0
votes

Code

```{r, eval=TRUE}
library(caret)

plot(iris$Sepal.Length)
```

Error reported

pandoc.exe: pdflatex not found. pdflatex is needed for pdf output. Error: pandoc document conversion failed with error 41 In addition: Warning message: running command '"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS t4.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output t4.pdf --template "C:\Users\15235330\Documents\R\R-3.3.0\library\rmarkdown\rmd\latex\default-1.15.2.tex" --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable "geometry:margin=1in"' had status 41 Execution halted No TeX installation detected (TeX is required to create PDF output). You should install a recommended TeX distribution for your platform: Windows: MiKTeX (Complete) - http://miktex.org/2.9/setup (NOTE: Be sure to download the Complete rather than Basic installation) Mac OS X: TexLive 2013 (Full) - http://tug.org/mactex/ (NOTE: Download with Safari rather than Chrome _strongly_ recommended) Linux: Use system package manager

1
The error message is pretty clear about what is going wrong and how you can fix it. Have you installed MiKTeX as the message suggests?Marius
I have installed MikeTex and pandoc already, but it is not workingTuyen

1 Answers

-1
votes

After getting a new computer, I found this post I wrote a year ago, and the technique I documented below still worked. However my original instructions were not clear, and I have updated to hopefully help others having the same challenge. Of course, YMMV.

I spent hours trying to resolve this. I installed Miktex, but was unable to get the packages directly from the package manager due to sitting behind a firewall at work. I finally was able to resolve this using the following steps:

  1. Install Miktex
    • I used the basic installer
  2. Create a folder to install Miktex packages, e.g. "C:\miktex_pkgs"
  3. Go to the CTAN package archive and download the following .tar.lzma files:

    • fancyvrb
    • framed
    • microtype
    • miktex-zzdb1-2.9
    • miktex-zzdb2-2.9
    • mptopdf
    • titling
    • upquote
    • url
  4. After downloading the above files, move the above .tar.lzma files to the folder you created, e.g. "C:\miktex_pkgs"

  5. Open the MikTex Console Application downloaded in Step 1
    • Select "Packages"
    • Click "Install From" drop down
    • Click "change"
    • Select "Local package repository (file system)"
    • Click "Next",
    • Choose the folder you downloaded the .tar.lzma files to in Step 3
    • Click "Finish"
    • Click the "Update DB" logo next to the + - tool icons
    • Give a little bit of time to update.
  6. The packages should now show in the package list in the Miktex Console
  7. Close R studio out and re open.

Now you should be able to knit as PDF.