Documentation Index
Fetch the complete documentation index at: https://mintlify.com/davidgohel/flextable/llms.txt
Use this file to discover all available pages before exploring further.
Captions
set_caption() attaches a caption to a flextable. When you use R Markdown or Quarto, settings from set_caption() take priority over knitr chunk options.
Simple string caption
as_paragraph() instead.
Formatted caption with as_paragraph()
Build the caption from chunks to apply font properties:
word_stylename parameter applies the named Word paragraph style to the caption. Use officer::styles_info() to list available style names in your reference document.
Formatted
as_paragraph() captions are not supported in Quarto. In Quarto, caption content and numbering are managed by the Quarto framework itself.Auto-numbered captions
Combineset_caption() with officer::run_autonum() to produce a caption preceded by an automatic “Table N:” sequence in Word:
bkm argument defines the Word bookmark name used for cross-referencing. In HTML and PDF output, the bookmark serves as the element identifier.
set_caption() parameter reference
| Parameter | Default | Description |
|---|---|---|
caption | NULL | Caption text (string) or formatted paragraph (as_paragraph()). |
autonum | NULL | officer::run_autonum() object for auto-numbering. |
word_stylename | "Table Caption" | Word paragraph style applied to the caption. |
fp_p | fp_par(padding = 3) | Paragraph formatting (alignment, spacing). Applies to HTML and Word, but not bookdown. |
align_with_table | TRUE | When TRUE, caption alignment follows the table’s alignment. |
html_classes | NULL | CSS class(es) added to the <caption> element in HTML output. |
html_escape | TRUE | Escape HTML entities in the caption string. |
Captions across output formats
- R Markdown (rmarkdown)
- bookdown
- Quarto
- officer (programmatic)
In
rmarkdown::word_document() and rmarkdown::html_document(), numbered and cross-referenced captions are not expected by default. Use knitr chunk options or set_caption() with a plain string.In rmarkdown::pdf_document(), numbers are added automatically before the caption text.Knitr chunk options
You can set captions through chunk options instead of callingset_caption(). A typical chunk looks like:
| Option | Description |
|---|---|
tab.id | Caption ID / bookmark name. |
tab.cap | Caption text. |
tab.cap.style | Word paragraph style name for the caption. |
tab.topcaption | TRUE to place caption above the table (default). |
tab.lp | Caption sequence prefix. Default "tab:". |
tab.cap.pre | Prefix before the number. Default "Table ". |
tab.cap.sep | Separator after the number. Default ": ". |
tab.cap.tnd | Title number depth. Default 0. |
tab.cap.tns | Separator between title number and table number. Default "-". |
tab.cap.fp_text | fp_text_lite() object for formatting the caption prefix. |
Footnotes
footnote() adds reference symbols to selected cells and places the footnote text in the table footer.
Basic usage
ref_symbols corresponds to one element of the value paragraph. The symbol is appended to the matched cell and the footnote text appears as a footer row.
Parameter reference
| Parameter | Default | Description |
|---|---|---|
i | NULL | Row selector. |
j | NULL | Column selector. |
value | required | as_paragraph() call with one element per distinct footnote. |
ref_symbols | NULL | Character vector of reference symbols (e.g. c("a", "b") or c("*", "†")). When NULL, no symbol is inserted. |
part | "body" | Which part the selected cells belong to. "all" is not allowed. |
inline | FALSE | When TRUE, appends the new footnote on the same footer line as the previous one. |
sep | "; " | Separator used between inline footnotes. |
symbol_sep | "" | Separator between multiple symbols in the same cell. Use "," to produce 1,2 instead of 12. |
Inline footnotes
Wheninline = TRUE, multiple footnote calls append to the same footer row rather than creating a new row each time:
Shared symbol across multiple cells
Wheni and j select multiple cells but you provide a single symbol, the same symbol and footnote is shared across all of them:
Footnotes vs footer lines
footnote() and add_footer_lines() both add content to the footer, but serve different purposes:
footnote() | add_footer_lines() | |
|---|---|---|
| Adds symbol to cell | Yes | No |
| Links cell to footnote text | Yes | No |
Accepts as_paragraph() | Yes | Yes |
| Suitable for general notes | No | Yes |
footnote() when you need to mark specific cells with a symbol and associate each mark with an explanatory note. Use add_footer_lines() for general notes or source attributions that apply to the whole table.