Error generating PDF in R Markdown

Hi guys, I'm using R Markdown to generate a report of my graphs. However, I can only generate in HTML or Word format, for the PDF format it gives an error. The error is below:

output file: teste.knit.md
Erro: LaTeX failed to compile teste.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips.
Além disso: Warning messages:
1: In system2(..., stdout = if (use_file_stdout()) f1 else FALSE, stderr = f2) :
'CreateProcess' failed to run 'C:\Users\Jovani Souza\AppData\Local\Programs\MiKTeX 2.9\miktex\bin\x64\pdflatex.exe -halt-on-error -interaction=batchmode "teste.tex"'
2: In system2("tlmgr", args, ...) :
'CreateProcess' failed to run 'C:\Users\Jovani Souza\AppData\Roaming\TinyTeX\bin\win32\tlmgr.bat update --all --self'
Execução interrompida

Could someone help me solve this problem? I reinstalled MiKTeX and tinytex too, but without effectiveness.

Thanks!

Are you using both MikTex and TinyTex distribution ?

Actually Miktext, but I saw that some forums indicated to install this TinyTex that would work. But it didn't even work when I installed it.

TinyTex is recommanded with Rmakdown but you can still use MikTex. You just need to have only one installed to be sure there is no conflict.

Here both seem to be used so I am unclear...

Hello Friend. I uninstalled MikTex. I reinstalled TinyTex. But it is giving error again.

output file: teste.knit.md

"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS teste.utf8.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output teste.tex --self-contained --highlight-style tango --pdf-engine pdflatex --variable graphics --lua-filter "C:/Users/Jovani Souza/Documents/R/win-library/3.5/rmarkdown/rmd/lua/pagebreak.lua" --lua-filter "C:/Users/Jovani Souza/Documents/R/win-library/3.5/rmarkdown/rmd/lua/latex-div.lua" --variable "geometry:margin=1in" --include-in-header "C:\Users\Jovani Souza\AppData\Local\Temp\RtmpSkf2Cz\rmarkdown-str355c49d634f1.html"
Erro: LaTeX failed to compile teste.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips.
Além disso: Warning messages:
1: In system2(..., stdout = if (use_file_stdout()) f1 else FALSE, stderr = f2) :
'CreateProcess' failed to run 'C:\Users\Jovani Souza\AppData\Roaming\TinyTeX\bin\win32\pdflatex.exe -halt-on-error -interaction=batchmode "teste.tex"'
2: In system2(...) :
'CreateProcess' failed to run 'C:\Users\Jovani Souza\AppData\Roaming\TinyTeX\bin\win32\pdflatex.exe -halt-on-error -interaction=batchmode "teste.tex"'
3: In system2("tlmgr", args, ...) :
'CreateProcess' failed to run 'C:\Users\Jovani Souza\AppData\Roaming\TinyTeX\bin\win32\tlmgr.bat update --all --self'
Execução interrompida

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

I think you have a similar issue as @dkStevensNZed here

I don't know if a solution was found or not...

I is possible this is an issue because you have a space in your username, CreateProcess does not seems to like that. There is some mention on this on the web, but I am not sure... :man_shrugging:

This needs to be investigated.

Out of curiosity, is this working ?

tinytex::tlmgr("--version")

Thanks for the answer. I created another user on the computer with only a name "Test", I installed the package again, however it gave the same error.

If I uninstall TinyTex and install only MikText, can it work?

Just in case I installed the package like this:
install.packages ('tinytex')
tinytex :: install_tinytex ()
But when it is installing it gives a small error, but later it continues to install. The error is attached.

The information you asked for. I entered in the console and it appears:

tinytex :: tlmgr ("- version")
tlmgr --version

error

Yes it should work - the R package works also with MikTex

This is normal as explain in the error message box.

This results with this for me

> tinytex::tlmgr("--version")
tlmgr --version
tlmgr revision 53842 (2020-02-19 08:28:40 +0100)
tlmgr using installation: C:/Users/chris/AppData/Roaming/TinyTeX
TeX Live (http://tug.org/texlive) version 2019

Do you have something similar ?

No. Yours is looking different. Is it not installing Tinytex properly? But see the image that I attached. I can open the library and it appears as an installed package.

Just for clarifying based on yourlast comment, tinytex :package: is different than TinyTex distribution. (note the T) You can use tinytext :package: without TinyTex distribution for example.
See the documentations

TinyTeX is a custom LaTeX distribution based on TeX Live that is small in size (150Mb on macOS/Linux and 220Mb on Windows) but functions well in most cases, especially for R users.

The package mainly provides two sets of functions: functions to manage TinyTeX, and those that help compile LaTeX documents to PDF.

In your last example,did you install the latex distribution TinyTex or did you use MikTex ? From what I said above, you can have the :package: installed but not the distribution.

What is the result of this

tinytex::tinytex_root()
#> [1] "C:\\Users\\chris\\AppData\\Roaming\\TinyTeX"

To install, uninstall or reinstall TinyTex, you'll find that in the doc.

Hope it helps

2 Likes

Christophe, now it worked. I was getting confused between tinytex and TinyTex.

I installed from this site: http://tug.org/texlive/acquire-netinstall.html

Thanks for letting me know and sorry for the inconvenience.

3 Likes

Glad I could help !

If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.