R knitr PDF problems with includegraphics



使用一个新的空 .rmd 文档,此代码工作:

![](RainbowDolphin.png)
begin{center}
includegraphics[width=4in]{RainbowDolphin.png}
end{center}

但是如果没有第一行,它不会:

begin{center}
includegraphics[width=4in]{RainbowDolphin.png}
end{center}

我收到一个错误:

! Undefined control sequence.
l.71 includegraphics
pandoc.exe: Error producing PDF from TeX source
Error: pandoc document conversion failed with error 43
In addition: Warning message:
running command '"C:/Program Files/RStudio/bin/pandoc/pandoc" Sampling_03.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output Sampling_03.pdf --template "C:PROGRA~1RR-31~1.2libraryRMARKD~1rmdlatexdefault.tex" --highlight-style tango --latex-engine pdflatex --variable "geometry:margin=1in"' had status 43 
Execution halted

奇怪。任何帮助表示赞赏!

这是因为乳胶模板默认情况下不会加载图形包。您可以通过将其添加到 yaml 标头来手动执行此操作:

---
title: "Untitled"
header-includes: usepackage{graphicx}
output: 
    pdf_document:
        keep_tex: true
---

您可以通过指定 YAML 元数据让 Pandoc 知道您在本文档中有图形:

---
graphics: yes
---

相关内容

  • 没有找到相关文章

最新更新