Forums | OpenR

OpenR: R & Statistics /
I can't export PDF files in R Markdown.


Ruini Peng's profile picture
Posts: 6

25 March 2022, 7:04 PM

When I want to knit to PDF, it doesn't work. But, I can knit it into a word document. R studio shows that I should install LaTeX. So, how can I solve this problem, should I install LaTeX?
 
Error: LaTeX failed to compile draft.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
Rong Zhu's profile picture
Posts: 5
Ruini Peng's profile picture
Posts: 6

25 March 2022, 8:26 PM

Thanks for your help, but I still have the same problem. I have installed tinytex package and I tried to install pdflatex package, while there is a warning: package ‘pdflatex’ is not available for this version of R.

Peng Zhao's profile picture
Posts: 128

26 March 2022, 12:16 PM

There is no package called pdflatex in R, as the warning indicates.

You must have misunderstood R packages and LaTeX distribution. In short, you have to install LaTeX, and pdflatex is a component of LaTeX. For installing LaTeX, you can run the following code in R:

tinytex::install_tinytex()

It might take seconds to minutes, depending on you internet connection status.

After the installation, check if it is successfully installed:

tinytex::is_tinytex()

If you get TRUE, you are done. If FALSE, restart R or RStudio and repeat these two steps. If still failed, maybe it is your internet problem.

 

Ruini Peng's profile picture
Posts: 6

26 March 2022, 7:05 PM

Thank you! I can knit to PDF now! : )

Liancheng Lu's profile picture
Posts: 8

25 March 2022, 9:09 PM

Try knitting half to debug. If not work, knit half again to figure out what went wrong

Ruini Peng's profile picture
Posts: 6

26 March 2022, 7:04 PM

thank u!

7 results