RweaveLatex {utils}R Documentation

R/LaTeX Driver for Sweave

Description

A driver for Sweave that translates R code chunks in LaTeX files.

Usage

RweaveLatex()

RweaveLatexSetup(file, syntax, output = NULL, quiet = FALSE,
                 debug = FALSE, stylepath, ...)

Arguments

file Name of Sweave source file.
syntax An object of class SweaveSyntax.
output Name of output file, default is to remove extension ‘.nw’, ‘.Rnw’ or ‘.Snw’ and to add extension ‘.tex’. Any directory names in file are also removed such that the output is created in the current working directory.
quiet If TRUE all progress messages are suppressed.
debug If TRUE, input and output of all code chunks is copied to the console.
stylepath See ‘Details’.
... named values for the options listed in ‘Supported Options’.

Details

The LaTeX file generated needs to contain \usepackage{Sweave}, and if this is not present in the Sweave source file, it is inserted by the RweaveLatex driver. If stylepath = TRUE, a hard-coded path to the file ‘Sweave.sty’ in the R installation is set in place of Sweave. The hard-coded path makes the TeX file less portable, but avoids the problem of installing the current version of ‘Sweave.sty’ to some place in your TeX input path. However, TeX may not be able to process the hard-coded path if it contains spaces (as it often will under Windows) or TeX special characters.

The default in R prior to 2.7.0 was stylepath = TRUE. It is now taken from the environment variable SWEAVE_STYLEPATH_DEFAULT, or is FALSE it that is unset or empty. If set, it should be exactly TRUE or FALSE: any other values are taken as FALSE.

By default, ‘Sweave.sty’ sets the width of all included graphics to:
\setkeys{Gin}{width=0.8\textwidth}.

This setting affects the width size option passed to the \includegraphics{} directive for each plot file and in turn impacts the scaling of your plot files as they will appear in your final document.

Thus, for example, you may set width=3 in your figure chunk and the runtime generated EPS and PDF files will be set to 3 inches in width. However, the width of your graphic in your final document, will be set to 0.8\textwidth and the height dimension will be scaled accordingly. Fonts and symbols will be similarly scaled in the final document.

You can adjust the default value by including the \setkeys{Gin}{width=...} directive in your ‘.Rnw’ file after the \begin{document} directive and changing the width option value as you prefer, using standard LaTeX measurement values.

If you wish to override this default behavior entirely, you can add a \usepackage[nogin]{Sweave} directive in your preamble. In this case, no size/scaling options will be passed to the \includegraphics{} directive and the height and width options will determine both the runtime generated graphic file sizes and the size of the graphics in your final document.

Sweave.sty’ also supports the [noae] option, which suppresses the use of the ae package, the use of which may interfere with certain encoding and typeface selections. If you have problems in the rendering of certain character sets, try this option.

The use of fancy quotes (see sQuote) can cause problems when setting R output. Either set options(useFancyQuotes = FALSE) or arrange that LaTeX is aware of the encoding used (by a \usepackage[utf8]{inputenc} declaration: Windows users will need to replace utf8 by cp1252 or similar) and ensure that typewriter fonts containing directional quotes are used.

Supported Options

RweaveLatex supports the following options for code chunks (the values in parentheses show the default values):

echo:
logical (TRUE). Include S code in the output file?
keep.source:
logical (FALSE). When echoing, if keep.source == TRUE the original source is copied to the file. Otherwise, deparsed source is echoed.
eval:
logical (TRUE). If FALSE, the code chunk is not evaluated, and hence no text or graphical output produced.
results:
character string (verbatim). If verbatim, the output of S commands is included in the verbatim-like Soutput environment. If tex, the output is taken to be already proper latex markup and included as is. If hide then all output is completely suppressed (but the code executed during the weave).
print:
logical (FALSE). If TRUE, each expression in the code chunk is wrapped into a print() statement before evaluation, such that the values of all expressions become visible.
term:
logical (TRUE). If TRUE, visibility of values emulates an interactive R session: values of assignments are not printed, values of single objects are printed. If FALSE, output comes only from explicit print or cat statements.
split:
logical (FALSE). If TRUE, text output is written to separate files for each code chunk.
strip.white:
character string (false). If true, blank lines at the beginning and end of output are removed. If all, then all blank lines are removed from the output.
prefix:
logical (TRUE). If TRUE generated filenames of figures and output have a common prefix.
prefix.string:
a character string, default is the name of the ‘.Snw’ source file.
include:
logical (TRUE), indicating whether input statements for text output and includegraphics statements for figures should be auto-generated. Use include = FALSE if the output should appear in a different place than the code chunk (by placing the input line manually).
fig:
logical (FALSE), indicating whether the code chunk produces graphical output. Note that only one figure per code chunk can be processed this way.
eps:
logical (TRUE), indicating whether EPS figures should be generated. Ignored if fig = FALSE.
pdf:
logical (TRUE), indicating whether PDF figures should be generated. Ignored if fig = FALSE.
pdf.version, pdf.encoding:
passed to pdf to set the version and encoding. Defaults taken from pdf.options().
width:
numeric (6), width of figures in inches. See ‘Details’.
height:
numeric (6), height of figures in inches. See ‘Details’.
expand:
logical (TRUE). Expand references to other chunks so that only R code appears in the output file. If FALSE, the chunk reference (e.g. <<chunkname>>) will appear. The expand=FALSE option requires keep.source = TRUE or it will have no effect.
concordance:
logical (FALSE). Write a concordance file to link the input line numbers to the output line numbers. This is an experimental feature; see the source code for the output format, which is subject to change in future releases.

Author(s)

Friedrich Leisch

References

Friedrich Leisch: Sweave User Manual, 2008
http://www.stat.uni-muenchen.de/~leisch/Sweave

See Also

Sweave, Rtangle


[Package utils version 2.11.0 Index]