Learn R Programming

xdvir (version 0.1-2)

grid.latex: Render LaTeX in R

Description

Author, typeset, and render LaTeX in R graphics.

Usage

latexGrob(tex,
          x=0.5, y=0.5,
          margin=0, rot=0,
          default.units="npc",
          hjust="centre", vjust="centre",
          width=NA,
          dpi=NA,
          page=1,
          packages=NULL,
          engine=getOption("xdvir.engine"),
          fontLib=getOption("xdvir.fontLib"),
          texFile=NULL,
          name=NULL,
          gp=gpar(),
          vp=NULL) 
grid.latex(...)

xelatexGrob(tex, ...) grid.xelatex(...)

lualatexGrob(tex, ...) grid.lualatex(...)

Value

A "DVIgrob" object.

Arguments

tex

LaTeX code as a character vector.

x, y

Numeric values or units specifying where to draw the output.

margin

Numeric values or units specifying margins (in the order bottom, left, top, right). Recycled if necessary.

rot

Rotation angle (in degrees).

default.units

Units to use if x or y are numeric.

hjust, vjust

Justification of the output relative to the x/y location.

width

Either NA or a numeric value or a unit specifying the width for typesetting. NA means the natural width of tex.

dpi

Resolution (dots per inch) for rendering.

page

Which page should be drawn.

packages

The LaTeX packages to be used. May be the name of a LaTeX package (character) or a "LaTeXpackage" object.

engine

The TeX engine that should be used to render the LaTeX. May be the name of a TeX engine (character) or a "TeXengine" object.

fontLib

The font libraary the should be used to query fonts and glyphs.

name

Character value giving name for the grob.

gp

Graphical parameter settings.

vp

A viewport or NULL.

texFile

Name of a file to use for LaTeX code.

...

Arguments passed to dviGrob.

Author

Paul Murrell

Details

grid.latex() takes a LaTeX fragment, generates a LaTeX document, typesets it, reads the resulting DVI file and renders the result.

grid.xelatex() is just a convenient front end for grid.latex(), with appropriate default engine.

grid.latex() attempts to be smart about delaying typesetting until drawing time if necessary in order to get the correct context for width and gp settings. This means that, unless gp is set to NULL and width is set to either NA or an absolute unit (e.g., a number of inches), the calculation of, for example, the width of a grob will be less efficient because the typesetting has to be performed all over again.

See Also

LaTeXpackage.

Examples

Run this code
if (FALSE) {
# Requires TeX installation
grid.latex("this is a test")
}

Run the code above in your browser using DataLab