# 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)
}
Run the code above in your browser using DataLab