Get dimensions of a LaTeX expression
Arguments
- tex
Character string of LaTeX math code.
- math_font
Name of the math font to use (e.g.,
"stix"). Use""(default) for Lete Sans Math, which pairs with R's default sans-serif text font. Seeavailable_math_fontsfor loaded fonts.- max_width
Numeric maximum width in big points for automatic line wrapping. Use
0(default) for no wrapping.- tex_style
Character: TeX style override. One of
""(default; let the parser decide),"display","text","script", or"scriptscript". Seelatex_grobfor the semantics of each value.- input_mode
How
texis interpreted before being parsed."mixed"wraps the input in\text{...}so the string reads as ordinary text and$...$(or\(...\)) opens math mode, matching document-level LaTeX semantics. Useful for labels that arrive from external sources mixing prose and math without explicit\text{}markers."math"(default) is the standard MicroTeX behaviour — the whole string is treated as math, so unwrapped prose renders as spaced math italics. The default can be changed globally vialatex_options(input_mode = "mixed"). Seelatex_wrapfor details on the wrapping process.- render_mode
Character string:
"typeface"(default) renders glyphs as native text using the math font, producing selectable/accessible text in PDF and SVG output. Bundled math fonts and any registered viaload_fontare read directly from their OTF files — no system-wide font install is required. Falls back to path mode automatically on devices that lack the R \(\geq\) 4.3 glyph engine (e.g., the basepdf()device). For selectable PDF output, prefercairo_pdf."path"renders math symbols as filled vector paths (works on all devices but text is not selectable in PDF/SVG).- gp
Graphical parameters (see
gpar). Common entries:col(formula foreground),fontfamily/fontface(text font),fontsize/cex(formula size), andlineheight(multi-line spacing). Seelatex_grobfor how each of these flows through MicroTeX.
Value
A list with the following elements:
width,height,depth: grid unit objects in big points.heightis total height (ascent + descent).baseline: grid unit object giving the baseline position measured in big points from the bottom of the bounding box. Equivalent toheight - depthfor single-line formulas. Useful for aligning a formula's baseline with surrounding text.is_split: logical;TRUEif the formula was wrapped across multiple lines (only possible whenmax_width > 0).