expr2latex: Translate 'plotmath' expressions to LaTeX

View source: R/expr2latex.R

expr2latexR Documentation

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 R object of class expression or language, typically as from quote(...).

x

a character vector.

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 R itself. (Hidden in simsalpar's namespace, we have AccentTable, BinTable, RelTable, Lgreek and Ugreek, currently.)

The current implementation is still incomplete.

Value

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

Author(s)

Martin Maechler.

See Also

plotmath for mathematical expressions to annotate R graphics.

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

Examples

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"))

simsalapar documentation built on April 27, 2023, 9:05 a.m.