bump version...
remove magick from imports to suggests;
update documentation
update vignettes
diff --git a/docs/awesome_table_in_html.Rmd b/docs/awesome_table_in_html.Rmd
index 95c745e..e042f65 100644
--- a/docs/awesome_table_in_html.Rmd
+++ b/docs/awesome_table_in_html.Rmd
@@ -112,7 +112,7 @@
# Column / Row Specification
## Column spec
-When you have a table with lots of explanatory texts, you may want to specified the column width for different column, since the auto adjust in HTML may not work in its best way while basic LaTeX table is really bad at handling text wrapping. Also, sometimes, you may want to highlight a column (e.g. a "Total" column) by making it bold. In these scenario, you can use `column_spec()`. You can find an example below.
+When you have a table with lots of explanatory texts, you may want to specified the column width for different column, since the auto adjust in HTML may not work in its best way while basic LaTeX table is really bad at handling text wrapping. Also, sometimes, you may want to highlight a column (e.g. a "Total" column) by making it bold. In these scenario, you can use `column_spec()`. You can find an example below.
Warning: If you have a super long table, you should be cautious when you use `column_spec` as the xml node modification takes time.
@@ -139,8 +139,8 @@
```{r}
kable(dt, "html") %>%
kable_styling("striped", full_width = F) %>%
- column_spec(7, bold = T) %>%
- row_spec(5, bold = T, color = "white", background = "#D7261E")
+ column_spec(5:7, bold = T) %>%
+ row_spec(3:5, bold = T, color = "white", background = "#D7261E")
```
# Grouped Columns / Rows
@@ -170,6 +170,14 @@
group_rows("Group 2", 8, 10)
```
+Another way to use `group_rows` is to provide an grouping index, similar with `add_header_above()`. This feature is only available in kableExtra > 0.5.2.
+```{r, eval = F}
+# Not evaluated. This example generates the same table as above.
+kable(mtcars[1:10, 1:6], "html", caption = "Group Rows") %>%
+ kable_styling("striped", full_width = F) %>%
+ group_rows(index = c(" " = 3, "Group 1" = 4, "Group 2" = 3))
+```
+
For advanced users, you can even define your own css for the group labeling.
```{r}
kable(dt, "html") %>%
@@ -249,4 +257,3 @@
kable_styling() %>%
scroll_box(width = "500px", height = "200px")
```
-
diff --git a/docs/awesome_table_in_html.html b/docs/awesome_table_in_html.html
index 3b0c3ad..6e80212 100644
--- a/docs/awesome_table_in_html.html
+++ b/docs/awesome_table_in_html.html
@@ -11,7 +11,7 @@
<meta name="author" content="Hao Zhu" />
-<meta name="date" content="2017-09-13" />
+<meta name="date" content="2017-09-15" />
<title>Create Awesome HTML Table with knitr::kable and kableExtra</title>
@@ -217,7 +217,7 @@
<h1 class="title toc-ignore">Create Awesome HTML Table with knitr::kable and kableExtra</h1>
<h4 class="author"><em>Hao Zhu</em></h4>
-<h4 class="date"><em>2017-09-13</em></h4>
+<h4 class="date"><em>2017-09-15</em></h4>
</div>
@@ -1650,8 +1650,8 @@
<p>Similar with <code>column_spec</code>, you can define specifications for rows. Currently, you can either bold or italiciz an entire row. Note that, similar with other row-related functions in <code>kableExtra</code>, for the position of the target row, you don’t need to count in header rows or the group labelling rows.</p>
<pre class="r"><code>kable(dt, "html") %>%
kable_styling("striped", full_width = F) %>%
- column_spec(7, bold = T) %>%
- row_spec(5, bold = T, color = "white", background = "#D7261E")</code></pre>
+ column_spec(5:7, bold = T) %>%
+ row_spec(3:5, bold = T, color = "white", background = "#D7261E")</code></pre>
<table class="table table-striped" style="width: auto !important; margin-left: auto; margin-right: auto;">
<thead>
<tr>
@@ -1691,10 +1691,10 @@
<td style="text-align:right;">
160
</td>
-<td style="text-align:right;">
+<td style="text-align:right;font-weight: bold;">
110
</td>
-<td style="text-align:right;">
+<td style="text-align:right;font-weight: bold;">
3.90
</td>
<td style="text-align:right;font-weight: bold;">
@@ -1714,10 +1714,10 @@
<td style="text-align:right;">
160
</td>
-<td style="text-align:right;">
+<td style="text-align:right;font-weight: bold;">
110
</td>
-<td style="text-align:right;">
+<td style="text-align:right;font-weight: bold;">
3.90
</td>
<td style="text-align:right;font-weight: bold;">
@@ -1725,48 +1725,48 @@
</td>
</tr>
<tr>
-<td style="text-align:left;">
+<td style="text-align:left;font-weight: bold;color: white;background-color: #D7261E;">
Datsun 710
</td>
-<td style="text-align:right;">
+<td style="text-align:right;font-weight: bold;color: white;background-color: #D7261E;">
22.8
</td>
-<td style="text-align:right;">
+<td style="text-align:right;font-weight: bold;color: white;background-color: #D7261E;">
4
</td>
-<td style="text-align:right;">
+<td style="text-align:right;font-weight: bold;color: white;background-color: #D7261E;">
108
</td>
-<td style="text-align:right;">
+<td style="text-align:right;font-weight: bold;font-weight: bold;color: white;background-color: #D7261E;">
93
</td>
-<td style="text-align:right;">
+<td style="text-align:right;font-weight: bold;font-weight: bold;color: white;background-color: #D7261E;">
3.85
</td>
-<td style="text-align:right;font-weight: bold;">
+<td style="text-align:right;font-weight: bold;font-weight: bold;color: white;background-color: #D7261E;">
2.320
</td>
</tr>
<tr>
-<td style="text-align:left;">
+<td style="text-align:left;font-weight: bold;color: white;background-color: #D7261E;">
Hornet 4 Drive
</td>
-<td style="text-align:right;">
+<td style="text-align:right;font-weight: bold;color: white;background-color: #D7261E;">
21.4
</td>
-<td style="text-align:right;">
+<td style="text-align:right;font-weight: bold;color: white;background-color: #D7261E;">
6
</td>
-<td style="text-align:right;">
+<td style="text-align:right;font-weight: bold;color: white;background-color: #D7261E;">
258
</td>
-<td style="text-align:right;">
+<td style="text-align:right;font-weight: bold;font-weight: bold;color: white;background-color: #D7261E;">
110
</td>
-<td style="text-align:right;">
+<td style="text-align:right;font-weight: bold;font-weight: bold;color: white;background-color: #D7261E;">
3.08
</td>
-<td style="text-align:right;font-weight: bold;">
+<td style="text-align:right;font-weight: bold;font-weight: bold;color: white;background-color: #D7261E;">
3.215
</td>
</tr>
@@ -1783,10 +1783,10 @@
<td style="text-align:right;font-weight: bold;color: white;background-color: #D7261E;">
360
</td>
-<td style="text-align:right;font-weight: bold;color: white;background-color: #D7261E;">
+<td style="text-align:right;font-weight: bold;font-weight: bold;color: white;background-color: #D7261E;">
175
</td>
-<td style="text-align:right;font-weight: bold;color: white;background-color: #D7261E;">
+<td style="text-align:right;font-weight: bold;font-weight: bold;color: white;background-color: #D7261E;">
3.15
</td>
<td style="text-align:right;font-weight: bold;font-weight: bold;color: white;background-color: #D7261E;">
@@ -2437,6 +2437,11 @@
</tr>
</tbody>
</table>
+<p>Another way to use <code>group_rows</code> is to provide an grouping index, similar with <code>add_header_above()</code>. This feature is only available in kableExtra > 0.5.2.</p>
+<pre class="r"><code># Not evaluated. This example generates the same table as above.
+kable(mtcars[1:10, 1:6], "html", caption = "Group Rows") %>%
+ kable_styling("striped", full_width = F) %>%
+ group_rows(index = c(" " = 3, "Group 1" = 4, "Group 2" = 3))</code></pre>
<p>For advanced users, you can even define your own css for the group labeling.</p>
<pre class="r"><code>kable(dt, "html") %>%
kable_styling("striped", full_width = F) %>%
@@ -2796,7 +2801,7 @@
3
</td>
<td style="text-align:center;">
-0
+1
</td>
</tr>
<tr>
@@ -2804,7 +2809,7 @@
4
</td>
<td style="text-align:center;">
-1
+0
</td>
</tr>
<tr>
@@ -2828,7 +2833,7 @@
7
</td>
<td style="text-align:center;">
-1
+0
</td>
</tr>
<tr>
@@ -2855,7 +2860,7 @@
10
</td>
<td style="text-align:center;">
-1
+0
</td>
</tr>
<tr>
@@ -2877,7 +2882,7 @@
12
</td>
<td style="text-align:center;">
-1
+0
</td>
</tr>
<tr>
@@ -2888,7 +2893,7 @@
13
</td>
<td style="text-align:center;">
-1
+0
</td>
</tr>
<tr>
@@ -2896,7 +2901,7 @@
14
</td>
<td style="text-align:center;">
-0
+1
</td>
</tr>
<tr>
@@ -2904,7 +2909,7 @@
15
</td>
<td style="text-align:center;">
-0
+1
</td>
</tr>
</tbody>
diff --git a/docs/awesome_table_in_pdf.Rmd b/docs/awesome_table_in_pdf.Rmd
index 9a55b87..2d37e1b 100644
--- a/docs/awesome_table_in_pdf.Rmd
+++ b/docs/awesome_table_in_pdf.Rmd
@@ -65,7 +65,7 @@
library(kableExtra)
```
-If you are using R Sweave or some customized rmarkdown templates or you just want to load these LaTeX libraries by yourself, you can put the following meta data into the `yaml` section. If you are familar with LaTeX and you know what you are doing, feel free to remove unnecessary packages from the list.
+If you are using R Sweave, beamer, tufte or some customized rmarkdown templates, you can put the following meta data into the `yaml` section. If you are familar with LaTeX and you know what you are doing, feel free to remove unnecessary packages from the list.
```{yaml}
header-includes:
@@ -317,3 +317,20 @@
group_rows("Group 1", 4, 5) %>%
landscape()
```
+
+## Use LaTeX table in HTML or Word
+If you want to include a LaTeX rendered table in your HTML or Word document, or if you just want to save table as an image, you may consider to use `kable_as_image()`. Note that this feature requires you to have [magick](https://github.com/ropensci/magick) installed (`install.packages("magick")`). Also, if you are planning to use it on Windows, you need to install [Ghostscript](https://www.ghostscript.com/).
+
+```{r, eval = F}
+# Not evaluated.
+
+# The code below will automatically include the image in the rmarkdown document
+kable(dt, "latex", booktabs = T) %>%
+ column_spec(1, bold = T) %>%
+ kable_as_image()
+
+# If you want to save the image locally, just provide a name
+kable(dt, "latex", booktabs = T) %>%
+ column_spec(1, bold = T) %>%
+ kable_as_image("my_latex_table")
+```
diff --git a/docs/awesome_table_in_pdf.pdf b/docs/awesome_table_in_pdf.pdf
index 79c240e..666ff35 100644
--- a/docs/awesome_table_in_pdf.pdf
+++ b/docs/awesome_table_in_pdf.pdf
Binary files differ