从Rmarkdown生成PDF

3

我正在使用Rstudio中的rmarkdown尝试使用Rstudio提供的示例代码生成PDF(如下所示):

---
title: "Untitled"
output: 
  pdf_document: 
    keep_tex: yes
---

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

```{r}
summary(cars)
```

You can also embed plots, for example:

```{r, echo=FALSE}
plot(cars)
```

Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.

但是,我遇到了以下错误:

! pdfTeX 错误(字体扩展):仅可使用可缩放字体进行自动扩展。 \AtBegShi@Output ...ipout \box \AtBeginShipoutBox \fi \fi l.144 \end{document}

pandoc.exe: 从 TeX 源文件生成 PDF 时出错 错误:pandoc 文档转换失败,错误代码为 43 另外:警告信息: 运行命令 '“C:/Program Files/RStudio/bin/pandoc/pandoc” +RTS -K512m -RTS test_rmarkdown.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output test_rmarkdown.pdf --template “C:\Users\XXXX\Documents\R\win-library\3.2\rmarkdown\rmd\latex\default.tex” --highlight-style tango --latex-engine pdflatex --variable “geometry:margin=1in”' 返回状态码 43 Execution halted

我的会话信息如下:

> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] Rcpp_0.11.6      digest_0.6.8     MASS_7.3-43      grid_3.2.2       plyr_1.8.2       gtable_0.1.2     magrittr_1.5     scales_0.2.4    
 [9] ggplot2_1.0.1    stringi_0.4-1    reshape2_1.4.1   rmarkdown_0.8    proto_0.3-10     tools_3.2.2      stringr_1.0.0    munsell_0.4.2   
[17] yaml_2.1.13      colorspace_1.2-6 htmltools_0.2.6 

我正在运行完整的TeXworks版本0.4.6 64位。


你解决了吗?我的回答有帮助吗? - Developer
1个回答

0

我之前也遇到过类似的问题。 尝试运行 devtools::install_github("rstudio/rmarkdown") 这对我有用。 如果你没有安装 devtools,你需要运行以下命令:

install.packages("devtools")
library(devtools).

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接