I am trying to render a pdf document with the knit pdf button in RStudio, but I keep on getting this error:
我正在尝试在RStudio中使用编织的pdf按钮呈现一个pdf文档,但是我一直得到这个错误:
! 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
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:
我知道在网上有很多关于错误43的信息,但是没有一个能帮助我。有人知道它的确切含义吗?我在哪里可以找到答案?这很奇怪,因为几个小时前我有同样的错误,但在我的代码中添加了这个之后,渲染效果很好:
Sys.setenv(PATH = paste(Sys.getenv("PATH"), "C:\\Program Files\\MiKTeX 2.9\\miktex\\bin\\x64\\", sep=.Platform$path.sep))
But now the error is back
但现在错误又回来了
EDIT
编辑
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")
```
The error it gives is:
它给出的错误是:
!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
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.
这是一个不同的错误,但仍然是43。我检查过了,但是字体ec-lmr10文件在系统上。不知何故,它找不到。
1 个解决方案
#1
3
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.
你的问题是字体相关的问题。当你编织一个PDF, knitr使用乳胶,你必须知道乳胶的“字体”不像标准的字体。
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.
有关在文档中插入这段代码的方式和位置的更详细信息,请参阅这里。
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.
这个包允许你有可伸缩的字体;并非所有(字体)包的字体都是这样的。我认为,但我可能错了,因为TeX和LaTeX最初版本是设计用来处理METAFONT的。
Edit
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).
你的代码对我来说很好用,不会产生任何错误。我的想法是这样的,因为我的Mac (MacTeX)上有一个完整的Tex live distribution。在这一点上,我假设问题依赖于您使用的r包(如stargazer)和您(我们)不知道和不会使用的包(当然,除非我们分析代码)。
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).
在这一点上,我的建议是下载一个完整的TeX发行版,这样您就可以确定与PDF输出相关的任何错误都与Studio用来生成PDF文件的底层工具无关(比如,LaTeX)。
You can find a complete LaTeX distribution for Mac and for Windows.
您可以为Mac和Windows找到完整的乳胶分布。
#1
3
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.
你的问题是字体相关的问题。当你编织一个PDF, knitr使用乳胶,你必须知道乳胶的“字体”不像标准的字体。
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.
有关在文档中插入这段代码的方式和位置的更详细信息,请参阅这里。
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.
这个包允许你有可伸缩的字体;并非所有(字体)包的字体都是这样的。我认为,但我可能错了,因为TeX和LaTeX最初版本是设计用来处理METAFONT的。
Edit
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).
你的代码对我来说很好用,不会产生任何错误。我的想法是这样的,因为我的Mac (MacTeX)上有一个完整的Tex live distribution。在这一点上,我假设问题依赖于您使用的r包(如stargazer)和您(我们)不知道和不会使用的包(当然,除非我们分析代码)。
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).
在这一点上,我的建议是下载一个完整的TeX发行版,这样您就可以确定与PDF输出相关的任何错误都与Studio用来生成PDF文件的底层工具无关(比如,LaTeX)。
You can find a complete LaTeX distribution for Mac and for Windows.
您可以为Mac和Windows找到完整的乳胶分布。