[R] Run Sweave and LaTeX directly from command line

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Feb 23 10:43:43 CET 2005


On Tue, 22 Feb 2005, Gorjanc Gregor wrote:

> Friedrich,
>
> This texi2dvi is also very nice. Dou you know of any pros and cons
> in comparison to rubber?

texi2dvi is pretty standard, part of the texinfo distribution.  rubber is 
not in the standard Linux distros, and uses python, also not very 
standard, especially on Windows.

> Is tex2dvi also shipped with R for windows? I am not able to find
> a binnary in my windows installation, however I found help page.
> Did I missed anything? I have 2.0.1

I believe Fritz was referring to the script src/script/texi2dvi.  That is 
far too slow on Windows even if you have the tools installed as it runs ca 
2000 processes per invocation.

R has a function texi2dvi in package tools that avoids this on Windows. 
Let me repost (from a thread on R-devel about automating Sweave scripts on 
Windows).

% cat Rnw.bat
rterm --no-save --args "%1" < /tmp/MakeSweave.R > "%1.log"

% cat /tmp/MakeSweave.R
library(tools)
args <- commandArgs()
inp <- args[length(args)]
Sweave(inp)
base <- sub("\.(Rnw|Rtex)$", "", inp)
texi2dvi(paste("base", ".tex", sep=""), pdf=TRUE)
shell.exec(paste("base", ".pdf", sep="")) # display PDF file on Windows.

which shows how easy this is to script in R in a cross-platform way

>
>>>>>> On Tue, 22 Feb 2005 14:29:00 +0100,
>>>>>> Gregor GORJANC (GG) wrote:
>
>  > Hello!
>  > Those of you, who use Sweave a lot, will probably find my shell script
>  > usable. You can get it at:
>
>  > http://www.bfro.uni-lj.si/MR/ggorjan/programs/shell/Sweave.sh
>
>  > No warranty, however don't hesitate to contact me if you find an error or
>  > have a patch!
>
> Very nice!
>
> Side note 1: R ships a version of texi2dvi, hence you might use that
> one in case rubber is not found.
>
> side note 2: For make afficionados the follwing 2 rules in combination
> with the Sweave script from the FAQ do almost the same (that's what I
> use :-)
>
> %.tex: %.Rnw
>        Sweave $<
>
> %.pdf : %.tex
>        texi2dvi --clean --pdf $<
>
>
> Best,
> Fritz Leisch
>
> -- 
> -------------------------------------------------------------------
>                        Friedrich Leisch
> Institut für Statistik                     Tel: (+43 1) 58801 10715
> Technische Universität Wien                Fax: (+43 1) 58801 10798
> Wiedner Hauptstraße 8-10/1071
> A-1040 Wien, Austria             http://www.ci.tuwien.ac.at/~leisch
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


More information about the R-help mailing list