Final fixes for 0.7.0 release
diff --git a/vignettes/awesome_table_in_html.Rmd b/vignettes/awesome_table_in_html.Rmd
index 1161d28..47d71d8 100644
--- a/vignettes/awesome_table_in_html.Rmd
+++ b/vignettes/awesome_table_in_html.Rmd
@@ -360,41 +360,53 @@
```
# Table Footnote
-## Notation systems
-You can also use `add_footnote()` function from this package. You will need to supply a character vector with each element as one footnote. You may select from `number`, `alphabet` and `symbol` for different types of notations. Example are listed below.
-### Alphabet
+> Now it's recommended to use the new `footnote` function instead of `add_footnote` to make table footnotes.
+
+Documentations for `add_footnote` can be found [here](http://haozhu233.github.io/kableExtra/legacy_features#add_footnote).
+
+There are four notation systems in `footnote`, namely `general`, `number`, `alphabet` and `symbol`. The last three types of footnotes will be labeled with corresponding marks while `general` won't be labeled. You can pick any one of these systems or choose to display them all for fulfill the APA table footnotes requirements.
```{r}
-kable(dt, "html") %>%
- kable_styling("striped") %>%
- add_footnote(c("Footnote 1", "Have a good day."), notation = "alphabet")
+kable(dt, "html", align = "c") %>%
+ kable_styling(full_width = F) %>%
+ footnote(general = "Here is a general comments of the table. ",
+ number = c("Footnote 1; ", "Footnote 2; "),
+ alphabet = c("Footnote A; ", "Footnote B; "),
+ symbol = c("Footnote Symbol 1; ", "Footnote Symbol 2")
+ )
```
-### Number
+You can also specify title for each category by using the `***_title` arguments. Default value for `general_title` is "Note: " and "" for the rest three. You can also change the order using `footnote_order`. You can even display footnote as chunk texts (default is as a list) using `footnote_as_chunk`.
+
```{r}
-kable(dt, "html") %>%
- kable_styling("striped") %>%
- add_footnote(c("Footnote 1", "Have a good day."), notation = "number")
+kable(dt, "html", align = "c") %>%
+ kable_styling(full_width = F) %>%
+ footnote(general = "Here is a general comments of the table. ",
+ number = c("Footnote 1; ", "Footnote 2; "),
+ alphabet = c("Footnote A; ", "Footnote B; "),
+ symbol = c("Footnote Symbol 1; ", "Footnote Symbol 2"),
+ general_title = "General: ", number_title = "Type I: ",
+ alphabet_title = "Type II: ", symbol_title = "Type III: ",
+ footnote_as_chunk = T
+ )
```
-### Symbol
-```{r}
-kable(dt, "html") %>%
- kable_styling("striped") %>%
- add_footnote(c("Footnote 1", "Footnote 2", "Footnote 3"), notation = "symbol")
-```
-
-## In-table markers
-By design, `add_footnote()` will transform any `[note]` to in-table footnote markers.
+If you need to add footnote marks in table, you need to do it manually (no fancy) using `footnote_mark_***()`. Remember that similar with `cell_spec`, you need to tell this function whether you want it to do it in `HTML` (default) or `LaTeX`. You can set it for all using the `knitr.table.format` global option. ALso, if you have ever use `footnote_mark_***()`, you need to put `escape = F` in your `kable` function to avoid escaping of special characters.
```{r}
-kable(dt, "html", caption = "Demo Table[note]") %>%
- kable_styling("striped") %>%
- add_header_above(c(" ", "Group 1[note]" = 3, "Group 2[note]" = 3)) %>%
- add_footnote(c("This table is from mtcars",
- "Group 1 contains mpg, cyl and disp",
- "Group 2 contains hp, drat and wt"),
- notation = "symbol")
+dt_footnote <- dt
+names(dt_footnote)[2] <- paste0(names(dt_footnote)[2],
+ footnote_marker_symbol(1))
+row.names(dt_footnote)[4] <- paste0(row.names(dt_footnote)[4],
+ footnote_marker_alphabet(1))
+kable(dt_footnote, "html", align = "c",
+ # Remember this escape = F
+ escape = F) %>%
+ kable_styling(full_width = F) %>%
+ footnote(alphabet = "Footnote A; ",
+ symbol = "Footnote Symbol 1; ",
+ alphabet_title = "Type II: ", symbol_title = "Type III: ",
+ footnote_as_chunk = T)
```
# HTML Only Features
diff --git a/vignettes/awesome_table_in_pdf.Rmd b/vignettes/awesome_table_in_pdf.Rmd
index ff8e7dd..fe9e7f6 100644
--- a/vignettes/awesome_table_in_pdf.Rmd
+++ b/vignettes/awesome_table_in_pdf.Rmd
@@ -18,6 +18,7 @@
- \usepackage{pdflscape}
- \usepackage{tabu}
- \usepackage{threeparttable}
+ - \usepackage[normalem]{ulem}
vignette: >
%\VignetteIndexEntry{Create Awesome PDF Table with knitr::kable and kableExtra}
%\VignetteEngine{knitr::rmarkdown}
@@ -82,6 +83,7 @@
- \usepackage{pdflscape}
- \usepackage{tabu}
- \usepackage{threeparttable}
+ - \usepackage[normalem]{ulem}
```
## Plain LaTeX
@@ -199,6 +201,7 @@
kable(dt, format = "latex", booktabs = T) %>%
kable_styling("striped", full_width = F) %>%
column_spec(7, border_left = T, bold = T) %>%
+ row_spec(1, strikeout = T) %>%
row_spec(3:5, bold = T, color = "white", background = "black")
```
@@ -324,7 +327,9 @@
```
## Group rows via multi-row cell
-Function `group_rows` is great for showing simple structural information on rows but sometimes people may need to show structural information with multiple layers. When it happens, you may consider to use `collapse_rows` instead, which will put repeating cells in columns into multi-row cells. If you even need to specify column/row format, use `column_spec` & `row_spec` before you pipe it into `collapse_rows`.
+Function `group_rows` is great for showing simple structural information on rows but sometimes people may need to show structural information with multiple layers. When it happens, you may consider to use `collapse_rows` instead, which will put repeating cells in columns into multi-row cells.
+
+In LaTeX, `collapse_rows` adds some extra hlines to help differentiate groups. You can customize this behavior using the `latex_hline` argument. You can choose from `full` (default), `major` and `none`.
```{r}
collapse_rows_dt <- data.frame(C1 = c(rep("a", 10), rep("b", 5)),
@@ -333,7 +338,7 @@
C4 = sample(c(0,1), 15, replace = TRUE))
kable(collapse_rows_dt, format = "latex", booktabs = T, align = "c") %>%
column_spec(1, bold=T) %>%
- collapse_rows(columns = 1:2)
+ collapse_rows(columns = 1:2, latex_hline = "major")
```
```{r}
@@ -343,40 +348,52 @@
```
# Table Footnote
-## Notation system
-You can also use `add_footnote()` function from this package. You will need to supply a character vector with each element as one footnote. You may select from `number`, `alphabet` and `symbol` for different types of notations. Example are listed below.
-### Alphabet
+> Now it's recommended to use the new `footnote` function instead of `add_footnote` to make table footnotes.
+
+Documentations for `add_footnote` can be found [here](http://haozhu233.github.io/kableExtra/legacy_features#add_footnote).
+
+There are four notation systems in `footnote`, namely `general`, `number`, `alphabet` and `symbol`. The last three types of footnotes will be labeled with corresponding marks while `general` won't be labeled. You can pick any one of these systems or choose to display them all for fulfill the APA table footnotes requirements.
```{r}
-kable(dt, format = "latex", booktabs = T) %>%
- kable_styling() %>%
- add_footnote(c("Footnote 1", "Have a good day."), notation = "alphabet")
+kable(dt, "latex", align = "c") %>%
+ kable_styling(full_width = F) %>%
+ footnote(general = "Here is a general comments of the table. ",
+ number = c("Footnote 1; ", "Footnote 2; "),
+ alphabet = c("Footnote A; ", "Footnote B; "),
+ symbol = c("Footnote Symbol 1; ", "Footnote Symbol 2")
+ )
```
-### Number
+You can also specify title for each category by using the `***_title` arguments. Default value for `general_title` is "Note: " and "" for the rest three. You can also change the order using `footnote_order`. You can even display footnote as chunk texts (default is as a list) using `footnote_as_chunk`.
+
```{r}
-kable(dt, format = "latex", booktabs = T) %>%
- kable_styling() %>%
- add_footnote(c("Footnote 1", "Have a good day."), notation = "number")
+kable(dt, "latex", align = "c", booktabs = T) %>%
+ footnote(general = "Here is a general comments of the table. ",
+ number = c("Footnote 1; ", "Footnote 2; "),
+ alphabet = c("Footnote A; ", "Footnote B; "),
+ symbol = c("Footnote Symbol 1; ", "Footnote Symbol 2"),
+ general_title = "General: ", number_title = "Type I: ",
+ alphabet_title = "Type II: ", symbol_title = "Type III: ",
+ footnote_as_chunk = T
+ )
```
-### Symbol
-```{r}
-kable(dt, format = "latex", booktabs = T) %>%
- kable_styling() %>%
- add_footnote(c("Footnote 1", "Footnote 2", "Footnote 3"), notation = "symbol")
-```
+If you need to add footnote marks in table, you need to do it manually (no fancy) using `footnote_mark_***()`. Remember that similar with `cell_spec`, you need to tell this function whether you want it to do it in `HTML` (default) or `LaTeX`. You can set it for all using the `knitr.table.format` global option. ALso, if you have ever use `footnote_mark_***()`, you need to put `escape = F` in your `kable` function to avoid escaping of special characters.
-## In-table markers
-By design, `add_footnote()` will transform any `[note]` to in-table footnote markers.
```{r}
-kable(dt, format = "latex", caption = "Demo Table[note]", booktabs = T) %>%
- kable_styling(latex_options = "hold_position") %>%
- add_header_above(c(" ", "Group 1[note]" = 3, "Group 2[note]" = 3)) %>%
- add_footnote(c("This table is from mtcars",
- "Group 1 contains mpg, cyl and disp",
- "Group 2 contains hp, drat and wt"),
- notation = "symbol")
+dt_footnote <- dt
+names(dt_footnote)[2] <- paste0(names(dt_footnote)[2],
+ # That "latex" can be eliminated if defined in global
+ footnote_marker_symbol(1, "latex"))
+row.names(dt_footnote)[4] <- paste0(row.names(dt_footnote)[4],
+ footnote_marker_alphabet(1))
+kable(dt_footnote, "latex", align = "c", booktabs = T,
+ # Remember this escape = F
+ escape = F) %>%
+ footnote(alphabet = "Footnote A; ",
+ symbol = "Footnote Symbol 1; ",
+ alphabet_title = "Type II: ", symbol_title = "Type III: ",
+ footnote_as_chunk = T)
```
# LaTeX Only Features
diff --git a/vignettes/kableExtra_and_word.Rmd b/vignettes/kableExtra_and_word.Rmd
new file mode 100644
index 0000000..4ad4ceb
--- /dev/null
+++ b/vignettes/kableExtra_and_word.Rmd
@@ -0,0 +1,27 @@
+---
+title: "kableExtra and Word"
+author: "Hao Zhu"
+date: "`r Sys.Date()`"
+output:
+ html_document:
+ theme: simplex
+vignette: >
+ %\VignetteIndexEntry{kableExtra and Word}
+ %\VignetteEngine{knitr::rmarkdown}
+ %\VignetteEncoding{UTF-8}
+---
+
+```{r setup, include=FALSE}
+knitr::opts_chunk$set(echo = TRUE)
+```
+
+
+<video width="800" height="400" controls>
+ <source src="word.mp4" type="video/mp4">
+ Your browser does not support the video tag.
+</video>
+
+***
+
+> You can `copy` formatted tables from HTML and `paste` them into a Word document
+without losing the format.
diff --git a/vignettes/legacy_features.Rmd b/vignettes/legacy_features.Rmd
new file mode 100644
index 0000000..a82634c
--- /dev/null
+++ b/vignettes/legacy_features.Rmd
@@ -0,0 +1,66 @@
+---
+title: "Legacy or Unrecommended Features"
+author: "Hao Zhu"
+date: "`r Sys.Date()`"
+output:
+ html_document:
+ theme: simplex
+vignette: >
+ %\VignetteIndexEntry{Legacy or Unrecommended Features}
+ %\VignetteEngine{knitr::rmarkdown}
+ %\VignetteEncoding{UTF-8}
+---
+
+This document includes documentations for legacy/unrecommended features in this package.
+
+Unless there are significant differences between HTML/LaTeX, I will only keep one copy of documentation in HTML here since most of the functions in this packages share a very similar interface between their HTML and LaTeX ends.
+
+```{r, warning=FALSE}
+library(knitr)
+library(kableExtra)
+dt <- mtcars[1:5, 1:6]
+```
+
+# Unrecommended Features
+
+## add_footnote
+As the first function written in this package, the design of the `add_footnote` function is not flexible enough to introduce new features to this function. So I redesigned the footnote part and created the `footnote()` function. `add_footnote` will still be there for a while and be maintained because of its unique feature to add page footnote to longtables.
+
+Here are the old documentation for `add_footnote`.
+
+### Notation systems
+You can also use `add_footnote()` function from this package. You will need to supply a character vector with each element as one footnote. You may select from `number`, `alphabet` and `symbol` for different types of notations. Example are listed below.
+
+#### Alphabet
+```{r}
+kable(dt, "html") %>%
+ kable_styling("striped") %>%
+ add_footnote(c("Footnote 1", "Have a good day."), notation = "alphabet")
+```
+
+#### Number
+```{r}
+kable(dt, "html") %>%
+ kable_styling("striped") %>%
+ add_footnote(c("Footnote 1", "Have a good day."), notation = "number")
+```
+
+#### Symbol
+```{r}
+kable(dt, "html") %>%
+ kable_styling("striped") %>%
+ add_footnote(c("Footnote 1", "Footnote 2", "Footnote 3"), notation = "symbol")
+```
+
+### In-table markers
+By design, `add_footnote()` will transform any `[note]` to in-table footnote markers.
+
+```{r}
+kable(dt, "html", caption = "Demo Table[note]") %>%
+ kable_styling("striped") %>%
+ add_header_above(c(" ", "Group 1[note]" = 3, "Group 2[note]" = 3)) %>%
+ add_footnote(c("This table is from mtcars",
+ "Group 1 contains mpg, cyl and disp",
+ "Group 2 contains hp, drat and wt"),
+ notation = "symbol")
+```
diff --git a/vignettes/use_kableExtra_with_formattable.Rmd b/vignettes/use_kableExtra_with_formattable.Rmd
index 641fe78..e19dd2f 100644
--- a/vignettes/use_kableExtra_with_formattable.Rmd
+++ b/vignettes/use_kableExtra_with_formattable.Rmd
@@ -3,10 +3,6 @@
author: "Hao Zhu"
date: "`r Sys.Date()`"
output: html_document
-vignette: >
- %\VignetteIndexEntry{Use kableExtra with formattable}
- %\VignetteEngine{knitr::rmarkdown}
- %\VignetteEncoding{UTF-8}
---
I know you love `formattable`'s `color_tile` and `color_bar`. I do too. In my mind, these two features are among the best visualization methods in a tabular format. You may wonder if it's possible use it together with `kableExtra` so you can have a nested table with awesome presentation at the same time. Here is how.
@@ -61,3 +57,4 @@
kable("html", escape = F, align = "c") %>%
kable_styling("condensed", full_width = F)
```
+
diff --git a/vignettes/word.mp4 b/vignettes/word.mp4
new file mode 100644
index 0000000..8c24fab
--- /dev/null
+++ b/vignettes/word.mp4
Binary files differ