Learn R Programming

simsalapar (version 1.0-2)

expr2latex: Translate 'plotmath' expressions to LaTeX

Description

expr2latex() translates a R graphics annotation expression to the corresponding LaTeX one.

escapeLatex(), very similar to its original, escape_latex() from fortunes, escapes certain character combinations, such that the result can be used in LaTeX.

Usage

expr2latex(expr)
escapeLatex(x)

Arguments

expr
an Robject of class expression or language, typically as from quote(...).
x
a character vector.

Value

  • a character string with the LaTeX expression corresponding to R graphics annotation expression expr.

Details

The expr2latex() function is recursively rendering (sub) expressions, until it uses the internal renderAtom() for simple symbols (is.symbol).

We currently work with some tables of math annotation expressions, lifted from the corresponding C source of Ritself. (Hidden in simsalpar's namespace, we have AccentTable, BinTable, RelTable, Lgreek and Ugreek, currently.)

The current implementation is still incomplete.

See Also

plotmath for mathematical expressions to annotate Rgraphics.

toLatex() and its ftable method, toLatex().

Examples

Run this code
expr2latex( quote( N[sim] ) )
expr2latex( quote( N[sim] ~ O(n) ) )
expr2latex( quote(x %notin% N) )
expr2latex( quote(x %+-% epsilon) )
expr2latex( quote(N[s*m^2]) )
expr2latex( quote( 2^{N[sim] - 3} ~~~ O(n^{n^2}) ) )

escapeLatex(c("#{positives}", "A | B"))

Run the code above in your browser using DataLab