Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.
share|improve this question

migrated from Mar 23 '12 at 16:22

This question came from our site for professional and enthusiast programmers.

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... – Will Mar 23 '12 at 16:22
up vote 1 down vote accepted

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

share|improve this answer
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
Thank you @ slhck. – Stat-R Mar 24 '12 at 19:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .