Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Knitting to PDF in R

I am new to R and am trying to knit my R Markdown files into PDF format.

I continually get the error message:

pandoc: pdflatex not found. pdflatex is needed for pdf output. Error: pandoc document conversion failed with error 41 Execution halted

No TeX installation detected (TeX is required to create PDF output). You should install a recommended TeX distribution for your platform:

Windows: MiKTeX (Complete) - http://miktex.org/2.9/setup (NOTE: Be sure to download the Complete rather than Basic installation)

Mac OS X: TexLive 2013 (Full) - http://tug.org/mactex/ (NOTE: Download with Safari rather than Chrome strongly recommended)

Linux: Use system package manager

I have downloaded pandoc, and I have also downloaded TexLive and have installed them both onto my computer. For the life of me I cannot figure out why R wont recognize that Ive installed them, and knit into a PDF.

Please help!

like image 719
Jade Mestdagh Avatar asked Feb 04 '15 21:02

Jade Mestdagh


People also ask

Why can I not knit to PDF in R?

Looks like you have a character in your document that is not compatible with the inputenc LaTeX package. You may need to change the encoding if you are using non-English characters in your document.

How do I create a PDF in RStudio?

To transform your markdown file into an HTML, PDF, or Word document, click the “Knit” icon that appears above your file in the scripts editor. A drop down menu will let you select the type of output that you want. When you click the button, rmarkdown will duplicate your text in the new file format.

How do I knit a document in R?

If you are using RStudio, then the “Knit” button (Ctrl+Shift+K) will render the document and display a preview of it.


1 Answers

For Mac OS X, if you have installed TexLive (I installed so through homebrew caskroom) you should have pdftex available via command line.

type 'which pdftex' to make sure something shows up. from there, i created a symbolic link into my $PATH, specifically into my /usr/local/bin (which is where all my homebrew stuff is stored) with:

ln -s /usr/texbin/pdftex /usr/local/bin/pdflatex

from there, using knitr in RStudio and R in general seemed to work and rendering R Markdown is definitely a really beautiful option (check some of the templates too like the Tufte one!)

like image 93
Graham Annett Avatar answered Sep 23 '22 22:09

Graham Annett