cookie monster
cookie monster

Reputation: 51

Why No Latex Installation Detected

I am running R 4.0.5 on Window 10. It's a new laptop with a very recent R, RStudio, and tinytex installations. I have a notebook file that works fine when I knit to Word. But when I try to knit to PDF, I get the following error:

output file: intro_R_notebook_1.knit.md

Error: LaTeX failed to compile intro_R_notebook_1.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. In addition: Warning message: In system2(..., stdout = if (use_file_stdout()) f1 else FALSE, stderr = f2) : '"pdflatex"' not found Execution halted

No LaTeX installation detected (LaTeX is required to create PDF output). You should install a LaTeX distribution for your platform: https://www.latex-project.org/get/

If you are not sure, you may install TinyTeX in R: tinytex::install_tinytex()

Otherwise consider MiKTeX on Windows - http://miktex.org

MacTeX on macOS - https://tug.org/mactex/ (NOTE: Download with Safari rather than Chrome strongly recommended)

Linux: Use system package manager

In the YAML I have have the following for the pdf part: output:

pdf_document: default

It looks like RStudio can't find the tinytex executable file. The file is located here on my PC (note: I changed part of the path to 'johndoe'):

C:\Users\johndoe\Documents\R\R-4.0.5\library\tinytex

This path is different that where tintex installed itself on my other (4 year old) laptop, which looks like this:

C:\Users\johndoe\Documents\R\win-library\4.0\tinytex

So we can see that the folder names are somewhat different, because the first case uses /library/ (the one not working by the way), and the second case uses /win-library/ (that one is working OK).

I am not sure if I have to modify the Windows 10 PATH environment variable to address this. That was not necessary on my other Windows laptop which runs tinytex OK. I tried removing and re-installing the rmarkdown package with dep=TRUE, which was suggested in another post. I also tried installing MikTex out of desperation, but that did not work. Not sure what to try next.

Upvotes: 3

Views: 14203

Answers (2)

Sohali Roy
Sohali Roy

Reputation: 1

In Console:

First Check if you have the 'tinytex' package already installed in R tinytex:::is_tinytex()

it will return TRUE or FALSE

If FALSE, then install it using

tinytex::install_tinytex()

It might take some time. Once it is done, check again

tinytex:::is_tinytex()

If installed, it will return TRUE [1] TRUE

then,

library(tinytex)

You should not get any errors anymore. Now you can proceed with your report-making.

Upvotes: 0

Yihui Xie
Yihui Xie

Reputation: 30114

Installing the R package tinytex is not enough. The message says:

You should install a LaTeX distribution for your platform [...] If you are not sure, you may install TinyTeX in R: tinytex::install_tinytex()

Did you try that?

Upvotes: 6

Related Questions