[Rd] Problems building package vignette: Sweave requires multiple passes to build document.

Duncan Murdoch murdoch.duncan at gmail.com
Fri Mar 14 17:41:31 CET 2014

On 14/03/2014 12:28 PM, Skye Bender-deMoll wrote:
> Dear R-devel,
> Question:
>       How can I get Sweave to recognize that the \thebibliography section
> is already created and generate the vignette pdf with a single pass? Or
> is there a way to let R CMD build know that Sweave needs to be run twice?

I think the problem isn't Sweave:  it ignores LaTeX code.  The problem 
is the following step that converts the .tex output into a .pdf, which 
is handled by tools::texi2pdf (which runs tools::texi2dvi).  That 
function makes an effort to determine how many LaTeX passes are 
required, but it appears you are fooling it somehow.

Take a look at the source to tools::texi2dvi, and see if you can spot 
what's going wrong in your case.  There are a number of different paths 
through that code that depend on your particular setup, so we can't do 
that.  If you don't succeed in this, then post a simplified sample 
package and someone else will be able to see if they have the same 
problem as you, and perhaps fix it.

Duncan Murdoch

>       If (1) is not possible, any suggestions how to auto-generate a
> crude generic bibtex .bib file from my existing document?
> Background:
> I maintain serveral R packages that include package vignettes. The
> vignettes include the reference citations inline as\bibitem lines inside
> a thebiblilography section. For some reason, this requires running
> Sweave twice on the document (the first pass is presumably preformatting
> the citation information?) to produce a pdf. This seems to be the source
> of problems when included in R's preferred vignette location
> (/vignettes/myPackage.Rnw) because the R package builder just runs
> Sweave once during the check process, so no pdf is produced and warnings
> are generated like
> checking package vignettes in ‘inst/doc’ ... WARNING
>    Package vignette without corresponding PDF/HTML
> In the past, it has been possible for me to pre-build the pdf, and
> include it in the /inst/doc/ directory. But it seems the upcoming
> versions of R may prohibit this.
> It appears that it is possible to avoid all this by including a bibtex
> .bib file along with the vignette instead of doing the citations inline.
> If the .bib files exists, it seems to generate with a single pass. But
> reformatting all of the citations for each document into bibtex will be
> a huge pain. Including a blank \bibliography{} command above my
> \thebibliography environment also allows the document to be build in a
> single pass, but generates a warning about duplicate biliography and
> writes the section header twice (not surprisingly).
> Note: I've cross-posted this question at:
> http://stackoverflow.com/questions/22237675/how-to-get-sweave-to-recognize-thebibliography-environment-and-build-r-package
> thanks for your help,
>    best,
>    -skye
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

More information about the R-devel mailing list