move doc to vignette
diff --git a/vignettes/awesome_table_in_pdf.Rmd b/vignettes/awesome_table_in_pdf.Rmd
index fa84b7f..1bf5c24 100644
--- a/vignettes/awesome_table_in_pdf.Rmd
+++ b/vignettes/awesome_table_in_pdf.Rmd
@@ -11,7 +11,6 @@
- \usepackage{longtable}
- \usepackage{array}
- \usepackage{multirow}
- - \usepackage[table]{xcolor}
- \usepackage{wrapfig}
- \usepackage{float}
- \usepackage{colortbl}
@@ -21,6 +20,7 @@
- \usepackage{threeparttablex}
- \usepackage[normalem]{ulem}
- \usepackage{makecell}
+ - \usepackage{xcolor}
vignette: >
%\VignetteIndexEntry{Create Awesome PDF Table with knitr::kable and kableExtra}
%\VignetteEngine{knitr::rmarkdown}
@@ -37,7 +37,7 @@
\end{wrapfigure}
The goal of `kableExtra` is to help you build common complex tables and manipulate table styles. It imports the pipe `%>%` symbol from `magrittr` and verbalizes all the functions, so basically you can add "layers" to a kable output in a way that is similar with `ggplot2` and `plotly`.
-To learn how to generate complex tables in LaTeX, please visit [http://haozhu233.github.io/kableExtra/awesome_table_in_html.html](http://haozhu233.github.io/kableExtra/awesome_table_in_html.html).
+To learn how to generate complex tables in HTML, please visit [http://haozhu233.github.io/kableExtra/awesome_table_in_html.html](http://haozhu233.github.io/kableExtra/awesome_table_in_html.html).
# Installation
```r
@@ -50,6 +50,10 @@
# Getting Started
Here we are using the first few columns and rows from dataset `mtcars`
+```{r, echo = F}
+options(kableExtra.latex.load_packages = F)
+```
+
```{r}
library(knitr)
library(kableExtra)
@@ -87,7 +91,6 @@
- \usepackage{longtable}
- \usepackage{array}
- \usepackage{multirow}
- - \usepackage[table]{xcolor}
- \usepackage{wrapfig}
- \usepackage{float}
- \usepackage{colortbl}
@@ -97,8 +100,11 @@
- \usepackage{threeparttablex}
- \usepackage[normalem]{ulem}
- \usepackage{makecell}
+ - \usepackage{xcolor}
```
+Note: `kableExtra` was using `xcolor` for alternative row color before 1.0. However, the recent updates in `fancyvbr` causes a clash in `xcolor` option. Therefore, we removed the `xcolor` dependency in version 1.0 and started to rely on `colortbl` completely. If you experience any issues, please report on github.
+
## Plain LaTeX
Plain LaTeX table looks relatively ugly in 2017.
```{r}
@@ -371,7 +377,7 @@
collapse_rows(columns = 1:2, latex_hline = "major", valign = "middle")
```
-Right now, you can't automatically make striped rows based on collapsed rows but you can do it manually via the `extra_latex_after` option in `row_spec`. This feature is not officially supported. I'm only documenting it here if you want to give it a try.
+Right now, you can't automatically make striped rows based on collapsed rows but you can do it manually via the `extra_latex_after` option in `row_spec`. This feature is not officially supported. I'm only document it here if you want to give it a try.
```{r}
kable(collapse_rows_dt[-1], "latex", align = "c", booktabs = T) %>%
column_spec(1, bold = T, width = "5em") %>%
@@ -398,7 +404,7 @@
collapse_rows(1:3, row_group_label_position = 'stack')
```
-To better distinguish different layers, you can format each layer using `row_group_label_fonts`. You can also customize the hlines to better differentiate groups.
+To better distinguish different layers, you can format the each layer using `row_group_label_fonts`. You can also customize the hlines to better differentiate groups.
```{r}
row_group_label_fonts <- list(
diff --git a/vignettes/best_practice_for_newline_in_latex_table.Rmd b/vignettes/best_practice_for_newline_in_latex_table.Rmd
index 63b3ec5..5cd5006 100644
--- a/vignettes/best_practice_for_newline_in_latex_table.Rmd
+++ b/vignettes/best_practice_for_newline_in_latex_table.Rmd
@@ -4,11 +4,11 @@
date: "`r Sys.Date()`"
output: pdf_document
header-includes:
+ - \usepackage{caption}
- \usepackage{booktabs}
- \usepackage{longtable}
- \usepackage{array}
- \usepackage{multirow}
- - \usepackage[table]{xcolor}
- \usepackage{wrapfig}
- \usepackage{float}
- \usepackage{colortbl}
@@ -63,9 +63,17 @@
dt2 %>%
mutate_all(linebreak) %>%
kable("latex", booktabs = T, escape = F,
+ caption = "Main Title\\\\Subtitle",
col.names = linebreak(c("Item\n(Name)", "Value\n(Number)"), align = "c"))
```
+Note that linebreaks in table captions should be treated in a different way. You will need to insert the linebreak (`\\\\`) by yourself manually, which is easier than using `linebreak`. `linebreak` doesn't work because it put things in a `makecell`, which doesn't work in caption (as it's not a cell :P). At the same time, if you are using kableExtra 0.9.0 or any previous version, you need to load the `caption` package in LaTeX by yourself.
+
+```
+header-includes:
+ - \usepackage{caption}
+```
+
### Linebreak in other kableExtra functions
If you have a need to put a linebreak in `kableExtra` functions such as `add_header_above` and `group_rows`, just go ahead and use `\n` directly (in kableExtra >= 0.8.0) and it will be automatically converted. Note that this feature is also controlled by the `escape` option in those functions.