Package 'tabtibble'

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

Help Index


Print a tab_list

Description

Print a tab_list

Usage

## 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"
)

Arguments

x

The tab_list object to print

...

passed to print_fun

caption

The caption for each table as a character vector

label

Character vector of Quarto labels (without the ⁠tbl-⁠ prefix), one per table, matching x in length. NULL (the default) derives a label from each caption via derive_label().

topic_cols

A list the same length as x, each element a character vector of column names to group into repeating topic headers (used only by the "typst" backend; see render_backend_table()); NULL (the default) is treated as an empty vector for every table. Before a table using the "typst" backend, a Typst rule allowing its figure to break across pages is emitted ahead of the table's own crossref div – see emit_typst_breakable_figure_rule().

print_fun

Override the default printing using print_tabtibble. If provided it is a function taking arguments of x (one data.frame to print), caption (the caption for that data.frame), and ....

tab_prefix, tab_suffix

Any text to add before/after each figure (NULL to omit)

Details

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.

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).

See Also

Other knitters: knit_print.tab_tibble()


Print a tab_tibble

Description

Print a tab_tibble

Usage

## S3 method for class 'tab_tibble'
knit_print(x, ...)

Arguments

x

The tab_tibble object to print

...

Passed to subsequent methods

Value

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'.

See Also

Other knitters: knit_print.tab_list()


Create a new tab_tibble object

Description

Create a new tab_tibble object

Usage

new_tab_tibble(x)

new_tab_list(x)

Arguments

x

The object to convert. A data.frame (or tibble) with columns table (list of tables; see new_tab_list()), caption (character), and optionally label (character, unique, a valid Quarto label without the ⁠tbl-⁠ prefix – see derive_label()) and topic_cols (list column, one character vector per table, naming columns – in outer-to-inner order – that the "typst" backend groups into repeating topic headers instead of repeating their values on every row; see render_typst_table()). When label is absent or NA/empty for a row, a stable label is derived from that row's caption, so re-rendering the same caption always yields the same label. Each topic_cols[[i]] must name columns present in table[[i]], and table[[i]] must already be sorted by them.

Value

An object with the desired class

Functions

  • new_tab_list(): Create a new tab_list object