Added some documentation for new features
diff --git a/docs/awesome_table_in_pdf.Rmd b/docs/awesome_table_in_pdf.Rmd
index 9426d61..467bc0f 100644
--- a/docs/awesome_table_in_pdf.Rmd
+++ b/docs/awesome_table_in_pdf.Rmd
@@ -8,26 +8,18 @@
toc_depth: 2
---
-***
-
-> _**Some functionalities of this package, such as striped line, require the `extra_dependencies` feature from rmarkdown 1.4.0, which has not yet been released on CRAN in February, 2017. If necessary, please install the dev version of rmarkdown from github before you try this package**_
-
-***
-
# Overview
The goal of `kableExtra` is to help you build common complex tables and manipulate table styles. It imports the pipe `%>%` symbol from `magrittr` and verbalize all the functions, so basically you can add "layers" to a kable output in a way that is similar with `ggplot2` and `plotly`.
# Installation
-Some LaTeX features in `kableExtra`, such as striped line, requires rmarkdown 1.4.0+, which is not yet on CRAN. It is highly recommended to install the dev version of rmarkdown before you try this package. If you only use this package for HTML table, it doesn't matter what version of rmarkdown you are using.
```r
-# install.packages("devtools")
-devtools::install_github("rstudio/rmarkdown")
-
install.packages("kableExtra")
# For dev version
+# install.packages("devtools")
devtools::install_github("haozhu233/kableExtra")
```
+
# Getting Started
Here we are using the first few columns and rows from dataset `mtcars`
```{r}
@@ -77,7 +69,7 @@
```
### Scale down
-When you have a super-wide table and you want to scale down the table to fit the page, you can use the `scale_down` option here. Note that, it will also scale up your table if your table is too small. It was named as `scale_down` because scale up is usually not very useful. In fact, when you want to "scale up" a table, you should use `full_width = T` instead in most cases.
+When you have a wide table that will normally go out of the page and you want to scale down the table to fit the page, you can use the `scale_down` option here. Note that, if your table is too small, it will also scale up your table. It was named in this way only because scaling up isn't very useful in most cases.
```{r}
kable(cbind(dt, dt, dt), booktabs = T) %>%
kable_styling(latex_options = c("striped", "scale_down"))
@@ -88,8 +80,8 @@
```
-## Full Width or Not?
-By default, a bootstrap table takes 100% of the width. It is supposed to use together with its grid system to scale the table properly. However, when you are writing a rmarkdown document, you probably don't want to write your own css/or grid. For some small tables with only few columns, a page wide table looks awful. To make it easier, you can specify whether you want the table to have `full_width` or not in `kable_styling`. By default, `full_width` is set to be `FALSE` for LaTeX tables (note that for HTML, the default is `TRUE` since 100% width is the real "default" for bootstrap tables). Also, if you use `full_width` in LaTeX, you will loss your in-cell text alignment settings and everything will be left-aligned.
+## Full Width
+If you have a small table and you want it to spread wide on the page, you can try the `full_width` option. Unlike `scale_down`, it won't change your font size. Note that, if you use `full_width` in LaTeX, you will loss your in-cell text alignment settings and everything will be left-aligned.
```{r}
kable(dt, booktabs = T) %>%
kable_styling(full_width = T)
@@ -171,3 +163,42 @@
"Group 2 contains hp, drat and wt"),
notation = "symbol")
```
+
+---
+The following features are introduced in `kableExtra` 0.2.0.
+
+# Table on a Landscape Page
+Sometimes when we have a wide table, we want it to sit on a designated landscape page. The new function `landscape()` can help you on that. Unlike other functions, this little function only serves LaTeX and doesn't have a HTML side.
+```{r}
+kable(dt, caption = "Demo Table (Landscape)[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") %>%
+ landscape()
+```
+
+# Group Rows
+Sometimes we want a few rows of the table being grouped together. They might be items under the same topic (e.g., animals in one species) or just different data groups for a categorical variable (e.g., age < 40, age > 40). With the new function `group_rows()` in `kableExtra`, this kind of task can be completed in one line. Please see the example below. Note that when you count for the start/end rows of the group, you don't need to count for the header rows nor other group label rows. You only need to think about the row numbers in the "original R dataframe".
+```{r}
+kable(mtcars[1:10, 1:6], caption = "Group Rows", booktabs = T) %>%
+ kable_styling() %>%
+ group_rows("Group 1", 4, 7) %>%
+ group_rows("Group 2", 8, 10)
+```
+
+In case some users need it, you can define your own gapping spaces between the group labeling row and previous rows. The default value is `0.5em`.
+```{r}
+kable(dt, booktabs = T) %>%
+ group_rows("Group 1", 4, 5, latex_gap_space = "2em")
+```
+
+# Add indentation
+Unlike `group_rows()`, which will insert a labeling row, sometimes we want to list a few sub groups under a total one. In that case, `add_indent()` is probably more apporiate.
+For advanced users, you can even define your own css for the group labeling.
+```{r}
+kable(dt, booktabs = T) %>%
+ add_indent(c(1, 3, 5))
+```