blob: 45ffafbb920bb521892f6a0b38e3d9dc809e69e6 [file] [log] [blame]
Hao Zhucdd7f922018-01-08 11:39:40 -05001#' Footnote marker
Hao Zhu1ac13ad2018-01-08 16:12:24 -05002#' @export
3footnote_marker_number <- function(x, format) {
4 if (missing(format) || is.null(format)) {
5 format <- getOption('knitr.table.format')
6 }
7 if (is.null(format)) {
8 message("Setting footnote_marker_number format as html")
9 format <- "html"
10 }
11 if (format == "html") {
12 return(paste0("<sup>", x, "</sup>"))
13 } else {
Hao Zhu19c4fa52018-01-09 12:01:14 -050014 return(paste0("\\textsuperscript{", x, "}"))
Hao Zhu1ac13ad2018-01-08 16:12:24 -050015 }
16}
17
18#' @export
19footnote_marker_alphabet <- function(x, format) {
20 if (missing(format) || is.null(format)) {
21 format <- getOption('knitr.table.format')
22 }
23 if (is.null(format)) {
24 message("Setting footnote_marker_alphabet format as html")
25 format <- "html"
26 }
27 if (is.numeric(x)) x <- letters[x]
28 if (format == "html") {
29 return(paste0("<sup>", x, "</sup>"))
30 } else {
Hao Zhu19c4fa52018-01-09 12:01:14 -050031 return(paste0("\\textsuperscript{", x, "}"))
Hao Zhu1ac13ad2018-01-08 16:12:24 -050032 }
33}
34
35#' @export
36footnote_marker_symbol <- function(x, format) {
37 if (missing(format) || is.null(format)) {
38 format <- getOption('knitr.table.format')
39 }
40 if (is.null(format)) {
41 message("Setting footnote_marker_symbol format as html")
42 format <- "html"
43 }
44 number_index <- read.csv(system.file("symbol_index.csv",
45 package = "kableExtra"))
46 if (format == "html") {
47 x <- number_index$symbol.html[x]
48 return(paste0("<sup>", x, "</sup>"))
49 } else {
50 x <- number_index$symbol.latex[x]
Hao Zhu19c4fa52018-01-09 12:01:14 -050051 return(paste0("\\textsuperscript{", x, "}"))
Hao Zhu1ac13ad2018-01-08 16:12:24 -050052 }
53}