What exactly does R CMD Sweave

I noticed this in the changes of R 2.14:

R CMD Sweave now has a --pdf option to produce a PDF version of the processed Sweave document.

Trying it out, I noticed that it not only ran pdfLaTeX on the resulting tex but also correctly included bibTeX references and cleaned up afterwards. Seems like a very very nice way of using Sweave now (not to mention how easy it now is to implement the whole routine in editors).

But what exactly is this now running? I couldn't find any more details on it. It seems Sweave -> pdflatex -> bibtex -> pdflatex -> pdflatex at least?


Thanks for the question. I had wondered myself about the code behind that 'automagical' process.

R CMD Sweave --pdf ultimately calls tools::texi2dvi , which:

Run[s] latex and bibtex until all cross-references are resolved and create[s] either a dvi or PDF file.

(See here for more texi2dvi details).

Here is the chain of events set into motion by an R CMD Sweave --pdf call:

  • The source file rcmdfn.c has code that instructs R CMD Sweave to run utils:::.Sweave() --args" through Rterm.exe .

  • If --pdf is set, utils:::.Sweave() calls tools::texi2pdf() to process the Sweave file.

  • texi2pdf() in turn calls tools::texi2dvi() .

  • Finally, texi2dvi() looks at the environment to learn which tools are available to it, and does the work described in the help file linked above.


  • 您可以尝试手动执行从Rnw到pdf的转换,查看需要多少次才能获得与R CMD Sweave相同的结果。


    我对内饰工作知之甚少,但我知道RStudio的开发版本可以让您在knitrSweave之间以及在pdflatexxelatex之间进行选择,并且可以选择bibtex

    链接地址: http://www.djcxy.com/p/26910.html

    上一篇: Makeave与Sweave的依赖关系

    下一篇: R CMD Sweave究竟是什么?