extra changes for footnote with threeparttable
diff --git a/docs/awesome_table_in_html.html b/docs/awesome_table_in_html.html
index 488610d..e6c75b3 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="2018-01-16" />
+<meta name="date" content="2018-03-26" />
<title>Create Awesome HTML Table with knitr::kable and kableExtra</title>
@@ -219,7 +219,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>2018-01-16</em></h4>
+<h4 class="date"><em>2018-03-26</em></h4>
</div>
@@ -243,9 +243,8 @@
<div id="getting-started" class="section level1">
<h1>Getting Started</h1>
<p>Here we are using the first few columns and rows from dataset <code>mtcars</code></p>
-<pre class="r"><code>library(knitr)</code></pre>
-<pre><code>## Warning: package 'knitr' was built under R version 3.4.3</code></pre>
-<pre class="r"><code>library(kableExtra)
+<pre class="r"><code>library(knitr)
+library(kableExtra)
dt <- mtcars[1:5, 1:6]</code></pre>
<p>When you are using <code>kable()</code>, if you don’t specify <code>format</code>, by default it will generate a markdown table and let pandoc handle the conversion from markdown to HTML/PDF. This is the most favorable approach to render most simple tables as it is format independent. If you switch from HTML to pdf, you basically don’t need to change anything in your code. However, markdown doesn’t support complex table. For example, if you want to have a double-row header table, markdown just cannot provide you the functionality you need. As a result, when you have such a need, you should <strong>define <code>format</code> in <code>kable()</code></strong> as either “html” or “latex”. <em>You can also define a global option at the beginning using <code>options(knitr.table.format = "html")</code> so you don’t repeat the step everytime.</em> <strong>In this tutorial, I’ll still put <code>format="html"</code> in the function in case users just want to quickly replicate the results.</strong></p>
<pre class="r"><code>options(knitr.table.format = "html")
@@ -2102,7 +2101,8 @@
<p>This package also comes with a few helper functions, including <code>spec_color</code>, <code>spec_font_size</code> & <code>spec_angle</code>. These functions can rescale continuous variables to certain scales. For example, function <code>spec_color</code> would map a continuous variable to any <a href="https://CRAN.R-project.org/package=viridisLite">viridis color palettes</a>. It offers a very visually impactful representation in a tabular format.</p>
<pre class="r"><code>iris[1:10, ] %>%
mutate_if(is.numeric, function(x) {
- cell_spec(x, "html", bold = T, color = spec_color(x, end = 0.9),
+ cell_spec(x, "html", bold = T,
+ color = spec_color(x, end = 0.9),
font_size = spec_font_size(x))
}) %>%
mutate(Species = cell_spec(
@@ -3125,7 +3125,7 @@
</td>
</tr>
<tr>
-<td style="text-align:left; padding-left: 2em;" indentLevel="1">
+<td style="text-align:left; padding-left: 2em;" indentlevel="1">
Merc 240D
</td>
<td style="text-align:right;">
@@ -3148,7 +3148,7 @@
</td>
</tr>
<tr>
-<td style="text-align:left; padding-left: 2em;" indentLevel="1">
+<td style="text-align:left; padding-left: 2em;" indentlevel="1">
Merc 230
</td>
<td style="text-align:right;">
@@ -3171,7 +3171,7 @@
</td>
</tr>
<tr>
-<td style="text-align:left; padding-left: 2em;" indentLevel="1">
+<td style="text-align:left; padding-left: 2em;" indentlevel="1">
Merc 280
</td>
<td style="text-align:right;">
@@ -3282,7 +3282,7 @@
</td>
</tr>
<tr>
-<td style="text-align:left; padding-left: 2em;" indentLevel="1">
+<td style="text-align:left; padding-left: 2em;" indentlevel="1">
Datsun 710
</td>
<td style="text-align:right;">
@@ -3305,7 +3305,7 @@
</td>
</tr>
<tr>
-<td style="text-align:left; padding-left: 2em;" indentLevel="1">
+<td style="text-align:left; padding-left: 2em;" indentlevel="1">
Hornet 4 Drive
</td>
<td style="text-align:right;">
@@ -3328,7 +3328,7 @@
</td>
</tr>
<tr>
-<td style="text-align:left; padding-left: 2em;" indentLevel="1">
+<td style="text-align:left; padding-left: 2em;" indentlevel="1">
Hornet Sportabout
</td>
<td style="text-align:right;">
@@ -3386,7 +3386,7 @@
</thead>
<tbody>
<tr>
-<td style="text-align:left; padding-left: 2em;" indentLevel="1">
+<td style="text-align:left; padding-left: 2em;" indentlevel="1">
Mazda RX4
</td>
<td style="text-align:right;">
@@ -3432,7 +3432,7 @@
</td>
</tr>
<tr>
-<td style="text-align:left; padding-left: 2em;" indentLevel="1">
+<td style="text-align:left; padding-left: 2em;" indentlevel="1">
Datsun 710
</td>
<td style="text-align:right;">
@@ -3478,7 +3478,7 @@
</td>
</tr>
<tr>
-<td style="text-align:left; padding-left: 2em;" indentLevel="1">
+<td style="text-align:left; padding-left: 2em;" indentlevel="1">
Hornet Sportabout
</td>
<td style="text-align:right;">
@@ -3559,7 +3559,7 @@
3
</td>
<td style="text-align:center;">
-1
+0
</td>
</tr>
<tr>
@@ -3567,7 +3567,7 @@
4
</td>
<td style="text-align:center;">
-1
+0
</td>
</tr>
<tr>
@@ -3575,7 +3575,7 @@
5
</td>
<td style="text-align:center;">
-0
+1
</td>
</tr>
<tr>
@@ -3583,7 +3583,7 @@
6
</td>
<td style="text-align:center;">
-0
+1
</td>
</tr>
<tr>
@@ -3591,7 +3591,7 @@
7
</td>
<td style="text-align:center;">
-0
+1
</td>
</tr>
<tr>
@@ -3602,7 +3602,7 @@
8
</td>
<td style="text-align:center;">
-1
+0
</td>
</tr>
<tr>
@@ -3618,7 +3618,7 @@
10
</td>
<td style="text-align:center;">
-1
+0
</td>
</tr>
<tr>
@@ -3640,7 +3640,7 @@
12
</td>
<td style="text-align:center;">
-1
+0
</td>
</tr>
<tr>
diff --git a/docs/awesome_table_in_pdf.Rmd b/docs/awesome_table_in_pdf.Rmd
index 2faba1b..8e7d092 100644
--- a/docs/awesome_table_in_pdf.Rmd
+++ b/docs/awesome_table_in_pdf.Rmd
@@ -318,6 +318,21 @@
# Not evaluated. The code above should have the same result as the first example in this section.
```
+Note that `kable` has a relatively special feature to handle `align` and it may bring troubles to you if you are not using it correctly. In the documentation of the `align` argument of `kable`, it says:
+
+> If `length(align) == 1L`, the string will be expanded to a vector of individual letters, e.g. `'clc'` becomes `c('c', 'l', 'c')`, **unless the output format is LaTeX**.
+
+For example,
+```{r, eval=F}
+kable(mtcars[1:2, 1:2], "latex", align = c("cl"))
+# \begin{tabular}{l|cl|cl} # Note the column alignment here
+# \hline
+# & mpg & cyl\\
+# ...
+```
+
+LaTeX, somehow shows surprisingly high tolerance on that, which is quite unusual. As a result, it won't throw an error if you are just using `kable` to make some simple tables. However, when you use `kableExtra` to make some advanced modification, it will start to throw some bugs. As a result, please try to form a habbit of using a vector in the `align` argument for `kable` (tip: you can use `rep` function to replicate elements. For example, `c("c", rep("l", 10))`).
+
## Row 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.
@@ -347,6 +362,8 @@
collapse_rows(1:2)
```
+
+
# Table Footnote
> Now it's recommended to use the new `footnote` function instead of `add_footnote` to make table footnotes.
@@ -396,6 +413,14 @@
footnote_as_chunk = T)
```
+If your table footnote is very long, please consider to put your table in a `ThreePartTable` frame. Note that, in kableExtra version <= 0.7.0, we were using `threeparttable` but since kableExtra 0.8.0, we start to use `ThreePartTable` from `threeparttablex` instead. `ThreePartTable` supports both the `longtable` and `tabu` environments.
+
+```{r}
+kable(dt, "latex", align = "c", booktabs = T, caption = "s") %>%
+ footnote(general = "Here is a very very very very very very very very very very very very very very very very very very very very long footnote",
+ threeparttable = T)
+```
+
# LaTeX Only Features
## 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.
diff --git a/docs/awesome_table_in_pdf.pdf b/docs/awesome_table_in_pdf.pdf
index 65a491b..3972244 100644
--- a/docs/awesome_table_in_pdf.pdf
+++ b/docs/awesome_table_in_pdf.pdf
Binary files differ