2014-02-27 48 views
40

当我使用的渲染{} rmarkdown产生在我的Mac从.Rmd文件pdf文件,错误消息说rmarkdown:pandoc:pdflatex没有找到

pandoc: pdflatex not found. pdflatex is needed for pdf output. Error: pandoc document conversion failed

然而,当我检查与

pdflatex -v 

pdfTeX 3.1415926-2.4-1.40.13 (TeX Live 2012) 
kpathsea version 6.1.0 
Copyright 2012 Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX). 
There is NO warranty. Redistribution of this software is 
covered by the terms of both the pdfTeX copyright and 
the Lesser GNU General Public License. 
For more information about these matters, see the file 
named COPYING and the pdfTeX source. 
Primary author of pdfTeX: Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX). 
Compiled with libpng 1.5.10; using libpng 1.5.10 
Compiled with zlib 1.2.7; using zlib 1.2.7 
Compiled with xpdf version 3.03 

的pdflatex安装在我的机器。

任何人都可以帮助告诉我如何告诉R在哪里可以找到pdflatex?

非常感谢!

+0

您是否在安装pdflatex后重新启动R? – daroczig

+0

是的,我做到了。仍然没有工作。 – askming

回答

30

This answer on TexExchange might help

我发现我在升级到OS X Mavericks后(例如在RStudio中检查包版本时收到error tools::texi2pdf pdflatex missing消息)时出现pdflatex“缺失”问题。

  1. 检查/usr/texbin是否存在。
    在终端:

    cd /usr/texbin 
    
  2. 如果“没有这样的文件或目录”,那么你需要创建一个符号链接到你安装的texbin。矿是/Library/TeX/Distributions/.DefaultTeX/Contents/Programs/texbin
    在终端:

    ln -s /Library/TeX/Distributions/.DefaultTeX/Contents/Programs/texbin /usr/texbin 
    
  3. 在终端,检查echo $PATH结果。确保存在/usr/texbin。如果它不存在,则需要将/usr/texbin添加到您的PATH变量中。

如果您发现有自己惹PATH变量,安装最新版本的MacTex可能是一个更好的解决方案。

UPDATE: OS X 10.11埃尔卡皮坦不再允许写入/usr所以MacTEX都(2015)的最新版本,现在这个系统上写了一个链接/Library/TeX/texbin而不是/usr/texbin

+0

[this]的第8部分(http://tug.org/mactex/UpdatingForElCapitan.pdf)非常方便 - 您不需要安装更新版本的mactex – kungfujam

+2

可能有用的是提及重新启动R-Studio在做符号链接后需要。 –

7

对于那些因为在他们的Linux分配中出现相同错误而滞留在此处的人。例如获取pdflatexUbuntu的通过安装

sudo apt-get install texlive-latex-extra 

其太多的软件,而是通过knitr需要例如(rmarkdown-PDF编译)

14

对于使用扣篮的回答那些被发现(对于使用Ubuntu谁得到了0123人)错误,你还需要:

sudo apt-get install texlive-fonts-recommended texlive-latex-recommended 

这确实很遗憾扩大的规模相当的texlive安装,但它仍然是一个texlive-latex-extra的一半大小安装。

+0

您应该建议对该答案进行编辑,而不是将您的评论写为新的“答案”。 – Carpetsmoker

+2

@Carpetsmoker如果这样的编辑实际上被拒绝了,我不会感到惊讶。无论如何,它确实扩展了解决面临的其中一个问题的解决方案。 – Zizouz212

+3

通过在'apt-get install'中添加'--no-install-recommendations'参数,可以大大缩小占用空间。例如,要使用'rmarkdown'工作的PDF渲染,我安装了大约300MB的这些文件: 'apt-get -y --no-install-recommendations install texlive-latex-base texlive -fonts-recommended texlive-latex - 额外lmodern' – Leons