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

标签 r pdf latex r-markdown markdown

我想在 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 中输入这个矩阵时文件,预览窗口显示我想要的矩阵:
enter image description here
然而,当我编织Rmd文件到 pdf 我收到此错误:
! Extra alignment tab has been changed to \cr.
<recently read> \endtemplate 
当我删除所有 \vdots\dots它创建了渲染工作正常的 3 点符号。我在这里缺少什么?

最佳答案

这看起来像是 LaTeX 问题而不是 RMarkdown 问题。如果您删除任何列(因此矩阵只有 10 列,而不是 11 列),那就没问题了。
它在预览中工作的原因是 RStudio 使用 MathJax 而不是 LaTeX 进行渲染。
在线搜索“amslatex 矩阵中的 10 列限制”找到此链接:https://tex.stackexchange.com/questions/3519/how-to-use-more-than-10-tab-stops-in-bmatrix-or-other-amsmath-matrix-environment ,这说明您可以通过使用增加限制

\setcounter{MaxMatrixCols}{20}

关于r - 带有 3 个点的矩阵不会在 Rmarkdown 中呈现为 pdf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68516555/

相关文章:

r - 如何在从股票代码列表中检索雅虎财经数据的 For 循环中进行错误处理

r - 在一个包中,如何使用 Rcpp 调用该包中的 R 函数?

makefile - 如何定义TeX/LaTeX和Makefile的语法?

latex - 如何在 R markdown beamer 中使用 latex 包?

r - 如何在百分比条形图上方添加百分比或计数标签?

r - R 函数中的非此即彼参数

cocoa-touch - 在 iPad 上的外部应用程序中打开 PDF 文件

latex - 防止\texttt LaTeX 标签让其内容越过边距

java - "PDF"场景当前发展的良好来源是什么?

objective-c - iBooks 如何在查看 PDF 时如此快速地呈现索引 View ?或者 : how do draw UIImages on UIScrollView directly without UIImageView?