Hao Zhu | cdd7f92 | 2018-01-08 11:39:40 -0500 | [diff] [blame] | 1 | #' Footnote marker |
Hao Zhu | 1ac13ad | 2018-01-08 16:12:24 -0500 | [diff] [blame] | 2 | #' @export |
| 3 | footnote_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 { |
| 14 | return(paste0("\\\\textsuperscript{", x, "}")) |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | #' @export |
| 19 | footnote_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 { |
| 31 | return(paste0("\\\\textsuperscript{", x, "}")) |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | #' @export |
| 36 | footnote_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] |
| 51 | return(paste0("\\\\textsuperscript{", x, "}")) |
| 52 | } |
| 53 | } |