R: Compile LaTeX Files

texi2dvi {tools} | R Documentation

## Compile LaTeX Files

### Description

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

### Usage

    texi2dvi(file, pdf = FALSE, clean = FALSE, quiet = TRUE,
             texi2dvi = getOption("texi2dvi"),
             texinputs = NULL, index = TRUE)

    texi2pdf(file, clean = FALSE, quiet = TRUE,
             texi2dvi = getOption("texi2dvi"),
             texinputs = NULL, index = TRUE)

### Arguments

`file` | character. Name of LaTeX source file.
`pdf` | logical. If `TRUE`, a PDF file is produced instead of the default dvi file (`texi2dvi` command line option --pdf).
`clean` | logical. If `TRUE`, all auxiliary files are removed (`texi2dvi` command line option --clean). May not work on some platforms.
`quiet` | logical. No output unless an error occurs. Ignored if emulation (see the `texi2dvi` argument) is used.
`texi2dvi` | character (or `NULL`). Script or program used to compile a TeX file to dvi or PDF, respectively. The default (selected by `""` or `NULL`) is to look for an executable on the search path and otherwise emulate the script with `system` calls.
`texinputs` | `NULL` or a character vector of paths to add to the LaTeX and bibtex input search paths.
`index` | logical: should indices be prepared?

### Details

`texi2pdf` is a wrapper for the common case of `texi2dvi(pdf = TRUE)`.

Despite the name, this is used in R to compile LaTeX files, specifically those generated from vignettes. It ensures that the ‘R_HOME/share/texmf’ directory is in the TEXINPUTS path, so R style files such as ‘Sweave’ and ‘Rd’ will be found. The search path used is first the existing TEXINPUTS setting (or the current directory if unset), then elements of `texinputs`, then ‘R_HOME/share/texmf’ and finally the default path. Analogous changes are made to BIBINPUTS and BSTINPUTS settings.

MiKTeX has a `texi2dvi` executable but no other Windows TeX installation that we know of does, so emulation is used on e.g. TeXLive installations on Windows.

Occasionally indices contain special characters which cause indexing to fail (particularly when using the hyperref LaTeX package) even on valid input. The argument `index = FALSE` is provided to allow package manuals to be made when this happens: it uses emulation.

### Value

Invisible `NULL`. Used for the side effect of creating a dvi or PDF file in the current working directory (and maybe other files, especially if `clean = FALSE`).

### Note

There are various versions of the `texi2dvi` script on Unix-alikes and quite a number of bugs have been seen, some of which this R wrapper works around.

One that is current is that it may not work correctly for paths which contain spaces, nor even if the absolute path to a file would contain spaces.

The three possible approaches all have their quirks. For example the Unix-alike `texi2dvi` script removes ancillary files that already exist but the other two approaches do not (and may get confused by such files).

### Author(s)

Originally Achim Zeileis but largely rewritten by R-core.

[Package tools version 2.15.1 Index]