Rmarkdown,Rstudio:pandoc.exe:从TeX源生成PDF时出错 [英] Rmarkdown, Rstudio: pandoc.exe: Error producing PDF from TeX source

查看:431
本文介绍了Rmarkdown,Rstudio:pandoc.exe:从TeX源生成PDF时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用RStudio中的knit pdf按钮来呈现pdf文档,但是我仍然不断遇到此错误:

I am trying to render a pdf document with the knit pdf button in RStudio, but I keep on getting this error:

! pdfTeX error (font expansion): auto expansion is only possible with scalable 
fonts.
\AtBegShi@Output ...ipout \box \AtBeginShipoutBox 
                                                  \fi \fi 
l.167 

pandoc.exe: Error producing PDF from TeX source
Error: pandoc document conversion failed with error 43

我知道在互联网上可以找到有关错误43的很多信息,但没有一个对我有帮助. 有谁知道这到底意味着什么以及在哪里可以找到解决方案?这很奇怪,因为几个小时前我遇到了同样的错误,但是在我的代码中添加了此渲染之后,渲染效果很好:

I know there is a lot be found on the internet regarding error 43, but non of them helped me. Does anyone know what it means exactly and where I can find the solution? It's peculiar because a few hours ago I had the same error but the rendering went well after adding this in my code:

Sys.setenv(PATH = paste(Sys.getenv("PATH"), "C:\\Program Files\\MiKTeX 2.9\\miktex\\bin\\x64\\", sep=.Platform$path.sep))

但是现在错误又回来了

编辑

尝试一个最小的示例时:

when trying a minimal example:

---
title: "test"
output: pdf_document
---

```{r results="asis"}
library(stargazer)
c1 <- c("test1","test1","test2","test2")
c2 <- c(1,2,3,4)
data_object <- as.data.frame(cbind(c1,c2))
names(data_object) <- c("test","test2")
stargazer(data_object,summary=FALSE,rownames=FALSE,type="html")
```

它给出的错误是:

!pdfTeX error: pdflatex (file ec-lmr10): Font ec-lmr10 at 600 not found
 ==> Fatal error occurred, no output PDF file produced!
Trying to make PK font ec-lmr10 at 600 DPI...
Running miktex-makemf.exe...
miktex-makemf: The ec-lmr source file could not be found.
miktex-makepk: The application file ttf2pk.exe could not be found.

pandoc.exe: Error producing PDF from TeX source
Error: pandoc document conversion failed with error 43

这是一个不同的错误,但仍然是43个错误.我检查了它,但是字体ec-lmr10文件在系统上.莫名其妙找不到它.

This is a different error, but still a 43 one. I checked it, but the font ec-lmr10 file is on the system. Somehow it can't be found.

推荐答案

您遇到的问题是与字体有关的问题.当您编织PDF时,knitr使用LaTeX,并且您必须知道LaTeX的字体"与标准字体不同.

The problem you have is a font related one. When you knit a PDF, knitr uses LaTeX and you have to know that "fonts" of LaTeX are not like the standard ones.

要解决您的问题,请尝试通过加载程序包来添加拉丁模型字体家族(位于最顶部):

To solve your problem try to add the latin model font family by loading the package (at the very top):

\usepackage{lmodern}

有关在您的文档中如何以及在何处插入这段代码的更多详细信息,请查看

For more detailed informations about how and where insert this piece of code in your document, have a look here.

此软件包允许您使用可缩放的字体;并非所有(字体)包中的所有字体都是如此. 我认为,但我可能错了,因为TeX和LaTeX的第一个版本是设计用于METAFONT的.

This package allows you to have scalable fonts; not all fonts of all (font) packages are to so. I think, but I might be wrong, because first versions of TeX and LaTeX were designed to work with METAFONT.

您的代码对我来说效果很好,它不会产生任何错误.我的想法是发生这种情况,因为我在Mac(MacTeX)上拥有完整的Tex实时发行版.在这一点上,我认为问题取决于您使用的r包(如stargazer)使用的某些包,而您(我们)不知道也不会(除非我们分析代码).

Your code works well for me, it does not produce any error. My idea is that happens because I have a complete Tex live distribution on my Mac (MacTeX). At this point I suppose that the problem relies on some packages that the r packages you use (like stargazer) use and you (we) do not know and won't (unless we analyze the code of course).

这时,我的建议是下载完整的TeX发行版,这样您就可以确保与PDF输出有关的任何错误都与Studio用于生成此类PDF的基础工具(例如LaTeX)无关.

At this point my suggestion is to download a complete TeX distribution so you will be sure that any error related to PDF output is no related to the underlying tool that Studio uses to produce such PDFs (say, LaTeX).

对于 Mac 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆