使用Knitr将mathéquation导出为pdf时出错

问题描述 投票:1回答:1

我正在尝试将我的.rmd脚本导出为pdf。使用Knitr(和Pandoc我猜)。在这段代码中,我在第116行有一个数学公式:

$$
\text{Sleep_cr}  = \frac{\text{Sleep_Data}-\boldsymbol\mu}{\boldsymbol{S}}
$$ 

当我编织pdf时,我收到此错误:

! Missing $ inserted.
<inserted text> 
            $
l.274 \$ \text{Sleep_cr}

pandoc.exe: Error producing PDF
Error: pandoc document conversion failed with error 43

如果我从脚本中删除方程式一切正常,我可以打印pdf。

我怎样才能做到这一点?

我有Windows 10和新下载的MikTex。

pdf latex knitr r-markdown
1个回答
1
投票

下划线是LaTeX中的特殊字符,您必须将它们转义:

$$
\text{Sleep\_cr}  = \frac{\text{Sleep\_Data}-\boldsymbol\mu}{\boldsymbol{S}}
$$ 
© www.soinside.com 2019 - 2024. All rights reserved.