在 LaTeX 中垂直和水平对齐矩阵

发布于 2024-07-22 06:00:41 字数 319 浏览 4 评论 0原文

我试图在 LaTeX 中实现这一点:

⎡a⎤ ⎡b …  n⎤
⎢⁞⎢ ⎢⁞ ⋱ ⁞⎢
⎣x⎦ ⎣y …  z⎦

      [a  … x]

我能够在一行上获得一个向量 + 一个矩阵,但我不确定如何对齐下面的向量,以便它完美地位于大矩阵下方。

下面是上面“绘图”的 less-unicode 文本表示形式:

[a] [ b c ]
[d] [ e f ]
    [ g h ] 

请注意,最后一行 ([ gh ]) 是一个单行矩阵,与其上方的 2x2 矩阵分开。

I'm trying to accomplish this in LaTeX:

⎡a⎤ ⎡b …  n⎤
⎢⁞⎢ ⎢⁞ ⋱ ⁞⎢
⎣x⎦ ⎣y …  z⎦

      [a  … x]

I'm able to get a vector + a matrix on one line, but I'm not sure how to align the vector below so that it sits perfectly under the large matrix.

Here's a less-unicode text representation of the 'drawing' above:

[a] [ b c ]
[d] [ e f ]
    [ g h ] 

Note that the last line ([ g h ]) is a single-row matrix, separate from the 2x2 matrix above it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

魔法少女 2024-07-29 06:00:41

\编辑2
最终答案:

\begin{align*}
        \begin{vmatrix} 1 \\ 2 \end{vmatrix} &\begin{vmatrix} 1 & 2 & 3 \\ 3 & 4 & 5 \end{vmatrix} \\[6px]
        &\begin{vmatrix} 2 & 3 & 4 \end{vmatrix} 
\end{align*}

完全符合您的要求,请阅读下文以了解有关展示位置等的更多信息。 “&” 符号一般用于对齐。 忘记了第一行有 2 个矩阵,但现在你有了它:)。

有关间距等的信息
\开始{对齐*}
&\begin{pmatrix} 1 & 2& 3\3& 4& 5 \end{pmatrix} \[6px]
&\hspace{2px}\begin{pmatrix} 2 & 3& 4 \结束{p矩阵}
\end{align*}

可以完成这项工作。 由于某些奇怪的原因,在省略第一个“&”时,对齐会出错。 符号,它给出了 2px 的偏移量。 我认为如果不保留 [6px],您希望两者之间有一些空间。 您始终可以使用 \hspace{空白数量} 将第二个矩阵放置在您想要的位置。 这可以用 pt、px(我就是这样做的)等形式给出。

//edit
嗯,我注意到 \hspace{} 实际上是不需要的,但可以在 pmatrix 的情况下使用。 发生的情况是 pmatrix 括号给出了矩阵的有偏差图像。 当使用vmatrix时:

\begin{align*}
        &\begin{vmatrix} 1 & 2 & 3 \\ 3 & 4 & 5 \end{vmatrix} \\[6px]
        &\begin{vmatrix} 2 & 3 & 4 \end{vmatrix} 
\end{align*}

一切顺利:)。 所以基本上,修复它的最简单方法可能是使用其他括号使其看起来不错,或者使用 \hspace 根据您的喜好进行对齐。

\edit2
final answer:

\begin{align*}
        \begin{vmatrix} 1 \\ 2 \end{vmatrix} &\begin{vmatrix} 1 & 2 & 3 \\ 3 & 4 & 5 \end{vmatrix} \\[6px]
        &\begin{vmatrix} 2 & 3 & 4 \end{vmatrix} 
\end{align*}

does exactly what you want, read below for more info about placement and such. The "&" sign is used to align in general. Forgot the first line had 2 matrices but now you have it :).

info on spacing and such
\begin{align*}
&\begin{pmatrix} 1 & 2 & 3 \ 3 & 4 & 5 \end{pmatrix} \[6px]
&\hspace{2px}\begin{pmatrix} 2 & 3 & 4 \end{pmatrix}
\end{align*}

would do the job. For some strange reason the align gave errors when leaving out the first "&" symbol and it gave a 2px offset. I figured you wanted some space between the two if not leave the [6px]. You can always use \hspace{amount of whitespace} to place your second matrix in the place you want. This can be given in pt's, px's (which i did) etc.

//edit
Hm I notice the \hspace{} is actually not needed, but can be used in case of pmatrix. What happens is that the pmatrix brackets give a biased image of the matrices. When using vmatrix like:

\begin{align*}
        &\begin{vmatrix} 1 & 2 & 3 \\ 3 & 4 & 5 \end{vmatrix} \\[6px]
        &\begin{vmatrix} 2 & 3 & 4 \end{vmatrix} 
\end{align*}

It all goes well :). So basically, probably the easiest way to fix it is either use other brackets to make it look good or use the \hspace to align as you like it.

紫竹語嫣☆ 2024-07-29 06:00:41

如果一切都失败了, PGF/TikZ 可以这。 请参阅此示例

If all else fails, PGF/TikZ can do this. See this example.

怀中猫帐中妖 2024-07-29 06:00:41

将内容包裹在 \begin{align*} ... \end{align*} 中,并使用 & 作为公式中的对齐标记。

示例:

<代码>

    \begin{align*}
        \begin{pmatrix} ... vector here \end{pmatrix}
        &\begin{pmatrix} ... first matrix here \end{pmatrix}\\
        &\begin{pmatrix} ... second matrix here \end{pmatrix}
    \end{align*}

Wrap the thing in \begin{align*} ... \end{align*} and use & as the alignment marker in your formulas.

Example:

    \begin{align*}
        \begin{pmatrix} ... vector here \end{pmatrix}
        &\begin{pmatrix} ... first matrix here \end{pmatrix}\\
        &\begin{pmatrix} ... second matrix here \end{pmatrix}
    \end{align*}

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文