简体   繁体   English

RMarkdown / Pandoc无法使用乳胶颜色命令来编织Pdf

[英]RMarkdown / pandoc fails to knit Pdf with latex color commands

  • Mac Os: 10.11.6 Mac OS:10.11.6
  • R version: 3.3.1 R版本:3.3.1
  • MacTex: 2016 / TexLive: 6.2.2 MacTex:2016 / TexLive:6.2.2
  • RMarkdown: 1.0.9014 RMarkdown:1.0.9014
  • Knitr: 1.14 针织物:1.14
  • Pandoc: 1.17 潘多克:1.17

RMarkdown fails to knit PDF when latex commands such as: 当乳胶命令(例如)时,RMarkdown无法编织PDF:

\textcolor{blue}{Character String} 

are present in the .rmd file. 在.rmd文件中。 The error output is: 错误输出为:

/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' ! / 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探戈--latex-engine / Library / TeX / texbin / pdflatex --variable graphics = yes --variable'geometry:margin = 1in'! Undefined control sequence. 未定义的控制顺序。 l.105 \\textcolor l.105 \\ textcolor

pandoc: Error producing PDF pandoc:生成PDF时出错

Error: pandoc document conversion failed with error 43 错误:pandoc文档转换失败,错误43

Execution halted 执行停止

Inclusion of an r code chunk with echo = TRUE such as: 包含带有echo = TRUE的r代码块,例如:

```{r, echo = TRUE}
# I am a glitch 
```

in the .rmd file allows for the successful creation of the PDF document. .rmd文件中的允许成功创建PDF文档。

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. 如果.rmd文件中的所有r代码块均设置为echo = FALSE或等效语句,则如果存在诸如/ textcolor之类的乳胶命令,则无论使用的乳胶引擎如何,PDF文件都不会编织。 If only latex commands such as \\begin{tabular}, many , etc… are used the error is not present. 如果只有胶乳命令如\\ {开始片状}, 许多等...被使用的错误不存在。

Addition of “header-includes: \\usepackage{color}” to the YAML header, as seen below, addresses the issue. 如下所示,在YAML标头中添加了“标头包括:\\ usepackage {color}” ,解决了该问题。 However, it is unclear why insertion of an “echo = TRUE” R-code chunk also resolves the issue. 但是,不清楚为什么插入“ echo = TRUE” R代码块也可以解决该问题。

---
title: "test"
output: pdf_document
header-includes: \usepackage{color}
---

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. 有趣的是,与以前版本的R-Studio套件的,如下面看到的,列入“报头包括:\\ usepackage {颜色}”中的YAML头,并未使用的命令之前需要诸如“\\文本颜色{ .rmd文件中的“ blue} {Character String}”

  • Mac OS: 10.10.5 Mac OS:10.10.5
  • R Version: 3.2.2 R版本:3.2.2
  • MacTex: 2014 / TexLive: 6.2.0 MacTex:2014年/ TexLive:6.2.0
  • Rmarkdown: 1.0 Rmarkdown:1.0
  • Knitr: 1.13 针织物:1.13
  • Pandoc: 1.13.1 Pandoc:1.13.1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM