latex_options: Set or query package-wide LaTeX rendering defaults

View source: R/options.R

latex_optionsR Documentation

Set or query package-wide LaTeX rendering defaults

Description

A single entry point for project-wide defaults used by latex_grob, grid.latex, latex_dims, and latex_tree. Options set here are applied only when the corresponding argument is not supplied at the call site, so explicit arguments always win.

Usage

latex_options(
  math_font = NULL,
  render_mode = NULL,
  tex_style = NULL,
  input_mode = NULL
)

reset_latex_options()

Arguments

math_font

Math font name or alias (see available_math_fonts).

render_mode

Either "typeface" or "path".

tex_style

TeX style override. One of "" (let the parser decide), "display", "text", "script", or "scriptscript". "display" forces large operators with limits placed over/under, useful for inline labels that should still look like display equations.

input_mode

How the input string is interpreted before being handed to MicroTeX. "math" (default) treats the whole string as math — the standard MicroTeX behaviour, where letters render as math italics and unwrapped prose looks wrong. "mixed" wraps the string in \text{...} so it reads as ordinary text, with $...$ (and \(...\)) opening math mode — the document-level LaTeX convention. Useful when consuming labels from other packages that mix prose and math without explicit \text{} markers.

Details

Calling latex_options() with no arguments returns the current settings (a list whose NULL entries mean "use the built-in default"). Supply one or more named arguments to update them.

Font size and line spacing are controlled via gp parameters (fontsize, cex, lineheight) at the grob level — see latex_grob.

Value

Invisibly returns the previous settings (a list). With no arguments, returns the current settings visibly.

See Also

available_math_fonts, latex_grob

Examples


  latex_options(math_font = "stix", render_mode = "typeface")
  grid.latex("\\sum_{i=1}^{n} i^{2}", gp = grid::gpar(fontsize = 14))
  reset_latex_options()


gridmicrotex documentation built on May 16, 2026, 5:06 p.m.