Learn R Programming

kableExtra (version 1.4.0)

footnote: Add footnote (new)

Description

footnote provides a more flexible way to add footnote. You can add multiple sets of footnote using different notation systems. It is also possible to specify footnote section header one by one and print footnotes as a chunk of texts.

Usage

footnote(
  kable_input,
  general = NULL,
  number = NULL,
  alphabet = NULL,
  symbol = NULL,
  footnote_order = c("general", "number", "alphabet", "symbol"),
  footnote_as_chunk = FALSE,
  escape = TRUE,
  threeparttable = FALSE,
  fixed_small_size = FALSE,
  general_title = "Note: ",
  number_title = "",
  alphabet_title = "",
  symbol_title = "",
  title_format = "italic",
  symbol_manual = NULL
)

Arguments

kable_input

HTML or LaTeX table generated by knitr::kable

general

Text for general footnote comments. Footnotes in this section won't be labeled with any notations

number

A vector of footnote texts. Footnotes here will be numbered. There is no upper cap for the number of footnotes here

alphabet

A vector of footnote texts, Footnotes here will be labeled with "a,b,c". The vector here should not have more than 26 elements.

symbol

A vector of footnote texts, Footnotes here will be labeled with special symbols. The vector here should not have more than 20 elements.

footnote_order

The order of how to arrange general, number, alphabet and symbol.

footnote_as_chunk

T/F value. Default is FALSE. It controls whether the footnotes should be printed in a chunk (without line break).

escape

T/F value. It controls whether the contents and titles should be escaped against HTML or LaTeX. Default is TRUE.

threeparttable

T/F value for whether to use LaTeX package threeparttable. Threeparttable will force the width of caption and footnotes be the width of the original table. It's useful when you have long paragraph of footnotes.

fixed_small_size

T/F When you want to keep the footnote small after specifying large font size with the kable_styling() (e.g. ideal font for headers and table content with small font in footnotes).

general_title

Section header for general footnotes. Default is "Note: ".

number_title

Section header for number footnotes. Default is "".

alphabet_title

Section header for alphabet footnotes. Default is "".

symbol_title

Section header for symbol footnotes. Default is "".

title_format

Choose from "italic"(default), "bold" and "underline". Multiple options are possible.

symbol_manual

User can manually supply a vector of either html or latex symbols. For example, symbol_manual = c('*', '\\\\dag', '\\\\ddag').`

See Also

add_footnote(), footnote_marker_number()

Examples

Run this code
if (FALSE) {
dt <- mtcars[1:5, 1:5]
colnames(dt)[1] <- paste0("mpg",
                          footnote_marker_alphabet(2))
rownames(dt)[2] <- paste0(rownames(dt)[2],
                          footnote_marker_alphabet(1))
dt[1,2] <- paste0(dt[1,2], footnote_marker_alphabet(3))

kbl(dt, escape = FALSE) |>
  footnote(alphabet = c("Note a", "Note b", "Note c"))
}

Run the code above in your browser using DataLab