我想把文字写进一个矩阵中,以描述某一行和某一列的元素代表什么。以下是我目前所得到的结果(经过几个小时!)。
\begin{equation*}
P_{m,n} =
\begin{pmatrix}
\text{description 1 - some text} & p_{1,2} \\
p_{2,1} & \text{description 2 - some more text} \\
\end{pmatrix}
\end{equation*}
文本没有包裹,而且相对于没有描述的行和列来说,它的大小太大。是否可以使用LaTeX在矩阵中写出包裹的文本(我在RStudio中使用Markdown)?- 如果可以,LaTeX的命令是什么?
你可以把文本放在 \parbox
并指定文本宽度和大小。 此外,我还展示了一个TABstack的替代方案,其中行基线跳过了 22pt
和柱隙 3pt
是很容易指定的.如果你使用Rmarkdown,无论如何,陈述公式可以使用$ ... $或$$...$更容易。
\documentclass{article}
\usepackage{amsmath,tabstackengine}
\begin{document}
\begin{equation*}
P_{m,n} =
\begin{pmatrix}
\parbox{.6in}{\raggedright\tiny description 1 - some text} & p_{1,2} \\
p_{2,1} & \parbox{.6in}{\raggedright\tiny description 2 - some more text} \\
\end{pmatrix}
\end{equation*}
\begin{equation*}
\setstackgap{L}{22pt}
\setstacktabbedgap{3pt}
P_{m,n} =
\parenMatrixstack{
\parbox{.6in}{\raggedright\tiny description 1 - some text} & p_{1,2} \\
p_{2,1} & \parbox{.6in}{\raggedright\tiny description 2 - some more text}
}
\end{equation*}
\end{document}
您可以使用以下组合 tabular
和 \left
\right
命令如下。
\documentclass{article}
\usepackage{array}
\begin{document}
$$
\left(
\begin{tabular}{m{2cm}<{\centering}m{2cm}<{\centering}}
description 1 - some text & $x$\\
$y$ & description 2 - some text
\end{tabular}
\right)
$$
\end{document}
这不是很优雅,但也许它接近你的愿望。此外,你可以调整列的宽度,而不是给出一个绝对长度。