RMarkdown/Pandoc无法使用乳胶颜色命令来编织Pdf [英] RMarkdown / pandoc fails to knit Pdf with latex color commands
问题描述
- Mac OS:10.11.6
- R版本:3.3.1
- MacTex:2016年/TexLive:6.2.2
- RMarkdown:1.0.9014
- 针织衫:1.14
- Pandoc:1.17
当乳胶命令(例如:
\textcolor{blue}{Character String}
存在于.rmd文件中.错误输出为:
are present in the .rmd file. The error output is:
/usr/local/bin/pandoc + RTS -K512m -RTS test.utf8.md --to乳胶-from markdown + autolink_bare_uris + ascii_identifiers + tex_math_single_backslash --output test.pdf --template〜/R/3.3 /library/rmarkdown/rmd/latex/default-1.17.0.2.tex --highlight-style tango --latex-engine/Library/TeX/texbin/pdflatex --variable graphics = yes --variable'geometry:margin = 1in ' !未定义的控制顺序. l.105 \ textcolor
/usr/local/bin/pandoc +RTS -K512m -RTS test.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output test.pdf --template ~/R/3.3/library/rmarkdown/rmd/latex/default-1.17.0.2.tex --highlight-style tango --latex-engine /Library/TeX/texbin/pdflatex --variable graphics=yes --variable 'geometry:margin=1in' ! Undefined control sequence. l.105 \textcolor
pandoc:生成PDF时出错
pandoc: Error producing PDF
错误:pandoc文档转换失败,错误43
Error: pandoc document conversion failed with error 43
执行停止
包含带有echo = TRUE的r代码块,例如:
Inclusion of an r code chunk with echo = TRUE such as:
```{r, echo = TRUE}
# I am a glitch
```
.rmd文件中的
允许成功创建PDF文档.
in the .rmd file allows for the successful creation of the PDF document.
如果.rmd文件中的所有r代码块均使用echo = FALSE或等效语句设置,则如果存在诸如/textcolor之类的乳胶命令,则无论使用的乳胶引擎如何,PDF文件都不会编织.如果仅使用乳胶命令,例如\ begin {tabular},许多等…,则不会出现该错误.
If all r code chunks in the .rmd file are set with echo = FALSE or equivalent statements, the PDF file will not knit regardless of latex engine used if latex commands such as /textcolor are present. If only latex commands such as \begin{tabular}, many, etc… are used the error is not present.
推荐答案
在YAML标头中添加标头包括:\ usepackage {color}" ,可以解决此问题.但是,目前尚不清楚为什么插入"echo = TRUE" R代码块也可以解决该问题.
Addition of "header-includes: \usepackage{color}" to the YAML header, as seen below, addresses the issue. However, it is unclear why insertion of an "echo = TRUE" R-code chunk also resolves the issue.
---
title: "test"
output: pdf_document
header-includes: \usepackage{color}
---
有趣的是,对于R-Studio套件的早期版本(如下所示),在YAML标头中没有出现标头包括:\ usepackage {color}" ,在此之前并没有必要在.rmd文件中使用诸如"\ textcolor {blue} {Character String}" 之类的命令.
Interestingly, with a previous version of the R-Studio suite, as see below, inclusion of "header-includes: \usepackage{color}" in the YAML header, did not appear necessary prior to use of commands such as "\textcolor{blue}{Character String}" in the .rmd file.
- Mac OS:10.10.5
- R版本:3.2.2
- MacTex:2014年/TexLive:6.2.0
- Rmarkdown:1.0
- 针织衫:1.13
- Pandoc:1.13.1
这篇关于RMarkdown/Pandoc无法使用乳胶颜色命令来编织Pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!