Sorry for such a basic question but since I do not have a degree in programming...

I am a user of R, knitr and Notepad++. I was trying to configure Notepad++ to run pdflatex and knitr(knit2pdf). By googling I found how to do it for pdflatex but I did not find anything for sweave/knitr. The following are the good ones for pdflatex



I inserted cmd /c cd /d "$(CURRENT_DIRECTORY)" && pdflatex.exe -shell-escape "$(FILE_NAME)" into the run>run menu in Notepad++. I do not fully understand the command though. I will appreciate any help on this.

  1. Please direct me if you can to any resource for learning these commands.
  2. I will be grateful to get any help in configuring Notepad++ for running knitr.
  • when you're on superuser (and here too), note that when you rollover a tag that you have added (knitr), it will show you the number of followers. Many power users set up a list of tags that they watch the questions for. You only have ~350 followers looking at your question. Many topics have 1,000s of followers. Look for other tags to related topics that can get you more readers. Good luck. – shellter Mar 23 '12 at 3:53
  • Thanks @ Shellter for the advice. I will remember this for in future. It would be good if the question goes to superuser... – Stat-R Mar 23 '12 at 13:38
  • This is actually on topic here. But since OP asked for migration... – user939 Mar 23 '12 at 16:22

I used the NPPExec plugin (Link to NppExec) in Notepad++. I used the following command to:

  • Take the current sweave(say test.rnw) file and run knitr2pdf on it. It would generate test.tex (One need's to change path to Rscript.exe accordingly)

    cmd /c cd /d "$(CURRENT_DIRECTORY)" &&  "C:/.../bin/Rscript.exe" -e "knitr::knit2pdf('"$(NAME_PART).rnw"')
  • Run pdflatex to test.tex. It would generate test.pdf

    pdflatex.exe -shell-escape "$$(NAME_PART).tex"
  • Open test.pdf in a pdfview that updates the PDF file when the new one is generated

    npp_run "C:\Users\...\SumatraPDF\SumatraPDF.exe" "$(CURRENT_DIRECTORY)\$(NAME_PART).pdf"

We need to hit F6 and a window opens up. We can put the following command chunk there and save it. Rest is self explanatory.

cmd /c cd /d "$(CURRENT_DIRECTORY)" &&  "C:/.../bin/Rscript.exe" -e "knitr::knit2pdf('"$(NAME_PART).rnw"') pdflatex.exe -shell-escape "$$(NAME_PART).tex" npp_run "C:\Users\...\SumatraPDF\SumatraPDF.exe" "$(CURRENT_DIRECTORY)\$(NAME_PART).pdf"

References: NppExec plugin manual and NppExec plugin Help

  • Please check if the formatting is okay now. Breaking up command lines is problematic since you can't copy them anymore. – slhck Mar 24 '12 at 16:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.