Hao Zhu | e10cfd3 | 2017-02-21 16:41:14 -0500 | [diff] [blame] | 1 | --- |
| 2 | title: add_footnote - HTML |
| 3 | output: html_document |
Hao Zhu | 9495658 | 2017-02-21 18:18:29 -0500 | [diff] [blame] | 4 | vignette: > |
| 5 | %\VignetteIndexEntry{Use add_footnote in HTML document} |
| 6 | %\VignetteEngine{knitr::rmarkdown} |
| 7 | %\VignetteEncoding{UTF-8} |
Hao Zhu | e10cfd3 | 2017-02-21 16:41:14 -0500 | [diff] [blame] | 8 | --- |
| 9 | |
| 10 | # Through Pandoc |
| 11 | ```{r through_pandoc} |
| 12 | library(knitr) |
| 13 | library(kableExtra) |
| 14 | dt <- mtcars[1:5, 1:2] |
| 15 | colnames(dt)[1] <- c("mpg[note]") |
| 16 | rownames(dt)[2] <- c("Mazda RX4 Wag[note]") |
| 17 | dt[3, 2] <- paste0(dt[3, 2], "[note]") |
| 18 | |
| 19 | kable(dt) %>% |
| 20 | add_footnote(c("footnote 1", "footnote 2", "footnote 3")) |
| 21 | ``` |
| 22 | |
| 23 | # Through HTML |
| 24 | ## Plain HTML |
| 25 | ```{r through_html} |
| 26 | kable(dt, format = "html") %>% |
| 27 | add_footnote(c("footnote 1", "footnote 2", "footnote 3")) |
| 28 | ``` |
| 29 | |
| 30 | ## HTML + bootstrap table |
| 31 | ```{r through_html_bootstrap} |
| 32 | kable(dt, format = "html", table.attr = htmlTable_styling()) %>% |
| 33 | add_footnote(c("footnote 1", "footnote 2", "footnote 3")) |
| 34 | ``` |
| 35 | |
| 36 | ## HTML + bootstrap narrow table |
| 37 | ```{r through_latex_longtable} |
| 38 | kable(dt, format = "html", |
| 39 | table.attr = htmlTable_styling(c("striped", "bordered"), |
| 40 | full_width = F)) %>% |
| 41 | add_footnote(c("footnote 1", "footnote 2", "footnote 3")) |
| 42 | ``` |