2014-02-27 44 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