title: Why No Latex Installation Detected
body: <p>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:</p>
  <p>output file: intro_R_notebook_1.knit.md</p>
  <p>Error: LaTeX failed to compile intro_R_notebook_1.tex. See <a href="https://yihui.org/tinytex/r/#debugging" rel="nofollow noreferrer">https://yihui.org/tinytex/r/#debugging</a> for debugging tips.
  In addition: Warning message:
  In system2(..., stdout = if (use_file_stdout()) f1 else FALSE, stderr = f2) :
  '&quot;pdflatex&quot;' not found
  Execution halted</p>
  <p>No LaTeX installation detected (LaTeX is required to create PDF output). You should install a LaTeX distribution for your platform: <a href="https://www.latex-project.org/get/" rel="nofollow noreferrer">https://www.latex-project.org/get/</a></p>
  <p>If you are not sure, you may install TinyTeX in R: tinytex::install_tinytex()</p>
  <p>Otherwise consider MiKTeX on Windows - <a href="http://miktex.org" rel="nofollow noreferrer">http://miktex.org</a></p>
  <p>MacTeX on macOS - <a href="https://tug.org/mactex/" rel="nofollow noreferrer">https://tug.org/mactex/</a>
  (NOTE: Download with Safari rather than Chrome <em>strongly</em> recommended)</p>
  <p>Linux: Use system package manager</p>
  <p>In the YAML I have have the following for the pdf part:
  output:</p>
  <p>pdf_document: default</p>
  <p>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'):</p>
  <p><strong>C:\Users\johndoe\Documents\R\R-4.0.5\library\tinytex</strong></p>
  <p>This path is different that where tintex installed itself on my other (4 year old) laptop, which looks like this:</p>
  <p><strong>C:\Users\johndoe\Documents\R\win-library\4.0\tinytex</strong></p>
  <p>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).</p>
  <p>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.</p>