Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rmarkdown: pandoc: pdflatex not found

When I use the render{rmarkdown} to produce pdf file from .Rmd file on my Mac, an error message says

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

However when I check with

pdflatex -v 

I got

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 

The pdflatex is installed in my machine.

Can anyone help to tell how can I tell R where to find the pdflatex?

Many thanks!

like image 504
askming Avatar asked Feb 27 '14 22:02

askming


2 Answers

For people using ubuntu who get stranded here a better option (because it is 1/5 the size) is to use:

sudo apt-get install texlive-latex-base 

Which I found via https://tex.stackexchange.com/a/128309

like image 108
Dunk Avatar answered Sep 17 '22 11:09

Dunk


This answer on TexExchange might help.

I found I was having issues with pdflatex "missing" after I upgraded to OS X Mavericks (e.g. when checking package builds in RStudio I was getting an error tools::texi2pdf pdflatex missing message).

  1. Check that /usr/texbin exists.
    In terminal:

    cd /usr/texbin 
  2. If "No such file or directory" then you will need to create a symbolic link to your installation's texbin. Mine was in /Library/TeX/Distributions/.DefaultTeX/Contents/Programs/texbin
    In terminal:

    ln -s /Library/TeX/Distributions/.DefaultTeX/Contents/Programs/texbin /usr/texbin 
  3. In terminal, check the result of echo $PATH. Make sure that /usr/texbin is present. If it isn't present, then you need to add /usr/texbin to your PATH variable.

If you find yourself having to mess with the PATH variable, installing the latest version of MacTex might be a better solution.

UPDATE: OS X 10.11 El Capitan no longer allows writes to /usr so the latest version of MacTeX (2015) now writes a link to /Library/TeX/texbin instead of /usr/texbin on this system.

like image 36
Eric Avatar answered Sep 18 '22 11:09

Eric