RStudio Knitr无法将Rmd转换为PDF(Windows 7)
我想使用RStudio(版本0.99.903)和RStudio Knitr无法将Rmd转换为PDF(Windows 7),r,rstudio,knitr,r-markdown,pandoc,R,Rstudio,Knitr,R Markdown,Pandoc,我想使用RStudio(版本0.99.903)和knitr将.Rmd文件(请参见下文)转换为PDF文件 --- title: "test" output: pdf_document --- Roses are \textcolor{red}{red}, violets are \textcolor{blue}{blue}. 运行“Knit PDF”时,我收到以下错误消息: processing file: test.Rmd output file: test.knit.md ! Undef
knitr
将.Rmd文件(请参见下文)转换为PDF文件
---
title: "test"
output: pdf_document
---
Roses are \textcolor{red}{red}, violets are \textcolor{blue}{blue}.
运行“Knit PDF”时,我收到以下错误消息:
processing file: test.Rmd
output file: test.knit.md
! Undefined control sequence.
l.87 Roses are \textcolor
pandoc.exe: Error producing PDF
Error: pandoc document conversion failed with error 43
In addition: Warning message:
running command '"C:/PROGRA~2/Pandoc/pandoc" +RTS -K512m -RTS test.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output test.pdf --template "C:\Users\fuq\R\R-3.3.1\library\rmarkdown\rmd\latex\default-1.17.0.2.tex" --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable "geometry:margin=1in"' had status 43
Execution halted
! Undefined control sequence.
l.87 Roses are \textcolor
pandoc.exe: Error producing PDF
Error: pandoc document conversion failed with error 43
In addition: Warning message:
running command '"C:/PROGRA~2/Pandoc/pandoc" +RTS -K512m -RTS test.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output test.pdf --template "C:\Users\fuq\R\R-3.3.1\library\rmarkdown\rmd\latex\default-1.17.0.2.tex" --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable "geometry:margin=1in"' had status 43
Execution halted
但是,如果我在.Rmd文件的任何位置添加R代码块,例如:
---
title: "test"
output: pdf_document
---
Roses are \textcolor{red}{red}, violets are \textcolor{blue}{blue}.
```{r}
summary(cars)
```
然后,我就可以成功地得到我期望的PDF
但奇怪的是,如果在上述.Rmd文件中设置echo=FALSE
(见下文)
然后,我再次收到相同的错误消息:
processing file: test.Rmd
output file: test.knit.md
! Undefined control sequence.
l.87 Roses are \textcolor
pandoc.exe: Error producing PDF
Error: pandoc document conversion failed with error 43
In addition: Warning message:
running command '"C:/PROGRA~2/Pandoc/pandoc" +RTS -K512m -RTS test.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output test.pdf --template "C:\Users\fuq\R\R-3.3.1\library\rmarkdown\rmd\latex\default-1.17.0.2.tex" --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable "geometry:margin=1in"' had status 43
Execution halted
! Undefined control sequence.
l.87 Roses are \textcolor
pandoc.exe: Error producing PDF
Error: pandoc document conversion failed with error 43
In addition: Warning message:
running command '"C:/PROGRA~2/Pandoc/pandoc" +RTS -K512m -RTS test.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output test.pdf --template "C:\Users\fuq\R\R-3.3.1\library\rmarkdown\rmd\latex\default-1.17.0.2.tex" --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable "geometry:margin=1in"' had status 43
Execution halted
我在64位Windows 7上工作,并获得了最新版本的MiKTex。有谁能告诉我出了什么问题吗?你必须包括包装
颜色,然后它才能工作。我不知道为什么只有在R块的情况下才起作用。但这个解决方案将解决这个问题:
---
title: "test"
output: pdf_document
header-includes: \usepackage{color}
---
Roses are \textcolor{red}{red}, violets are \textcolor{blue}{blue}.
如果要将颜色编织到HTML,必须使用以下代码:
---
title: "test"
output: html_document
---
Roses are <span style="color:red">red</span>,
violets are <span style="color:blue">blue</span>.
---
标题:“测试”
输出:html\u文档
---
玫瑰是红色的,
紫罗兰是蓝色的。
非常感谢您。它可以转换成PDF格式!!!但是,当我试图将相同的.Rmd文件“编织”到HTML文件时,那些彩色文本消失了。你对这个问题也有什么想法吗?非常感谢。而且“编织词”也有一个问题。这些彩色文本不会出现在最终文档中。@mikeqfu:HTML的问题已经解决,请参阅我编辑的答案。对于Word女士,我现在还没有一个解决方案。