Numeric vector: Row indices where the styling should be applied. Can be a single value or a vector.
Logical matrix: A matrix with the same number of rows and columns as x. i=0 is the header, and negative values are higher level headers. Row indices refer to rows after the insertion of row labels by group_tt(), when applicable.
String: "notes" or "caption".
j: Column indices where the styling should be applied. Can be:
Integer vectors indicating column positions.
Character vector indicating column names.
A single string specifying a Perl-style regular expression used to match column names.
bold: Logical; if TRUE, text is styled in bold.
italic: Logical; if TRUE, text is styled in italic.
monospace: Logical; if TRUE, text is styled in monospace font.
underline: Logical; if TRUE, text is underlined.
strikeout: Logical; if TRUE, text has a strike through line.
color: Text color. There are several ways to specify colors, depending on the output format.
HTML:
Hex code composed of # and 6 characters, ex: #CC79A7.
Color blending using xcolor, ex:white!80!blue,green!20!red`.
Color names with luminance levels from c("the ", "list("ninecolors")", " package") (ex: "azure4", "magenta8", "teal2", "gray1", "olive3").
background: Background color. Specified as a color name or hexadecimal code. Can be NULL for default color.
fontsize: Font size in em units. Can be NULL for default size.
align: A single character or a string with a number of characters equal to the number of columns in j. Valid characters include 'c' (center), 'l' (left), 'r' (right), 'd' (decimal). Decimal alignment is only available in LaTeX via the siunitx package. The width of columns is determined by the maximum number of digits to the left and to the right in all cells specified by i and j.
alignv: A single character specifying vertical alignment. Valid characters include 't' (top), 'm' (middle), 'b' (bottom).
colspan: Number of columns a cell should span. i and j must be of length 1.
rowspan: Number of rows a cell should span. i and j must be of length 1.
indent: Text indentation in em units. Positive values only.
line: String determines if solid lines (rules or borders) should be drawn around the cell, row, or column.
"t": top
"b": bottom
"l": left
"r": right
Can be combined such as: "lbt" to draw borders at the left, bottom, and top.
line_color: Color of the line. See the color argument for details.
line_width: Width of the line in em units (default: 0.1).
finalize: A function applied to the table object at the very end of table-building, for post-processing. For example, the function could use regular expressions to add LaTeX commands to the text version of the table hosted in x@table_string, or it could programmatically change the caption in x@caption.
tabularray_inner: A string that specifies the "inner" settings of a tabularray LaTeX table.
tabularray_outer: A string that specifies the "outer" settings of a tabularray LaTeX table.
bootstrap_class: String. Bootstrap table class such as "table", "table table-dark" or "table table-dark table-hover". See the bootstrap documentation.
bootstrap_css: Character vector. CSS style declarations to be applied to every cell defined by i and j (ex: "font-weight: bold").
bootstrap_css_rule: String. Complete CSS rules (with curly braces, semicolon, etc.) that apply to the table class specified by the bootstrap_class argument.
output: Apply style only to the output format specified by this argument. NULL means that we apply to all formats.
...: extra arguments are ignored
Returns
An object of class tt representing the table.
Details
This function applies styling to a table created by tt(). It allows customization of text style (bold, italic, monospace), text and background colors, font size, cell width, text alignment, column span, and indentation. The function also supports passing native instructions to LaTeX (tabularray) and HTML (bootstrap) formats.
Word and Markdown limitations
Markdown and Word tables only support these styles: italic, bold, strikeout. The width argument is also unavailable Moreover, the style_tt() function cannot be used to style headers inserted by the group_tt() function; instead, you should style the headers directly in the header definition using markdown syntax: group_tt(i = list("*italic header*" = 2)). These limitations are due to the fact that there is no markdown syntax for the other options, and that we create Word documents by converting a markdown table to .docx via the Pandoc software.