本文介绍了使用\includegraphics编辑R knitr PDF问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用一个新的空的.rmd文件,这段代码有效: ![](RainbowDolphin.png)
\ begin {center}
\includegraphics [width = 4in] {RainbowDolphin.png}
\ end {center}
但没有第一行,它不会:
\开始{center}
\includegraphics [width = 4in] {RainbowDolphin.png}
\ end {center}
我收到一个错误:
!未定义的控制顺序。
l.71 \includegraphics
pandoc.exe:从TeX源生成PDF时出错
错误:pandoc文档转换失败,错误43
另外:警告消息:
运行命令'C:/ Program Files / RStudio / bin / pandoc / pandocSampling_03.utf8.md --to latex --from markdown + autolink_bare_uris + ascii_identifiers + tex_math_single_backslash-implicit_figures --output Sampling_03.pdf - 模板C:\PROGRA〜1 \R \R-31〜1.2 \ Library \RMARKD〜1 \rmd\latex\default.tex - highlight-style tango --latex -engine pdflatex --variablegeometry:margin = 1in'有状态43
执行停止
怪异。任何帮助表示赞赏!
解决方案
这是因为乳胶模板默认不加载graphicx软件包。您可以手动添加到yaml头文件中:
---
标题:无标题
header-includes:\ usepackage {graphicx}
输出:
pdf_document:
keep_tex:true
---
Using a new empty .rmd document, this code works:
![](RainbowDolphin.png)
\begin{center}
\includegraphics[width=4in]{RainbowDolphin.png}
\end{center}
But without the first line, it doesn't:
\begin{center}
\includegraphics[width=4in]{RainbowDolphin.png}
\end{center}
I get an error:
! 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
Weird. Any help appreciated!
解决方案
It's because the latex template doesn't load the graphicx package by default. You can do it manually by adding this to the yaml header:
---
title: "Untitled"
header-includes: \usepackage{graphicx}
output:
pdf_document:
keep_tex: true
---
这篇关于使用\includegraphics编辑R knitr PDF问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!