New problems producing pdf from Rmarkdown



I updated all of my packages and now have encountered new errors when attempting to generate pdf documents from Rmarkdown (called from a Shiny app). I installed tinytex in an effort to correct these issues and have ceased to be able to produce pdf reports at all. (Rmarkdown html output still works fine.) Can anyone tell from the following error message what my problem might be and how to correct it? Thank you!

“C:/Users/lewisjt4/AppData/Local/Pandoc/pandoc” +RTS -K512m -RTS --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output pandoc14c468294e79.tex --template “C:\Users\lewisjt4\Documents\R\win-library\3.4\rmarkdown\rmd\latex\default-” --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable "geometry:margin=1in"
Warning: running command ‘“pdflatex” -halt-on-error -interaction=batchmode “file14c46ddc4358.tex”’ had status 1
Warning: Error in : Failed to compile file14c46ddc4358.tex.
Stack trace (innermost first):
58: show_latex_error
57: on_error
56: system2_quiet
55: run_engine
54: latexmk_emu
53: tinytex::latexmk
52: latexmk
51: rmarkdown::render
50: download$func [downloadReports.R#155]
1: shiny::runApp
Error : Failed to compile file14c46ddc4358.tex.

R Shiny - Downloading a PDF Report Error

This is a bug in RMarkdown 1.9. Rolling back to RMarkdown 1.8 fixed it for me (after going crazy for multiple days trying to fix).

You can roll back the version using:

install_version(“rmarkdown”, version = “1.8”)

I’m about to email Yihui about the issue.


Thanks so much for your suggestion of going back to Rmarkdown 1.8. I should've followed your advice sooner. In wrestling with issues and going back and forth between tinytex and MiKTex, R is no longer able to find pdflatex on my computer. I'm sure it has to do with deleting and re-installing MiKTeX, but I don't know how to correct it. Sys.which("pdflatex") returns "" And any efforts to generate pdfs result in
pandoc.exe: pdflatex not found. pdflatex is needed for pdf output.
I've made sure that MiKTeX is in the path under system environment.
Any ideas?
Thank you!


Hi @JudyL. I was getting the same error a number of months ago on a MacBook, which I narrowed down to a Pandoc issue (I had a newer, separate version of Pandoc installed than the one bundled with RStudio which clearly created issues).

This SO answer confirms your suspicion that it is a path issue. Maybe there is something in this Tex Exchange Answer that might help?

I hope it gets sorted for you soon. Cheers, Steph


I would guess the same thing - issue with pandoc. I would reinstall MiKTeX and pandoc with defaults, then roll RMarkdown back to 1.8.


Thank you for this answer. Please do you have any suggestion regarding how to install this package behind a firewall?


I've had issues installing packages behind a firewall as well. The only thing I've figured out is to have our IT give me the ability to shut down the firewall on my comp temporarily while I install packages. Short of that, I don't know of a workaround.


The "official" answer is here: Personally I don't recommend downgrading to rmarkdown 1.8.

Issue when creating pdf file while running knit, output file does not exist (knit-HTML is fine)

Thank you very much. Ghanging version of markdown worked for me
You saved my life!



tinytex v0.5 has been released on CRAN, so all you need is install.packages('tinytex') now.