Unable to knit R Markdown file to pdf

I am unable to knit the rmarkdown file to pdf. I have tried every single thing on the internet however I am still getiin g this error. I did download MikTex on my system. It is not able to compile the tex file. Please let me know what can be done.

Error: Failed to compile HW1_samer.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. See HW1_samer.log for more info.
In addition: Warning messages:
1: running command '"pdflatex" -halt-on-error -interaction=batchmode "HW1_samer.tex"' had status 1 
2: running command '"pdflatex" -halt-on-error -interaction=batchmode "HW1_samer.tex"' had status 1 
Execution halted

Hi Supriya. It's more likely we'll be able to help you if you provide a sample rmarkdown file that gives this error when you try to knit it. This will allow us to reproduce the error you're getting and test out potential solutions.

How do I attach my RMD file here?

H @supriya24893!

You can copy and paste a small sample Rmd here by following these special formatting instructions: FAQ: How to Format R Markdown Source.

It might also help if you can describe all the steps you’ve taken already related to installing LaTeX. You mentioned MiKTeX — did you install in the default location following these instructions, or in another way? Can you open the MiKTeX console, and if so what do you see?

1 Like

Hi @supriya24893!

That document won’t be able to run on anybody else’s computer, since it references files that are only found on your computer. A good example of a sample document is the one that you get when you create a new R Markdown document within R Studio. Are you able to knit that default Rmd successfully? If not, then the problem probably lies with your LaTeX installation.

A couple of things I noticed above:

  • It’s not usually a good idea to install packages inside R Markdown documents, since installation is something that only needs to be done once, not every time you knit the document
  • The RTools for Windows are not an R package, so they can’t be installed with install.packages(). They are a set of external dependencies needed to build packages (or R itself) from source on Windows.
  • You have installed the tinytex R package that provides the TinyTeX (La)TeX distribution (good! It’s often easier for people to use than MiXTeX), but it doesn’t look like you’ve finished the TinyTeX installation? See the instructions here. These are also steps that only need to be run once from the console, not included in your Rmd.

What needs to be done in the MikTex console? Please let me know

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