Usage
format_tt(
x,
i = NULL,
j = NULL,
digits = get_option("tinytable_format_digits", default = NULL),
num_fmt = get_option("tinytable_format_num_fmt", default = "significant"),
num_zero = get_option("tinytable_format_num_zero", default = FALSE),
num_suffix = get_option("tinytable_format_num_suffix", default = FALSE),
num_mark_big = get_option("tinytable_format_num_mark_big", default = ""),
num_mark_dec = get_option("tinytable_format_num_mark_dec", default =
getOption("OutDec", default = ".")),
date = get_option("tinytable_format_date", default = NULL),
bool = get_option("tinytable_format_bool", default = NULL),
math = get_option("tinytable_format_math", default = FALSE),
other = get_option("tinytable_format_other", default = NULL),
replace = get_option("tinytable_format_replace", default = FALSE),
escape = get_option("tinytable_format_escape", default = FALSE),
markdown = get_option("tinytable_format_markdown", default = FALSE),
quarto = get_option("tinytable_format_quarto", default = FALSE),
fn = get_option("tinytable_format_fn", default = NULL),
sprintf = get_option("tinytable_format_sprintf", default = NULL)
)
tt_format(
x,
i = NULL,
j = NULL,
digits = get_option("tinytable_format_digits", default = NULL),
num_fmt = get_option("tinytable_format_num_fmt", default = "significant"),
num_zero = get_option("tinytable_format_num_zero", default = FALSE),
num_suffix = get_option("tinytable_format_num_suffix", default = FALSE),
num_mark_big = get_option("tinytable_format_num_mark_big", default = ""),
num_mark_dec = get_option("tinytable_format_num_mark_dec", default =
getOption("OutDec", default = ".")),
date = get_option("tinytable_format_date", default = NULL),
bool = get_option("tinytable_format_bool", default = NULL),
math = get_option("tinytable_format_math", default = FALSE),
other = get_option("tinytable_format_other", default = NULL),
replace = get_option("tinytable_format_replace", default = FALSE),
escape = get_option("tinytable_format_escape", default = FALSE),
markdown = get_option("tinytable_format_markdown", default = FALSE),
quarto = get_option("tinytable_format_quarto", default = FALSE),
fn = get_option("tinytable_format_fn", default = NULL),
sprintf = get_option("tinytable_format_sprintf", default = NULL)
)
Global options
Options can be set with options()
and change the default behavior of tinytable. For example:
options(tinytable_tt_digits = 4)
tt(head(iris))
You can set options in a script or via .Rprofile
. Note: be cautious with .Rprofile
settings as they may affect reproducibility.
Default values for function arguments
Nearly all of the package’s functions retrieve their default values from global options. This allows you to set defaults once and apply them to all tables without needing to specify them each time. For example, to fix the the digits
argument of the tt()
function globally, call:
options(tinytable_tt_digits = 4)
In addition, some more specific options are available to control the behavior of the package in specific contexts.
HTML
-
tinytable_html_mathjax
: Insert MathJax scripts (warning: may conflict if MathJax is loaded elsewhere)
-
tinytable_html_portable
: Insert base64 encoded images directly in HTML for plot_tt()
-
tinytable_html_engine
: Default HTML engine (default: "bootstrap"). Set to "tabulator" to use interactive tables by default in HTML documents instead of static Bootstrap tables.
PDF
-
tinytable_pdf_clean
: Delete temporary and log files
-
tinytable_pdf_engine
: Choose between "xelatex", "pdflatex", "lualatex"
Color processing
When enabled, R color names recognized by col2rgb()
are converted to hex format for consistent rendering across HTML, LaTeX, and Typst formats. If R color conversion fails, LaTeX color names are used as fallback. Colors explicitly supplied as hex values with "#" prefix are passed through unchanged. Set to FALSE to disable processing and pass color names unchanged.
Quarto
The format_tt(quarto=TRUE)
argument enables Quarto data processing with some limitations:
-
The
LaTeX macro may not process references and markdown as expected
-
Quarto processing may conflict with tinytable
styling/formatting
Options:
-
tinytable_quarto_disable_processing
: Disable Quarto cell processing
-
tinytable_print_rstudio_notebook
: Display tables "inline" or in "viewer" for RStudio notebooks
-
tinytable_quarto_figure
: Control Typst figure environment in Quarto
Example of Quarto-specific code in cells:
x <- data.frame(Math = "x^2^", Citation = "@Lovelace1842")
fn <- function(z) sprintf("<span data-qmd='%s'></span>", z)
tt(x) |> format_tt(i = 1, fn = fn)
For more details on Quarto table processing: https://quarto.org/docs/authoring/tables.html#disabling-quarto-table-processing