Stack Term Names over Mathematical Formulae
Source:R/table_styles.R
with_style_name_over_formula.RdReorganizes a tabulergm_table() result into a compact presentation layout.
The Name column contains the curated term title (or the canonical term
name when no title is available) followed by its formula; Representation
contains the term figure. Model statistics and metadata columns explicitly
included in the source table are retained after those two presentation
columns.
Arguments
- x
A data frame or
knitr_kableobject returned bytabulergm_table()or one of thewith_style_*()helpers.- column_widths
Optional named numeric vector of table-width fractions keyed by displayed compact-table column names (for example,
c(Name = .5, Representation = .2)). Values must be in(0, 1]and total no more than one.NULLuses automatic column widths.- figure_height
Optional positive numeric height, in inches, for term figures.
NULLretains the default width-based figure sizing.
Value
An object in the same requested output format as x; Markdown
requests return HTML table markup suitable for HTML-capable Markdown
renderers.
Details
HTML output uses a responsive HTML table. Markdown requests also use HTML,
because pipe tables cannot reliably represent the multi-line cells needed
by this style. Width and figure-height settings are stored on the returned
table object, so they also apply to previews and saved output. The saved
LaTeX snippet requires the array, booktabs, and graphicx packages.
Examples
tabulergm_table(~ edges + triangle, include_description = FALSE) |>
with_style_name_over_formula(
column_widths = c(Name = .5, Representation = .2),
figure_height = .8
)
#> Name
#> 1 Number of edges (holland1981)\n\\sum_{i<j} y_{ij}
#> 2 Triangles (frank1986)\n\\sum_{i<j<k} y_{ij} y_{jk} y_{ik}
#> Representation
#> 1 /tmp/RtmpRs97L3/tabulergm-4ec940654adcc485b27f39ca7dd20ef2-b6f3c9a3a81099857159db04549de0da-4-undirected.png
#> 2 /tmp/RtmpRs97L3/tabulergm-e05ef21a126238be3e7a84c4b687879e-b6f3c9a3a81099857159db04549de0da-4-undirected.png