footnote_options {ftExtra} | R Documentation |
Options for footnotes
Description
Configure options for footnotes.
Usage
footnote_options(
ref = c("1", "a", "A", "i", "I", "*"),
prefix = "",
suffix = "",
start = 1L,
max = 26L,
inline = FALSE,
sep = "; "
)
Arguments
ref |
A string or a function that defines symbols of footnote references.
If the value is string, it must be one of the "1", "a", "A", "i", "I", or
"*". If a function, keep in mind this is an experimental feature. It
receives 3 parameters ( |
prefix , suffix |
Pre- and suf-fixes for |
start |
A starting number of footnotes. |
max |
A max number of footnotes used only when |
inline |
whether to add footnote on same line as previous footnote or not |
sep |
used only when inline = TRUE, character string to use as a separator between footnotes. |
Value
An environment
Examples
# A examole flextable with unprocessed markdown footnotes
ft <- flextable(tibble::tibble(
"header1^[note a]" = c("x^[note 1]", "y"),
"header2" = c("a", "b^[note 2]")
))
# Render all footnotes in the same format.
if (rmarkdown::pandoc_available("2.0.6")) {
ft %>%
colformat_md(
part = "all",
.footnote_options = footnote_options("1", start = 1L)
)
}
# Use a user-defined function to format footnote symbols
# Skipped to reduce build time
if (FALSE) {
# a function to format symbols of footnote references
ref <- function(n, part, footer) {
# Change symbols by context
# - header: letters (a, b, c, ...)
# - body: integers (1, 2, 3, ...)
s <- if (part == "header") {
letters[n]
} else {
as.character(n)
}
# Suffix symbols with ": " (a colon and a space) in the footer
if (footer) {
return(paste0(s, ":\\ "))
}
# Use superscript in the header and the body
return(paste0("^", s, "^"))
}
# apply custom format of symbols
ft %>%
# process header first
colformat_md(
part = "header", .footnote_options = footnote_options(ref = ref)
) %>%
# process body next
colformat_md(
part = "body", .footnote_options = footnote_options(ref = ref)
) %>%
# tweak width for visibility
flextable::autofit(add_w = 0.2)
}