【发布时间】:2017-12-29 05:52:00
【问题描述】:
我在输出类型为“beamer presentation”的 Rmd 文档中居中绘图时遇到问题。当输出类型设置为“pdf_document”时,相同的代码可以正常工作。呈现我的文档时出现错误:
! Missing $ inserted.
<inserted text>
$
l.74 \end{frame}
pandoc: Error producing PDF
Error: pandoc document conversion failed with error 43
奇怪的是,我在使用命令render("slideshow.Rmd",output_file = "Demo slideshow.pdf") 编织时以及在 Rstudio GUI 中按“Knit”时都会出现此错误,但在后者中,我看到了一个 pdf,其中的情节是无论如何都居中。
编辑:事后看来,这可能不是真的。通过控制台语句进行渲染时,输出将打印在控制台的“控制台”选项卡中。通过'Knit'按钮渲染时,输出打印到控制台的'R markdown'选项卡,完成后自动返回'console'选项卡,仍然显示上一个渲染语句的错误.
我试过了
```{r, results = 'asis', echo = FALSE, fig.width=5, warning=FALSE, message=FALSE}
在这种情况下不会出现错误,但绘图是左对齐的。将此代码块包装在 \begin{center} 和 \end{center} 中会使我再次遇到同样的错误。
感谢任何帮助,提前感谢您的任何建议。
slideshow.Rmd
---
title: Oh man
subtitle: this issue is
author: really bugging me
fontsize: 10pt
output: beamer_presentation
---
```{r setup, include=FALSE, warning=FALSE, message=FALSE}
knitr::opts_chunk$set(echo = T)
df=data.frame(x=c(1,2,3),y=c(1,2,3))
```
### This is a title
And this is some text
```{r, results = 'asis', echo = FALSE, out.width='80%', warning=FALSE, message=FALSE, fig.align='center'}
plot(df$x,df$y)
```
【问题讨论】:
标签: r latex knitr r-markdown beamer