我试图在r标记中使用LaTeX 网格系统包。有人知道怎么做吗?当生成单元格(包括纯文本)时一切都进行得很好,但是当试图包含r块时,我得到了以下错误:
output file: testtest.knit.md
! You can't use `macro parameter character #' in horizontal mode.
\gridsystem@cellcontent0 ...(cars) ``` \par ``` ##
## speed dist #### Min. : ...
l.106 \end{Row}
pandoc.exe: Error producing PDF
Error: pandoc document conversion failed with error 43
In addition: Warning message:
running command '"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS testtest.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output testtest.pdf --template "C:\Users\pc\Documents\R\win-library\3.3\rmarkdown\rmd\latex\default-1.17.0.2.tex" --highlight-style tango --latex-engine xelatex --variable graphics=yes --variable "geometry:margin=1in"' had status 43
Execution halted我使用了这个代码:
---
output:
pdf_document:
latex_engine: xelatex
header-includes:
- \usepackage{grid-system}
---
\begin{Row}%
\begin{Cell}{2}
```{r cars}摘要(Cars)
\end{Cell}
\begin{Cell}{1}
Some text using 1/3 of the width.
\end{Cell}
\end{Row}最新情况:
注释中提到的解决方案comment=">"适用于上面的代码,但是当试图包含一个情节时,如下所示:
---
output:
pdf_document:
latex_engine: xelatex
header-includes:
- \usepackage{grid-system}
---
\begin{Row}
\begin{Cell}{5}
```{r, comment='>'}绘图(压力)
\end{Cell}
\begin{Cell}{1}
Some text using 1/6 of the width.
\end{Cell}
\end{Row}它会产生以下错误:
! Missing $ inserted.
<inserted text>
$
l.98 \end{Row}发布于 2017-03-28 09:21:21
有几个符号,在Tex中有一个特殊的含义。散列用于创建宏。因此,当您使用哈希而不转义哈希时,LaTex会感到困惑。将块选项comment设置为其他符号(如>或根本没有符号('') )将改变这一点。
关于你的第二个问题,我不知道为什么翻译的代码包括在最终pdf中的情节失败。解决方法是生成绘图,并直接使用LaTeX调用来包含该文件:
```{r cars, engine='R', echo = F, include=F, fig.path='plots/'}绘图(压力,col =‘蓝色’,pch = 16)
\includegraphics{plots/cars-1.pdf} 您可以使用fig.path控制文件夹的名称。这些情节是用块名命名的。
https://stackoverflow.com/questions/43028687
复制相似问题