首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在r标记中使用LaTeX网格-系统包(并在LaTeX环境中放置r块)?

如何在r标记中使用LaTeX网格-系统包(并在LaTeX环境中放置r块)?
EN

Stack Overflow用户
提问于 2017-03-26 12:28:10
回答 1查看 459关注 0票数 0

我试图在r标记中使用LaTeX 网格系统包。有人知道怎么做吗?当生成单元格(包括纯文本)时一切都进行得很好,但是当试图包含r块时,我得到了以下错误:

代码语言:javascript
复制
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

我使用了这个代码:

代码语言:javascript
复制
---
output:
  pdf_document: 
    latex_engine: xelatex
header-includes:
   - \usepackage{grid-system}
---

\begin{Row}%
    \begin{Cell}{2}
```{r cars}

摘要(Cars)

代码语言:javascript
复制
    \end{Cell}
    \begin{Cell}{1}
    Some text using 1/3 of the width.
    \end{Cell}
\end{Row}

最新情况:

注释中提到的解决方案comment=">"适用于上面的代码,但是当试图包含一个情节时,如下所示:

代码语言:javascript
复制
---
output:
  pdf_document: 
    latex_engine: xelatex
header-includes:
   - \usepackage{grid-system}
---


\begin{Row}
    \begin{Cell}{5}
```{r, comment='>'}

绘图(压力)

代码语言:javascript
复制
    \end{Cell}
    \begin{Cell}{1}
    Some text using 1/6 of the width.
    \end{Cell}
\end{Row}

它会产生以下错误:

代码语言:javascript
复制
! Missing $ inserted.
<inserted text> 
                $
l.98 \end{Row}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-03-28 09:21:21

有几个符号,在Tex中有一个特殊的含义。散列用于创建宏。因此,当您使用哈希而不转义哈希时,LaTex会感到困惑。将块选项comment设置为其他符号(如>或根本没有符号('') )将改变这一点。

关于你的第二个问题,我不知道为什么翻译的代码包括在最终pdf中的情节失败。解决方法是生成绘图,并直接使用LaTeX调用来包含该文件:

代码语言:javascript
复制
```{r cars, engine='R', echo = F, include=F, fig.path='plots/'}

绘图(压力,col =‘蓝色’,pch = 16)

代码语言:javascript
复制
\includegraphics{plots/cars-1.pdf} 

您可以使用fig.path控制文件夹的名称。这些情节是用块名命名的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43028687

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档