带有 3 个点的矩阵不会在 Rmarkdown 中呈现为 pdf

Matrix with 3 dots does not render to pdf in Rmarkdown

我想在 Rmarkdown pdf 文件中显示一个矩阵。使用基本 LaTeX 我创建了我想要的矩阵表示:

$$X_{123} = \begin{bmatrix}
a_{1} & a_{1} & a_{1} & \dots & a_{1} & a_{1} & a_{1} & a_{1} & a_{1} & a_{1} & a_{1}\
\ \vdots &\ \vdots &\ \vdots &\ \vdots &\ \vdots &\ \vdots &\ \vdots &\ \vdots &\ \vdots &\ \vdots &\ \vdots\
a_{n} & a_{n} & a_{n} & \dots & a_{n} & a_{n} & a_{n} & a_{n} & a_{n} & a_{n} & a_{n}\
\end{bmatrix}$$

当我在 Rmarkdown 文件中输入这个矩阵时,预览 window 显示我想要的矩阵:

但是,当我将 Rmd 文件编织成 pdf 文件时,我得到了这个错误:

! Extra alignment tab has been changed to \cr.
<recently read> \endtemplate 

当我删除所有创建 3 点符号的 \vdots\dots 时,渲染工作正常。我在这里错过了什么?

这看起来像是 LaTeX 问题而不是 RMarkdown 问题。如果删除任何列(因此矩阵只有 10 列,而不是 11 列)就可以了。

它在预览中起作用的原因是 RStudio 使用 MathJax 而不是 LaTeX 进行渲染。

在线搜索“amslatex 矩阵中的 10 列限制”发现此 link:https://tex.stackexchange.com/questions/3519/how-to-use-more-than-10-tab-stops-in-bmatrix-or-other-amsmath-matrix-environment,这说明您可以使用

增加限制
\setcounter{MaxMatrixCols}{20}