Hao Zhu | e10cfd3 | 2017-02-21 16:41:14 -0500 | [diff] [blame] | 1 | --- |
Hao Zhu | a3fc0c4 | 2017-02-27 12:04:59 -0500 | [diff] [blame] | 2 | title: "add_footnote - PDF" |
Hao Zhu | e10cfd3 | 2017-02-21 16:41:14 -0500 | [diff] [blame] | 3 | output: pdf_document |
| 4 | --- |
| 5 | |
| 6 | # Through Pandoc |
| 7 | ```{r through_pandoc} |
| 8 | library(knitr) |
| 9 | library(kableExtra) |
| 10 | dt <- mtcars[1:5, 1:2] |
| 11 | colnames(dt)[1] <- c("mpg[note]") |
| 12 | rownames(dt)[2] <- c("Mazda RX4 Wag[note]") |
| 13 | dt[3, 2] <- paste0(dt[3, 2], "[note]") |
| 14 | |
| 15 | kable(dt) %>% |
| 16 | add_footnote(c("footnote 1", "footnote 2", "footnote 3")) |
| 17 | ``` |
| 18 | |
| 19 | # Through LaTeX |
| 20 | ## Plain LaTeX |
| 21 | ```{r through_latex_plain} |
| 22 | kable(dt, format = "latex") %>% |
| 23 | add_footnote(c("footnote 1", "footnote 2", "footnote 3")) |
| 24 | ``` |
| 25 | |
| 26 | ## LaTeX + booktabs |
| 27 | ```{r through_latex_booktabs} |
| 28 | kable(dt, format = "latex", booktabs = T) %>% |
| 29 | add_footnote(c("footnote 1", "footnote 2", "footnote 3")) |
| 30 | ``` |
| 31 | |
Hao Zhu | c541563 | 2017-02-21 17:16:13 -0500 | [diff] [blame] | 32 | ## LaTeX + longtable + booktabs |
| 33 | Centered Table + page footnotes |
Hao Zhu | e10cfd3 | 2017-02-21 16:41:14 -0500 | [diff] [blame] | 34 | ```{r through_latex_longtable} |
Hao Zhu | c541563 | 2017-02-21 17:16:13 -0500 | [diff] [blame] | 35 | kable(dt, format = "latex", longtable = T, booktabs = T) %>% |
| 36 | add_footnote(c("footnote 1", "footnote 2", "footnote 3")) |
Hao Zhu | e10cfd3 | 2017-02-21 16:41:14 -0500 | [diff] [blame] | 37 | ``` |
Hao Zhu | 8dd65a9 | 2018-01-05 20:40:27 -0500 | [diff] [blame^] | 38 | |
| 39 | ## LaTeX + longtable |
| 40 | Centered Table + page footnotes |
| 41 | ```{r} |
| 42 | kable(dt, format = "latex", longtable = T) %>% |
| 43 | add_footnote(c("footnote 1", "footnote 2", "footnote 3")) |
| 44 | ``` |
| 45 | |
| 46 | ```{r} |
| 47 | kable(dt, format = "latex", booktabs = T, longtable = T) %>% |
| 48 | add_footnote(c("Footnote 1", "Have a good day."), notation = "alphabet") |
| 49 | ``` |