Fix #105
diff --git a/R/cell_spec.R b/R/cell_spec.R
index c6ef41d..0774fcb 100644
--- a/R/cell_spec.R
+++ b/R/cell_spec.R
@@ -50,7 +50,9 @@
background_as_tile = TRUE,
latex_background_in_cell = TRUE) {
- if (missing(format) || is.null(format)) format = getOption('knitr.table.format')
+ if (missing(format) || is.null(format)) {
+ format <- getOption('knitr.table.format')
+ }
if (is.null(format)) {
message("Setting cell_spec format as html")
format <- "html"
@@ -75,9 +77,10 @@
escape, background_as_tile) {
if (escape) x <- escape_html(x)
cell_style <- NULL
- if (bold) cell_style <- paste(cell_style,"font-weight: bold;")
- if (italic) cell_style <- paste(cell_style, "font-style: italic;")
- if (monospace) cell_style <- paste(cell_style, "font-family: monospace;")
+ cell_style <- paste(cell_style, ifelse(bold, "font-weight: bold;", ""))
+ cell_style <- paste(cell_style, ifelse(italic, "font-style: italic;", ""))
+ cell_style <- paste(cell_style,
+ ifelse(monospace, "font-family: monospace;", ""))
if (!is.null(color)) {
cell_style <- paste0(cell_style, "color: ", html_color(color), ";")
}
diff --git a/R/footnote.R b/R/footnote.R
index 63caf6d..92ad36a 100644
--- a/R/footnote.R
+++ b/R/footnote.R
@@ -2,17 +2,17 @@
#'
#' @export
footnote <- function(kable_input,
- general = NULL,
- number = NULL,
- alphabet = NULL,
- symbol = NULL,
- footnote_order = c("general", "number",
- "alphabet", "symbol"),
- footnote_as_chunk = FALSE,
- general_title = "Note: ",
- number_title = "",
- alphabet_title = "",
- symbol_title = ""
+ general = NULL,
+ number = NULL,
+ alphabet = NULL,
+ symbol = NULL,
+ footnote_order = c("general", "number",
+ "alphabet", "symbol"),
+ footnote_as_chunk = FALSE,
+ general_title = "Note: ",
+ number_title = "",
+ alphabet_title = "",
+ symbol_title = ""
) {
kable_format <- attr(kable_input, "format")
if (!kable_format %in% c("html", "latex")) {
@@ -94,8 +94,7 @@
}
# HTML
-footnote_html <- function(kable_input, footnote_table,
- footnote_as_chunk) {
+footnote_html <- function(kable_input, footnote_table, footnote_as_chunk) {
kable_attrs <- attributes(kable_input)
kable_xml <- read_kable_as_xml(kable_input)
@@ -146,6 +145,8 @@
}
# LaTeX
-footnote_latex <- function() {
+footnote_latex <- function(kable_input, footnote_table, footnote_as_chunk) {
+ table_info <- magic_mirror(kable_input)
+
}
diff --git a/R/footnote_marker.R b/R/footnote_marker.R
index 0b2dd8d..b0d1988 100644
--- a/R/footnote_marker.R
+++ b/R/footnote_marker.R
@@ -1 +1,53 @@
#' Footnote marker
+#' @export
+footnote_marker_number <- function(x, format) {
+ if (missing(format) || is.null(format)) {
+ format <- getOption('knitr.table.format')
+ }
+ if (is.null(format)) {
+ message("Setting footnote_marker_number format as html")
+ format <- "html"
+ }
+ if (format == "html") {
+ return(paste0("<sup>", x, "</sup>"))
+ } else {
+ return(paste0("\\\\textsuperscript{", x, "}"))
+ }
+}
+
+#' @export
+footnote_marker_alphabet <- function(x, format) {
+ if (missing(format) || is.null(format)) {
+ format <- getOption('knitr.table.format')
+ }
+ if (is.null(format)) {
+ message("Setting footnote_marker_alphabet format as html")
+ format <- "html"
+ }
+ if (is.numeric(x)) x <- letters[x]
+ if (format == "html") {
+ return(paste0("<sup>", x, "</sup>"))
+ } else {
+ return(paste0("\\\\textsuperscript{", x, "}"))
+ }
+}
+
+#' @export
+footnote_marker_symbol <- function(x, format) {
+ if (missing(format) || is.null(format)) {
+ format <- getOption('knitr.table.format')
+ }
+ if (is.null(format)) {
+ message("Setting footnote_marker_symbol format as html")
+ format <- "html"
+ }
+ number_index <- read.csv(system.file("symbol_index.csv",
+ package = "kableExtra"))
+ if (format == "html") {
+ x <- number_index$symbol.html[x]
+ return(paste0("<sup>", x, "</sup>"))
+ } else {
+ x <- number_index$symbol.latex[x]
+ return(paste0("\\\\textsuperscript{", x, "}"))
+ }
+}