as_latex.spar: Convert One Spork to Latex

View source: R/latex.R

as_latex.sparR Documentation

Convert One Spork to Latex

Description

Converts one spork to latex. See description for as_spork. By default, unrecognized tokens are returned literally. However, Greek symbols and latex metacharacters are escaped. See latexToken.

Usage

## S3 method for class 'spar'
as_latex(
  x,
  newline = getOption("latex_newline", "\n"),
  unrecognized = getOption("latex_unrecognized", "latexToken"),
  token_open = getOption("latex_token_open", "\\textrm{"),
  token_close = getOption("latex_token_close", "}"),
  math_open = getOption("latex_math_open", "\\mathrm{"),
  math_close = getOption("latex_math_close", "}"),
  label_open = getOption("latex_label_open", "$"),
  label_close = getOption("latex_label_close", "$"),
  enforce_math = getOption("latex_enforce_math", TRUE),
  ...
)

Arguments

x

spar

newline

value to replace '\n'

unrecognized

function to process unrecognized tokens: default latexToken

token_open, token_close

these wrap text-like portions of the label; the defaults try to give upright characters (non-italic); also passed to latexToken

math_open, math_close

these wrap math-like portions of the label; the defaults try to give upright characters (non-italic) which may not work for Greek symbols; also passed to latexToken

label_open, label_close

these wrap the entire label; defaults invoke traditional math mode

enforce_math

whether to enforce math mode for nested expression: latexToken

...

passed to unrecognized; see latexToken

Details

Experimental support is implemented for the newline character ('\n'). Default behavior is to introduce literal newline characters into the resulting tex. This may have no effect on the typeset result. It may be possible to achieve other effects by using non-default values of helper arguments and perhaps additional latex packages.

Value

latex

See Also

Other interface: as.expression.plotmath(), as_html.spar(), as_html.spork(), as_latex.default(), as_latex.spork(), as_plotmath.spar(), as_plotmath.spork(), as_previews.spork(), as_spork.character(), htmlToken(), latexToken(), plotmathToken()

Other latex: [.latex(), [[.latex(), as_latex.default(), as_latex.spork(), as_latex(), concatenate.latex(), latexToken()

Examples

library(magrittr)
'V_c./F' %>% as_spork %>% as_latex
'AUC_ss' %>% as_spork %>% as_latex
'C_max_ss' %>% as_spork %>% as_latex
'var^eta_j' %>% as_spork %>% as_latex
'& % $ # \\_ { } ~ \\^ \\' %>% as_spork %>% as_latex
'one joule (Omega) ~ 1 kg*m^2./s^2' %>% as_spork %>% as_latex

spork documentation built on Sept. 16, 2023, 9:06 a.m.

Related to as_latex.spar in spork...