1. David Lovell

    Many thanks Tom for this excellent public service announcement! I’ve just figured I need to move from Rmarkdown to Sweave to make some well-formatted Supplementary Materials. Your post has helped immensely.

  2. Simon Kiss

    Hi this looks really great, but is there *any* way to hack this to make it run Biber? I’ve got a style file that only uses biber

  3. maja

    Hi! Thanks for this, really helpful! I’m having trouble though trying to get it to work with natbib. If I understood you correctly I should be able to simply do


    instead of

    \usepackage[backend=bibtex, sorting=none]{biblatex}

    but this is giving me errors? Any help would be greatly appreciated!

    • tom

      Hi Maja,

      You’ll have to change a couple of more lines, because BibTeX uses a different set of macros to generate the bibliography.

       % replace these lines
      % by these (where the bibliography should be printed)

      Also, I couldn’t get RStudio to automatically generate the bibliography, but had to go to the terminal and type: bibtex xyz, pdflatex xyz, pdflatex xzy (with xyz being the tex filename).

      HTH, Tom

      • maja

        Thanks Tom! Not sure what happened, I was having problems yesterday with the second bit like you, but now it seems to work i.e. directly from RStudio (tjhat is using filecontents to create the file)!?
        Anyway, sees to be working fine, thanks for your quick reply and great blog!

    • tom

      Hi Joyce,

      Thanks for your comment. I assume you’re question is about using biber with RStudio. Essentially, it appears that this is still not possible by default. What you can do:
      – Manually generate the output from the tex-file using pdflatex and biber.
      – Configure RStudio to use latexmk as described here.

      Hope this helps,

      • Joyce

        Hi, Thanks a lot. I don’t need to use biber. For reproducibility purposes I was hoping for something though that didn’t need setwd.

        Once again, thanks for posting this. I tried a number of options and this one is the only one that worked for me.

      • tom

        Hi Joyce,

        Right, the setwd() should not have been in there in the first place. Sorry for that!

        Best, Tom

  4. I’m trying to compile a .Rnw using sweave and I would like to add a .bib file. When I add this


    And it compile it compiles without error but no references section is included. Then I tried adding per your advice:


    I added this to the part of my code before the document begins (i tried else where as well) but regardless of where I place that script a litany of errors is produced

    • tom

      I ran this from RStudio using knitr and it worked fine. I’m not sure the code is compatible with Sweave though.

      Best, Tom.

Leave a Reply to tom Cancel reply