| Title: | Simplify Reporting Many Tables |
|---|---|
| Description: | Simplify reporting many tables by creating tibbles of tables. With 'tabtibble', a tibble of tables is created with captions and automatic printing using knit_print(). |
| Authors: | Bill Denney [aut, cre] (ORCID: <https://orcid.org/0000-0002-5759-428X>) |
| Maintainer: | Bill Denney <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.0.2.9001 |
| Built: | 2026-10-07 08:41:32 UTC |
| Source: | https://github.com/humanpred/tabtibble |
Print a tab_list
## S3 method for class 'tab_list' knit_print( x, ..., caption, label = NULL, topic_cols = NULL, print_fun = NULL, tab_prefix = NULL, tab_suffix = "\n\n" )## S3 method for class 'tab_list' knit_print( x, ..., caption, label = NULL, topic_cols = NULL, print_fun = NULL, tab_prefix = NULL, tab_suffix = "\n\n" )
x |
The |
... |
passed to |
caption |
The caption for each table as a character vector |
label |
Character vector of Quarto labels (without the |
topic_cols |
A list the same length as |
print_fun |
Override the default printing using |
tab_prefix, tab_suffix
|
Any text to add before/after each figure ( |
Individual tables are printed with the print_tabtibble() S3 generic
function. Under Quarto (see detect_render_mode()), each table is
wrapped in a fenced Div with id #tbl-<label> (Quarto's syntax for a
crossreferenceable table from computational output), so @tbl-<label>
resolves and, when the report target is Typst, the table appears in a
Typst #outline(target: figure.where(kind: "quarto-float-tbl")) (the
list of tables; that outline call belongs in the report template, not
here). The caption is emitted once, as the Div's trailing paragraph,
which Quarto promotes to the figure's caption; it is Typst/Pandoc-escaped
(see escape_typst()) so caption text containing markup-significant
characters renders literally.
Under plain R Markdown, that Div is skipped: rendered by plain Pandoc
(no Quarto filter to interpret it), it would show up as a literal,
uncaptioned wrapper rather than a table figure. Instead, each table
carries an ordinary caption the output target understands – see
render_backend_table() – so a report that never used Quarto keeps
working exactly as it did before crossref support was added.
By default (the tabtibble.knitr.auto.asis option, TRUE), the
rendered markdown is captured and returned as knitr::asis_output(),
the same mechanism pander uses for its knitr.auto.asis option: knitr
inserts an asis-classed return value into the document directly,
whatever the chunk's own results setting, so a chunk printing a
tab_tibble/tab_list needs no results='asis' chunk option. Set
options(tabtibble.knitr.auto.asis = FALSE) to opt out and go back to
writing directly with cat() (requiring results='asis', with a
warning when it is missing) – useful if something downstream needs to
see the literal cat() side effect rather than a returned value.
With tabtibble.knitr.auto.asis TRUE (the default), a
knitr::asis_output() character value holding the rendered markdown.
With it FALSE, x invisibly (the markdown is written with cat()
as a side effect instead).
Other knitters:
knit_print.tab_tibble()
Print a tab_tibble
## S3 method for class 'tab_tibble' knit_print(x, ...)## S3 method for class 'tab_tibble' knit_print(x, ...)
x |
The |
... |
Passed to subsequent methods |
The result of knit_print(x$table, ...): by default (see
knit_print.tab_list()) a knitr::asis_output() value, so a chunk
printing a tab_tibble needs no results='asis'.
Other knitters:
knit_print.tab_list()
tab_tibble objectCreate a new tab_tibble object
new_tab_tibble(x) new_tab_list(x)new_tab_tibble(x) new_tab_list(x)
x |
The object to convert. A data.frame (or tibble) with columns
|
An object with the desired class
new_tab_list(): Create a new tab_list object
Print a single table from a tablist
print_tabtibble(x, ...) ## Default S3 method: print_tabtibble(x, caption = NULL, ..., topic_cols = character(0))print_tabtibble(x, ...) ## Default S3 method: print_tabtibble(x, caption = NULL, ..., topic_cols = character(0))
x |
A table to print |
... |
Passed to the backend's table constructor
( |
caption |
The table's caption, or |
topic_cols |
Character vector of column names to group into
repeating topic headers; only used by the |
x, invisibly
print_tabtibble(default): Print a single table from a tablist using the
backend selected by the tabtibble.backend option ("markdown"
(default), "tinytable", "gt", "flextable", or "typst"; see
render_backend_table()) when x is a plain data.frame. An x that
is already a gt, tinytable, flextable, or table1 object (see
new_tab_list()) is printed via its own knitr::knit_print() method
instead, regardless of tabtibble.backend, so a table the caller
built with a specific package is rendered exactly as they built it;
under R Markdown (see detect_render_mode()), caption (when
supplied) is still shown for it, as a plain bold paragraph before the
table, since there is no single API across those packages for adding
a caption to an already-built object.