[Rd] Problem with texi2pdf(..,clean=TRUE)

Marc Schwartz marc_schwartz at me.com
Fri Aug 30 21:40:30 CEST 2013

On Aug 30, 2013, at 2:20 PM, Henrik Bengtsson <hb at biostat.ucsf.edu> wrote:

> On Fri, Aug 30, 2013 at 12:14 PM, Duncan Murdoch
> <murdoch.duncan at gmail.com> wrote:
>> On 30/08/2013 3:09 PM, Marc Schwartz wrote:
>>> On Aug 30, 2013, at 2:00 PM, cstrato <cstrato at aon.at> wrote:
>>>> Dear all,
>>>> To create a *.pdf file from a *.Rnw file I do:
>>>>     olddir <- getwd();
>>>>     setwd(outdir);
>>>>     tryCatch({Sweave("QAReport.Rnw");
>>>>               tools::texi2pdf("QAReport.tex", clean=TRUE)
>>>>              },
>>>>              finally = setwd(olddir)
>>>>             );
>>>> This works fine, however 'clean=TRUE' does only work when:
>>>>    outdir <- "Test/inst/doc/"
>>>> but does not remove the files *.aux, *.log, *.toc when:
>>>>    outdir <- "Test/"
>>>> Why does function texi2pdf() require the directory structure for
>>>> vignettes for the deletion of interim files?
>>>> (The help file?texi2pdf does not mention that this structure is
>>>> necessary.)
>>>> Best regards
>>>> Christian
>>> In the Details section of ?texi2pdf, there is:
>>> "Despite the name, this is used in R to compile LaTeX files, specifically
>>> those generated from vignettes."
>>> Since it is intended specifically for package vignettes, the path
>>> requirement should not be a surprise. :-)
>> There is no path requirement.  Christian was incorrect in his diagnosis.
>> texi2pdf won't delete files that existed before it was run, whether or not
>> they were changed during the run.  That's likely what Christian was seeing.
> Or, that the cleanup fails if the compilation is too quick, cf.
> PR#15394 'texi2dvi(..., clean=TRUE) sometimes too quick for "clean"
> (with PATCH)' submitted on July 17, 2013:
>  https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=15394
> /Henrik


It is late on a Friday, so perhaps I am short on functioning neurons.

If the intent of 'clean = TRUE' is to remove the byproducts of compiling the .PDF file from the source .TEX file, why not just delete the resultant aux|log|tex|dvi files that match the basename of the source .TEX file rather than being dependent upon the time stamp? 

Is there a reason that I am failing to consider for a need to retain these files if older than the current time stamp? Perhaps if the compilation requires multiple cycles of latex processing (eg. the use of longtables, etc.), in which case, one could run texi2pdf(..., clean = FALSE) some number of times, then a final texi2pdf(..., clean = TRUE) when done. I actually have my own shell script that does this when creating Sweave files.

Of course, the help file does have the following for the 'clean' argument: ...May not work on some platforms.



More information about the R-devel mailing list