Returns the raw draw-record table produced by MicroTeX's layout pass together with the bounding-box metadata. Useful for debugging alignment issues, building custom grobs on top of the layout, or counting glyphs/paths/rules in a formula.
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.- render_mode
Character string:
"typeface"(default) renders glyphs as native text using the math font, producing selectable/accessible text in PDF and SVG output. Requires the math font to be installed on the system. Falls back to path mode automatically on devices that do not support font embedding (e.g., the basepdf()device)."path"renders math symbols as filled vector paths (works on all devices but text is not selectable in PDF/SVG). For PDF output with embedded/selectable text, prefercairo_pdf.- 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 class "latex_tree" containing:
recordsData frame of draw records (one row per glyph, path, line, rect, or text block). Columns include
type,x,y,glyph,font_size,color,text,codepoint,font_file.bboxNamed numeric vector with
width,height,depth,baseline(all in big points).texThe (macro-expanded) input string.
render_modeRendering mode used for the layout.
Examples
# \donttest{
tree <- latex_tree("\\frac{a}{b}")
print(tree)
#> <latex_tree>
#> tex: \frac{a}{b}
#> render_mode: typeface
#> bbox: width=7.00 height=25.00 depth=9.00 baseline=0.63 (bigpts)
#> records: 3
#> glyph 2
#> line 1
head(tree$records)
#> type x y glyph font_size color x2 y2 width height rx ry
#> 1 glyph 0.175 7.224 2701 14 #000000 NA NA NA NA NA NA
#> 2 line 0.000 10.624 NA NA #000000 7.392 10.624 NA NA NA NA
#> 3 glyph 0.000 25.824 2702 14 #000000 NA NA NA NA NA NA
#> lwd text font_style path codepoint
#> 1 NA <NA> NA NULL NA
#> 2 1.32 <NA> NA NULL NA
#> 3 NA <NA> NA NULL NA
#> font_file
#> 1 /home/runner/work/_temp/Library/gridmicrotex/fonts/LeteSansMath.otf
#> 2 <NA>
#> 3 /home/runner/work/_temp/Library/gridmicrotex/fonts/LeteSansMath.otf
# }