minor changes
diff --git a/docs/bookdown/02-bootstrap_in_gitbook.md b/docs/bookdown/02-bootstrap_in_gitbook.md
index 8028195..889b363 100644
--- a/docs/bookdown/02-bootstrap_in_gitbook.md
+++ b/docs/bookdown/02-bootstrap_in_gitbook.md
@@ -11,7 +11,7 @@
mtcars[1:5, 1:5] %>%
kable(booktabs = T) %>%
kable_styling(
- bootstrap_options = c("striped","hover", "bordered"),
+ bootstrap_options = c("striped","hover", "bordered", "condensed"),
latex_options = c("striped"),
full_width = F
) %>%
@@ -19,7 +19,7 @@
add_header_above(c(" ", "Group A" = 2, "Group B" = 3))
```
-<table class="table table-striped table-hover table-bordered" style="width: auto !important; margin-left: auto; margin-right: auto;">
+<table class="table table-striped table-hover table-bordered table-condensed" style="width: auto !important; margin-left: auto; margin-right: auto;">
<thead>
<tr>
<th style="border-bottom:hidden" colspan="1"></th>
diff --git a/docs/bookdown/bookdown_example.epub b/docs/bookdown/bookdown_example.epub
index 650f35e..eb1acf1 100644
--- a/docs/bookdown/bookdown_example.epub
+++ b/docs/bookdown/bookdown_example.epub
Binary files differ
diff --git a/docs/bookdown/bookdown_example.pdf b/docs/bookdown/bookdown_example.pdf
index cc1ef8c..c9cafb4 100644
--- a/docs/bookdown/bookdown_example.pdf
+++ b/docs/bookdown/bookdown_example.pdf
Binary files differ
diff --git a/docs/bookdown/bookdown_example.tex b/docs/bookdown/bookdown_example.tex
index 8ddc0f0..cc2ec9b 100644
--- a/docs/bookdown/bookdown_example.tex
+++ b/docs/bookdown/bookdown_example.tex
@@ -24,7 +24,7 @@
\usepackage[margin=1in]{geometry}
\usepackage{hyperref}
\hypersetup{unicode=true,
- pdftitle={Using kableExtra in Bookdown Projects},
+ pdftitle={Using kableExtra in Bookdown},
pdfauthor={Hao Zhu},
pdfborder={0 0 0},
breaklinks=true}
@@ -117,7 +117,7 @@
\setlength{\droptitle}{-2em}
- \title{Using kableExtra in Bookdown Projects}
+ \title{Using kableExtra in Bookdown}
\pretitle{\vspace{\droptitle}\centering\huge}
\posttitle{\par}
\author{Hao Zhu}
@@ -164,6 +164,9 @@
This book is hosted at
\url{https://github.com/haozhu233/kableExtra/tree/master/docs}.
+You can download PDF \& EPUB to see the results of kableExtra in those
+formats using the same code.
+
You can find the source code for this project at
\url{https://github.com/haozhu233/kableExtra/tree/master/docs}.
@@ -281,7 +284,7 @@
\NormalTok{mtcars[}\DecValTok{1}\OperatorTok{:}\DecValTok{5}\NormalTok{, }\DecValTok{1}\OperatorTok{:}\DecValTok{5}\NormalTok{] }\OperatorTok{%>%}
\StringTok{ }\KeywordTok{kable}\NormalTok{(}\DataTypeTok{booktabs =}\NormalTok{ T) }\OperatorTok{%>%}\StringTok{ }
\StringTok{ }\KeywordTok{kable_styling}\NormalTok{(}
- \DataTypeTok{bootstrap_options =} \KeywordTok{c}\NormalTok{(}\StringTok{"striped"}\NormalTok{,}\StringTok{"hover"}\NormalTok{, }\StringTok{"bordered"}\NormalTok{),}
+ \DataTypeTok{bootstrap_options =} \KeywordTok{c}\NormalTok{(}\StringTok{"striped"}\NormalTok{,}\StringTok{"hover"}\NormalTok{, }\StringTok{"bordered"}\NormalTok{, }\StringTok{"condensed"}\NormalTok{),}
\DataTypeTok{latex_options =} \KeywordTok{c}\NormalTok{(}\StringTok{"striped"}\NormalTok{),}
\DataTypeTok{full_width =}\NormalTok{ F}
\NormalTok{ ) }\OperatorTok{%>%}
diff --git a/docs/bookdown/cross-format-tables-in-bookdown.html b/docs/bookdown/cross-format-tables-in-bookdown.html
index c45999e..e96c0d3 100644
--- a/docs/bookdown/cross-format-tables-in-bookdown.html
+++ b/docs/bookdown/cross-format-tables-in-bookdown.html
@@ -5,11 +5,11 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
- <title>Using kableExtra in Bookdown Projects</title>
+ <title>Using kableExtra in Bookdown</title>
<meta name="description" content="This example provides documentations for using kableExtra to customize tables in bookdown projects.">
<meta name="generator" content="bookdown and GitBook 2.6.7">
- <meta property="og:title" content="Using kableExtra in Bookdown Projects" />
+ <meta property="og:title" content="Using kableExtra in Bookdown" />
<meta property="og:type" content="book" />
@@ -17,7 +17,7 @@
<meta name="twitter:card" content="summary" />
- <meta name="twitter:title" content="Using kableExtra in Bookdown Projects" />
+ <meta name="twitter:title" content="Using kableExtra in Bookdown" />
<meta name="twitter:description" content="This example provides documentations for using kableExtra to customize tables in bookdown projects." />
@@ -147,7 +147,7 @@
<div class="body-inner">
<div class="book-header" role="navigation">
<h1>
- <i class="fa fa-circle-o-notch fa-spin"></i><a href="./">Using kableExtra in Bookdown Projects</a>
+ <i class="fa fa-circle-o-notch fa-spin"></i><a href="./">Using kableExtra in Bookdown</a>
</h1>
</div>
diff --git a/docs/bookdown/index.html b/docs/bookdown/index.html
index e510547..4e6f8cf 100644
--- a/docs/bookdown/index.html
+++ b/docs/bookdown/index.html
@@ -5,11 +5,11 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
- <title>Using kableExtra in Bookdown Projects</title>
+ <title>Using kableExtra in Bookdown</title>
<meta name="description" content="This example provides documentations for using kableExtra to customize tables in bookdown projects.">
<meta name="generator" content="bookdown and GitBook 2.6.7">
- <meta property="og:title" content="Using kableExtra in Bookdown Projects" />
+ <meta property="og:title" content="Using kableExtra in Bookdown" />
<meta property="og:type" content="book" />
@@ -17,7 +17,7 @@
<meta name="twitter:card" content="summary" />
- <meta name="twitter:title" content="Using kableExtra in Bookdown Projects" />
+ <meta name="twitter:title" content="Using kableExtra in Bookdown" />
<meta name="twitter:description" content="This example provides documentations for using kableExtra to customize tables in bookdown projects." />
@@ -147,7 +147,7 @@
<div class="body-inner">
<div class="book-header" role="navigation">
<h1>
- <i class="fa fa-circle-o-notch fa-spin"></i><a href="./">Using kableExtra in Bookdown Projects</a>
+ <i class="fa fa-circle-o-notch fa-spin"></i><a href="./">Using kableExtra in Bookdown</a>
</h1>
</div>
@@ -156,7 +156,7 @@
<section class="normal" id="section-">
<div id="header">
-<h1 class="title">Using kableExtra in Bookdown Projects</h1>
+<h1 class="title">Using kableExtra in Bookdown</h1>
<p class="author"><em>Hao Zhu</em></p>
<p class="date"><em>2018-10-03</em></p>
</div>
@@ -164,6 +164,7 @@
<h1><span class="header-section-number">Chapter 1</span> Introduction</h1>
<p>If you have tried to use <code>kableExtra</code> in a <code>bookdown</code> project with mutltiple formats, you may have experienced some problems. For example, you might not be able to render HTML and PDF tables at the same time using the same piece of code. At the same time, you might start to wonder if it’s possible to create <code>bootstrap</code> style tables in <code>gitbook</code>. I will try to address these issues using this example.</p>
<p>This book is hosted at <a href="https://github.com/haozhu233/kableExtra/tree/master/docs" class="uri">https://github.com/haozhu233/kableExtra/tree/master/docs</a>.</p>
+<p>You can download PDF & EPUB to see the results of kableExtra in those formats using the same code.</p>
<p>You can find the source code for this project at <a href="https://github.com/haozhu233/kableExtra/tree/master/docs" class="uri">https://github.com/haozhu233/kableExtra/tree/master/docs</a>.</p>
</div>
diff --git a/docs/bookdown/index.md b/docs/bookdown/index.md
index feed0b4..458655c 100644
--- a/docs/bookdown/index.md
+++ b/docs/bookdown/index.md
@@ -1,5 +1,5 @@
---
-title: "Using kableExtra in Bookdown Projects"
+title: "Using kableExtra in Bookdown"
author: "Hao Zhu"
date: "2018-10-03"
site: bookdown::bookdown_site
@@ -16,4 +16,6 @@
This book is hosted at https://github.com/haozhu233/kableExtra/tree/master/docs.
+You can download PDF & EPUB to see the results of kableExtra in those formats using the same code.
+
You can find the source code for this project at https://github.com/haozhu233/kableExtra/tree/master/docs.
diff --git a/docs/bookdown/search_index.json b/docs/bookdown/search_index.json
index e4f0e72..a527703 100644
--- a/docs/bookdown/search_index.json
+++ b/docs/bookdown/search_index.json
@@ -1,5 +1,5 @@
[
-["index.html", "Using kableExtra in Bookdown Projects Chapter 1 Introduction", " Using kableExtra in Bookdown Projects Hao Zhu 2018-10-03 Chapter 1 Introduction If you have tried to use kableExtra in a bookdown project with mutltiple formats, you may have experienced some problems. For example, you might not be able to render HTML and PDF tables at the same time using the same piece of code. At the same time, you might start to wonder if it’s possible to create bootstrap style tables in gitbook. I will try to address these issues using this example. This book is hosted at https://github.com/haozhu233/kableExtra/tree/master/docs. You can find the source code for this project at https://github.com/haozhu233/kableExtra/tree/master/docs. "],
+["index.html", "Using kableExtra in Bookdown Chapter 1 Introduction", " Using kableExtra in Bookdown Hao Zhu 2018-10-03 Chapter 1 Introduction If you have tried to use kableExtra in a bookdown project with mutltiple formats, you may have experienced some problems. For example, you might not be able to render HTML and PDF tables at the same time using the same piece of code. At the same time, you might start to wonder if it’s possible to create bootstrap style tables in gitbook. I will try to address these issues using this example. This book is hosted at https://github.com/haozhu233/kableExtra/tree/master/docs. You can download PDF & EPUB to see the results of kableExtra in those formats using the same code. You can find the source code for this project at https://github.com/haozhu233/kableExtra/tree/master/docs. "],
["cross-format-tables-in-bookdown.html", "Chapter 2 Cross-format Tables in Bookdown 2.1 Use the “K-M” approach instead of “M-K” 2.2 Prepare Your Tables for Both Formats", " Chapter 2 Cross-format Tables in Bookdown Note that if kableExtra 0.9.0 doesn’t support the EPUB format. If you need to output tables in .epub, please upgrade to the dev version or version 1.0 on CRAN once it’s released. 2.1 Use the “K-M” approach instead of “M-K” Please read this chapter about the “K-M”/“M-K” approaches in bookdown: https://bookdown.org/yihui/bookdown/new-session.html To generate cross-format tables with kableExtra in a multi-format bookdown project, you will have to use the “M-K” approach by setting new_session: true in _bookdown.yml. Somehow the “M-K” approach, which merges chapters to a big Rmd and then renders, shares the global environment across formats. For now, I’m not sure if this is a bug or intended behavior. It might be fixable in the future but please don’t count on that. By setting new_session: true, we force R to use a new session for every chapter for different formats. In this way, tables are generated differently in different formats. Note that the “M-K” approach is slower than the “K-M” approach. At the same time, packages and data are not shared accross chapter. # Example _bookdown.yml book_filename: "bookdown_example" delete_merged_file: true new_session: true language: ui: chapter_name: "Chapter " 2.2 Prepare Your Tables for Both Formats In most cases, functions in kable and kableExtra use the same API to accomplish the same styling task in HTML and LaTeX. However, you also need some format specific settings so your tables will look good in both formats. Some common items here include the booktabs and longtable settings in kable and the bootstrap_options and latex_options in kable_styling. Here is an example for a table that will work in both HTML and LaTeX. library(kableExtra) mtcars[1:5, 1:5] %>% kable(booktabs = T) %>% kable_styling( latex_options = c("striped"), full_width = F ) %>% column_spec(1, bold = T) %>% add_header_above(c(" ", "Group A" = 2, "Group B" = 3)) Group A Group B mpg cyl disp hp drat Mazda RX4 21.0 6 160 110 3.90 Mazda RX4 Wag 21.0 6 160 110 3.90 Datsun 710 22.8 4 108 93 3.85 Hornet 4 Drive 21.4 6 258 110 3.08 Hornet Sportabout 18.7 8 360 175 3.15 "],
-["use-bootstrap-tables-in-gitbooks-epub.html", "Chapter 3 Use Bootstrap Tables in gitbooks & epub 3.1 Gitbook 3.2 Epub", " Chapter 3 Use Bootstrap Tables in gitbooks & epub 3.1 Gitbook Most of kableExtra tricks will work in bookdown except those requires bootstrap. By default, rmarkdown won’t load bootstrap for you on gitbook as it’s not necesary. In kableExtra, I used the bootstrap 3.3.7 customization tool and made a customized css copy. You can load it by setting options(kableExtra.html.bsTable = T). library(kableExtra) options(kableExtra.html.bsTable = T) mtcars[1:5, 1:5] %>% kable(booktabs = T) %>% kable_styling( bootstrap_options = c("striped","hover", "bordered"), latex_options = c("striped"), full_width = F ) %>% column_spec(1, color = "red") %>% add_header_above(c(" ", "Group A" = 2, "Group B" = 3)) Group A Group B mpg cyl disp hp drat Mazda RX4 21.0 6 160 110 3.90 Mazda RX4 Wag 21.0 6 160 110 3.90 Datsun 710 22.8 4 108 93 3.85 Hornet 4 Drive 21.4 6 258 110 3.08 Hornet Sportabout 18.7 8 360 175 3.15 However, very unfortunately, as we can see, the hover part is not working and the table still looks different from a regular bootstrap table. The reason is that gitbook defines its own way to style tables and some of its rules are conflicting with the one defined in bootstrap. For css, it’s like once you load something, it’s impossible to really unload it. As a result, unless there are some changes in bookdown (for example, we can replace the gitbook table part with bootstrap tables), there is nothing we can do here. 3.2 Epub Right now, it’s impossible to load addition CSS through HTML dependency (due to a setting in rmarkdown). I will file an issue in rmarkdown and see if this is something that can be changed. In the mean time, to use bootstrap tables in Epub, you will have to manually load this stylesheet by putting it to a CSS file (such as “style.css”) and load it in _output.yml. For example, bookdown::epub_book: stylesheet: style.css "]
+["use-bootstrap-tables-in-gitbooks-epub.html", "Chapter 3 Use Bootstrap Tables in gitbooks & epub 3.1 Gitbook 3.2 Epub", " Chapter 3 Use Bootstrap Tables in gitbooks & epub 3.1 Gitbook Most of kableExtra tricks will work in bookdown except those requires bootstrap. By default, rmarkdown won’t load bootstrap for you on gitbook as it’s not necesary. In kableExtra, I used the bootstrap 3.3.7 customization tool and made a customized css copy. You can load it by setting options(kableExtra.html.bsTable = T). library(kableExtra) options(kableExtra.html.bsTable = T) mtcars[1:5, 1:5] %>% kable(booktabs = T) %>% kable_styling( bootstrap_options = c("striped","hover", "bordered", "condensed"), latex_options = c("striped"), full_width = F ) %>% column_spec(1, color = "red") %>% add_header_above(c(" ", "Group A" = 2, "Group B" = 3)) Group A Group B mpg cyl disp hp drat Mazda RX4 21.0 6 160 110 3.90 Mazda RX4 Wag 21.0 6 160 110 3.90 Datsun 710 22.8 4 108 93 3.85 Hornet 4 Drive 21.4 6 258 110 3.08 Hornet Sportabout 18.7 8 360 175 3.15 However, very unfortunately, as we can see, the hover part is not working and the table still looks different from a regular bootstrap table. The reason is that gitbook defines its own way to style tables and some of its rules are conflicting with the one defined in bootstrap. For css, it’s like once you load something, it’s impossible to really unload it. As a result, unless there are some changes in bookdown (for example, we can replace the gitbook table part with bootstrap tables), there is nothing we can do here. 3.2 Epub Right now, it’s impossible to load addition CSS through HTML dependency (due to a setting in rmarkdown). I will file an issue in rmarkdown and see if this is something that can be changed. In the mean time, to use bootstrap tables in Epub, you will have to manually load this stylesheet by putting it to a CSS file (such as “style.css”) and load it in _output.yml. For example, bookdown::epub_book: stylesheet: style.css "]
]
diff --git a/docs/bookdown/use-bootstrap-tables-in-gitbooks-epub.html b/docs/bookdown/use-bootstrap-tables-in-gitbooks-epub.html
index ea4a602..baf46b8 100644
--- a/docs/bookdown/use-bootstrap-tables-in-gitbooks-epub.html
+++ b/docs/bookdown/use-bootstrap-tables-in-gitbooks-epub.html
@@ -5,11 +5,11 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
- <title>Using kableExtra in Bookdown Projects</title>
+ <title>Using kableExtra in Bookdown</title>
<meta name="description" content="This example provides documentations for using kableExtra to customize tables in bookdown projects.">
<meta name="generator" content="bookdown and GitBook 2.6.7">
- <meta property="og:title" content="Using kableExtra in Bookdown Projects" />
+ <meta property="og:title" content="Using kableExtra in Bookdown" />
<meta property="og:type" content="book" />
@@ -17,7 +17,7 @@
<meta name="twitter:card" content="summary" />
- <meta name="twitter:title" content="Using kableExtra in Bookdown Projects" />
+ <meta name="twitter:title" content="Using kableExtra in Bookdown" />
<meta name="twitter:description" content="This example provides documentations for using kableExtra to customize tables in bookdown projects." />
@@ -147,7 +147,7 @@
<div class="body-inner">
<div class="book-header" role="navigation">
<h1>
- <i class="fa fa-circle-o-notch fa-spin"></i><a href="./">Using kableExtra in Bookdown Projects</a>
+ <i class="fa fa-circle-o-notch fa-spin"></i><a href="./">Using kableExtra in Bookdown</a>
</h1>
</div>
@@ -166,13 +166,13 @@
mtcars[<span class="dv">1</span><span class="op">:</span><span class="dv">5</span>, <span class="dv">1</span><span class="op">:</span><span class="dv">5</span>] <span class="op">%>%</span>
<span class="st"> </span><span class="kw">kable</span>(<span class="dt">booktabs =</span> T) <span class="op">%>%</span><span class="st"> </span>
<span class="st"> </span><span class="kw">kable_styling</span>(
- <span class="dt">bootstrap_options =</span> <span class="kw">c</span>(<span class="st">"striped"</span>,<span class="st">"hover"</span>, <span class="st">"bordered"</span>),
+ <span class="dt">bootstrap_options =</span> <span class="kw">c</span>(<span class="st">"striped"</span>,<span class="st">"hover"</span>, <span class="st">"bordered"</span>, <span class="st">"condensed"</span>),
<span class="dt">latex_options =</span> <span class="kw">c</span>(<span class="st">"striped"</span>),
<span class="dt">full_width =</span> F
) <span class="op">%>%</span>
<span class="st"> </span><span class="kw">column_spec</span>(<span class="dv">1</span>, <span class="dt">color =</span> <span class="st">"red"</span>) <span class="op">%>%</span>
<span class="st"> </span><span class="kw">add_header_above</span>(<span class="kw">c</span>(<span class="st">" "</span>, <span class="st">"Group A"</span> =<span class="st"> </span><span class="dv">2</span>, <span class="st">"Group B"</span> =<span class="st"> </span><span class="dv">3</span>))</code></pre>
-<table class="table table-striped table-hover table-bordered" style="width: auto !important; margin-left: auto; margin-right: auto;">
+<table class="table table-striped table-hover table-bordered table-condensed" style="width: auto !important; margin-left: auto; margin-right: auto;">
<thead>
<tr>
<th style="border-bottom:hidden" colspan="1">
diff --git a/docs/bookdown_example/02-bootstrap_in_gitbook.Rmd b/docs/bookdown_example/02-bootstrap_in_gitbook.Rmd
index 796f910..63a6ca1 100644
--- a/docs/bookdown_example/02-bootstrap_in_gitbook.Rmd
+++ b/docs/bookdown_example/02-bootstrap_in_gitbook.Rmd
@@ -10,7 +10,7 @@
mtcars[1:5, 1:5] %>%
kable(booktabs = T) %>%
kable_styling(
- bootstrap_options = c("striped","hover", "bordered"),
+ bootstrap_options = c("striped","hover", "bordered", "condensed"),
latex_options = c("striped"),
full_width = F
) %>%
diff --git a/docs/bookdown_example/index.Rmd b/docs/bookdown_example/index.Rmd
index 6be41f7..2f73ca8 100644
--- a/docs/bookdown_example/index.Rmd
+++ b/docs/bookdown_example/index.Rmd
@@ -1,5 +1,5 @@
---
-title: "Using kableExtra in Bookdown Projects"
+title: "Using kableExtra in Bookdown"
author: "Hao Zhu"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
@@ -16,4 +16,6 @@
This book is hosted at https://github.com/haozhu233/kableExtra/tree/master/docs.
+You can download PDF & EPUB to see the results of kableExtra in those formats using the same code.
+
You can find the source code for this project at https://github.com/haozhu233/kableExtra/tree/master/docs.