RMarkdown / pandoc fails to knit Pdf with latex color commands

  • Mac Os: 10.11.6
  • R version: 3.3.1
  • MacTex: 2016 / TexLive: 6.2.2
  • RMarkdown: 1.0.9014
  • Knitr: 1.14
  • Pandoc: 1.17
  • RMarkdown fails to knit PDF when latex commands such as:

    textcolor{blue}{Character String} 
    

    are present in the .rmd file. 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' ! Undefined control sequence. l.105 textcolor

    pandoc: Error producing PDF

    Error: pandoc document conversion failed with error 43

    Execution halted

    Inclusion of an r code chunk with echo = TRUE such as:

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

    in the .rmd file allows for the successful creation of the PDF document.

    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.


    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}
    ---
    

    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 Version: 3.2.2
  • MacTex: 2014 / TexLive: 6.2.0
  • Rmarkdown: 1.0
  • Knitr: 1.13
  • Pandoc: 1.13.1
  • 链接地址: http://www.djcxy.com/p/33476.html

    上一篇: 为什么从rmarkdown渲染pdf需要在渲染之间关闭rstudio?

    下一篇: RMarkdown / pandoc无法用乳胶颜色命令编织PDF