There is a great piece on Yihui's site about using knitr with TeXShop. Taking some time for some self indulgent curiosity here. Is there a way to use knitr as an engine in TeXworks?


1 Answer 1


You can add knitr as additional engine into TeXworks similar as already shown on the linked demo page for Texmaker (note: I do not know knitr at all and also I’m not a regular user of TeXworks, so some mistakes are possible):

Edit: Yihui added instructions for TeXworks to the already mentioned page Editors for knitr.

  • Open the “Preferences” window (can be found in the “Edit” menu) and go to the “Typesetting” tab.

    (For next steps see image below.)

  • Then (step 1 one the image) add a new Processing Tool. In the new window give it a name (step 2) and add the executable file (step 3). Last add the needed arguments (step 4); you can add more than one by repeated pressing the plus sign. I also marked the TeXworks variable $basename, there exists a $fullname as well. Press OK.

    Edit: And I made a mistake: The arguments must be splitted into two – first argument -e, second knitr::knit2pdf('$basename.$suffix') (this second changed according to Yihui).

    Preferences for knitr in TeXworks

Then you can choose this processing tool in the main window from the menu “Typeset” or from the toolbar popdown:

TeXworks toolbar, choose processing tool

  • I just added the link to this answer in yihui.name/knitr/demo/editors; for some reason I had to put -e and "knitr::knit2pdf(...)" in two lines under Ubuntu in the arguments; not sure if it has to be the case under Windows as well.
    – Yihui Xie
    Dec 2, 2012 at 6:55
  • @Yihui: I think, you are right! As I wrote in the beginning: “… some mistakes are possible”.
    – Speravir
    Dec 2, 2012 at 18:44
  • @Yihui BTW: TeXStudio as Texmaker fork should be almost the same, and TeXnicCenter is also very similar!
    – Speravir
    Dec 2, 2012 at 19:04
  • @Speravir Thanks! I'll try to test TeXnicCenter some day.
    – Yihui Xie
    Dec 3, 2012 at 7:12
  • @Yihui: But don’t forget, it’s a Windows program. I don’t know, whether it runs in wine.
    – Speravir
    Dec 3, 2012 at 21:17

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.