使用新的空.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~1\R\R-31~1.2\library\RMARKD~1\rmd\latex\default.tex" --highlight-style tango --latex-engine pdflatex --variable "geometry:margin=1in"' had status 43
Execution halted
怪异。任何帮助表示赞赏!
答案 0 :(得分:13)
这是因为乳胶模板默认不加载graphicx包。您可以通过将其添加到yaml标头手动执行此操作:
---
title: "Untitled"
header-includes: \usepackage{graphicx}
output:
pdf_document:
keep_tex: true
---
答案 1 :(得分:10)
您可以通过指定YAML元数据让Pandoc知道您在本文档中有图形:
---
graphics: yes
---