我在R studio的RMarkdown文件中有这个乳胶代码:
---
title: "matrix"
date: "November 2, 2016"
output:
pdf_document: default
---
$$
\mathbf{y} = \left[\begin{array}
{rrr}
y_{1,1} \\
y_{4,3}
\end{array}\right]
\mathbf{X} = \left[\begin{array}
{rrr}
1 & 0 & 0 & 0 \\
1 & 0 & 0 & 0
\end{array}\right]
$$
预览在Rstudio中显示正常: 但是,当我编写pdf时,我收到此错误消息:
! LaTeX Error: \mathbf allowed only in math mode.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.88 \$\$ \mathbf{y}
pandoc: Error producing PDF
Error: pandoc document conversion failed with error 43
Execution halted
我该如何解决?
答案 0 :(得分:3)
如果您更改为显式数学环境,则可以正常工作:
---
title: "matrix"
date: "November 2, 2016"
output:
pdf_document: default
---
\begin{equation}
\mathbf{y} = \left[\begin{array}
{r}
y_{1,1} \\
y_{4,3}
\end{array}\right]
\mathbf{X} = \left[\begin{array}
{rrrr}
1 & 0 & 0 & 0 \\
1 & 0 & 0 & 0
\end{array}\right]
\end{equation}
除了您还要修复数组对齐,否则
Extra alignment tab has been changed to \cr.
(第一个需要{r}
,第二个需要{rrrr}