add add_header_left
diff --git a/R/add_header_above.R b/R/add_header_above.R
index 29ab6d7..39b6273 100644
--- a/R/add_header_above.R
+++ b/R/add_header_above.R
@@ -92,12 +92,23 @@
pdfTable_add_header_above <- function(kable_input, header = NULL) {
table_info <- magic_mirror(kable_input)
header <- standardize_header_input(header)
+ header$header <- escape_latex(header$header)
+ header$header <- gsub("\\\\", "\\\\\\\\", header$header)
hline_type <- switch(table_info$booktabs + 1, "\\\\hline", "\\\\toprule")
+ new_header_split <- pdfTable_new_header_generator(header, table_info$booktabs)
+ new_header <- paste0(new_header_split[1], "\n", new_header_split[2])
out <- sub(hline_type,
- paste0(hline_type, "\n",
- pdfTable_new_header_generator(header, table_info$booktabs)),
+ paste0(hline_type, "\n", new_header),
as.character(kable_input))
out <- structure(out, format = "latex", class = "knitr_kable")
+ # new_header_row <- latex_contents_escape(new_header_split[1])
+ if (is.null(table_info$new_header_row)) {
+ table_info$new_header_row <- new_header_split[1]
+ table_info$header_df <- list(header)
+ } else {
+ table_info$new_header_row <- c(table_info$new_header_row, new_header_split[1])
+ table_info$header_df[[length(table_info$header_df) + 1]] <- header
+ }
attr(out, "original_kable_meta") <- table_info
return(out)
}
@@ -115,6 +126,11 @@
paste0('\\\\multicolumn{', x[2], '}{', x[3], '}{', x[1], "}")
})
header_text <- paste(paste(header_items, collapse = " & "), "\\\\\\\\")
+ cline <- cline_gen(header_df, booktabs)
+ return(c(header_text, cline))
+}
+
+cline_gen <- function(header_df, booktabs) {
cline_end <- cumsum(header_df$colspan)
cline_start <- c(0, cline_end) + 1
cline_start <- cline_start[-length(cline_start)]
@@ -124,6 +140,7 @@
cline <- paste0(cline_type, cline_start, "-", cline_end, "}")
cline <- cline[trimws(header_df$header) != ""]
cline <- paste(cline, collapse = " ")
- header_text <- paste(header_text, cline)
- return(header_text)
+ return(cline)
}
+
+
diff --git a/R/add_header_left.R b/R/add_header_left.R
index b91a38c..6fa6971 100644
--- a/R/add_header_left.R
+++ b/R/add_header_left.R
@@ -3,7 +3,8 @@
#' @description Experimenting. Please don't use it in production
#'
#' @export
-add_header_left <- function(kable_input, header = NULL, header_name = "") {
+add_header_left <- function(kable_input, header = NULL, header_name = "",
+ align = "c") {
if (is.null(header)) return(kable_input)
kable_format <- attr(kable_input, "format")
if (!kable_format %in% c("html", "latex")) {
@@ -11,31 +12,33 @@
"generic markdown table using pandoc is not supported.")
}
if (kable_format == "html") {
- return(add_header_left_html(kable_input, header, header_name))
+ return(add_header_left_html(kable_input, header, header_name, align))
}
if (kable_format == "latex") {
- return(add_header_left_latex(kable_input, header, header_name))
+ return(add_header_left_latex(kable_input, header, header_name, align))
}
}
# HTML
-add_header_left_html <- function(kable_input, header, header_name) {
+add_header_left_html <- function(kable_input, header, header_name, align) {
kable_attrs <- attributes(kable_input)
kable_xml <- read_xml(as.character(kable_input), options = "COMPACT")
kable_thead <- xml_tpart(kable_xml, "thead")
kable_tbody <- xml_tpart(kable_xml, "tbody")
+ align <- switch(align, "c" = "center", "l" = "left", "r" = "right")
+
new_header <- paste0(
- '<th style="text-align:center;" rowspan="',
+ '<th style="text-align:', align, '; vertical-align: bottom;" rowspan="',
length(xml_children(kable_thead)), '">', header_name, '</th>'
)
new_header <- read_xml(new_header, options = c("COMPACT"))
xml_add_child(xml_child(kable_thead, 1), new_header, .where = 0)
- header <- standardize_rowheader_input(header, length(xml_children(kable_tbody)))
+ header <- standardize_header(header, length(xml_children(kable_tbody)))
for (i in 1:nrow(header)) {
new_row_item <- paste0(
- '<td style="text-align:center; vertical-align: middle;" rowspan="',
+ '<td style="text-align:', align, '; vertical-align: middle;" rowspan="',
header$rowspan[i], '">', header$header[i], '</td>')
new_row_item <- read_xml(new_row_item, options = "COMPACT")
target_row <- xml_child(kable_tbody, header$row[i])
@@ -48,7 +51,7 @@
return(out)
}
-standardize_rowheader_input <- function(header, n_row) {
+standardize_header <- function(header, n_row) {
header_names <- names(header)
if (is.null(header_names)) {
@@ -71,6 +74,100 @@
))
}
-add_header_left_latex <- function(kable_input, header, header_name) {
- return(kable_input)
+add_header_left_latex <- function(kable_input, header, header_name, align) {
+ table_info <- magic_mirror(kable_input)
+ usepackage_latex("multirow")
+ if (!table_info$booktabs) {
+ warning("add_header_left only supports LaTeX table with booktabs. Please",
+ " use kable(..., booktabs = T) in your kable function.")
+ }
+ out <- as.character(kable_input)
+ contents <- table_info$contents
+ header_name <- escape_latex(header_name)
+ header <- standardize_header(header, length(contents) - 1)
+ header$header <- escape_latex(header$header)
+ header$header <- gsub("\\\\", "\\\\\\\\", header$header)
+ header$row <- header$row + 1
+ header$row_end <- header$row + header$rowspan - 1
+
+ # Align
+ out <- sub(paste0(table_info$begin_tabular, "\\{"),
+ paste0(table_info$begin_tabular, "{", align,
+ ifelse(table_info$booktabs, "", "|")),
+ out, perl = T)
+
+ # Header
+ if (!is.null(table_info$new_header_row)) {
+ new_header_row <- table_info$new_header_row
+ for (i in 1:length(new_header_row)) {
+ out <- sub(regex_escape(new_header_row[i]),
+ paste0(" & ", new_header_row[i]), out)
+ cline_old <- cline_gen(table_info$header_df[[i]], table_info$booktabs)
+ cline_old <- regex_escape(cline_old)
+ table_info$header_df[[i]] <- rbind(
+ data.frame(header = " ", colspan = 1),
+ table_info$header_df[[i]]
+ )
+ cline_new <- cline_gen(table_info$header_df[[i]], table_info$booktabs)
+ out <- sub(cline_old, cline_new, out)
+ }
+ }
+ out <- sub(contents[1], paste0(header_name, " & ", contents[1]), out)
+ table_info$contents[1] <- paste0(header_name, " & ", contents[1])
+
+ # move existing midrules if exists
+ out_lines <- read_lines(out)
+ tbody_start_row <- which(out_lines == "\\midrule")
+ tbody_end_row <- which(out_lines == "\\bottomrule")
+ before_tbody <- out_lines[seq(1, tbody_start_row)]
+ tbody <- out_lines[seq(tbody_start_row + 1, tbody_end_row - 1)]
+ after_tbody <- out_lines[seq(tbody_end_row, length(out_lines))]
+
+ # Remove addlinespace in this case
+ tbody <- tbody[tbody != "\\addlinespace"]
+
+ midrule_exist <- str_sub(tbody, 1, 9) == "\\cmidrule"
+ if (sum(midrule_exist) > 0) {
+ existing_midrules <- which(midrule_exist)
+ tbody[existing_midrules] <- unlist(lapply(
+ tbody[existing_midrules], cmidrule_plus_one
+ ))
+ out <- paste0(c(before_tbody, tbody, after_tbody), collapse = "\n")
+ }
+
+ for (j in 1:nrow(header)) {
+ new_row_pre <- paste0(
+ "\\\\multirow\\{", -header$rowspan[j], "\\}\\{\\*\\}\\{", header$header[j], "\\} & "
+ )
+ new_row_text <- paste0(new_row_pre, contents[header$row_end[j]])
+ out <- sub(contents[header$row_end[j]], new_row_text, out)
+ table_info$contents[header$row_end[j]] <- new_row_text
+ if (j != nrow(header)) {
+ out <- sub(
+ paste0(contents[header$row_end[j]], "\\\\\\\\\n"),
+ paste0(contents[header$row_end[j]],
+ "\\\\\\\\\n\\\\cmidrule[0.5pt](l{2pt}r{2pt}){1-1}\n"),
+ out
+ )
+ }
+ }
+
+ for (k in setdiff(seq(2, length(contents)), header$row_end)) {
+ out <- sub(contents[k],
+ paste0(" & ", contents[k]),
+ out)
+ table_info$contents[k] <- paste0(" & ", contents[k])
+ }
+
+ out <- structure(out, format = "latex", class = "knitr_kable")
+ attr(out, "original_kable_meta") <- table_info
+ return(out)
+}
+
+cmidrule_plus_one <- function(x) {
+ start_pos <- as.numeric(str_match(x, "\\)\\{(.*)-")[2]) + 1
+ stop_pos <- as.numeric(str_match(x, "-(.*)\\}")[2]) + 1
+ return(
+ paste0("\\cmidrule[0.5pt](l{2pt}r{2pt}){", start_pos, "-", stop_pos, "}")
+ )
}
diff --git a/R/add_indent.R b/R/add_indent.R
index 3fc2837..ae3548f 100644
--- a/R/add_indent.R
+++ b/R/add_indent.R
@@ -39,12 +39,15 @@
for (i in positions) {
rowtext <- table_info$contents[i + 1]
out <- sub(rowtext, latex_indent_unit(rowtext), out, perl = TRUE)
+ table_info$contents[i + 1] <- latex_indent_unit(rowtext)
}
+ out <- structure(out, format = "latex", class = "knitr_kable")
+ attr(out, "original_kable_meta") <- table_info
return(out)
}
latex_indent_unit <- function(rowtext) {
- paste0("\\\\hspace{1em}", rowtext)
+ paste0("\\\\hspace\\{1em\\}", rowtext)
}
# Add indentation for HTML
diff --git a/R/magic_mirror.R b/R/magic_mirror.R
index 6276eae..d200a9d 100644
--- a/R/magic_mirror.R
+++ b/R/magic_mirror.R
@@ -71,7 +71,7 @@
)
# Contents
kable_info$contents <- str_match_all(kable_input, "\n(.*)\\\\\\\\")[[1]][,2]
- kable_info$contents <- latex_contents_escape(kable_info$contents)
+ kable_info$contents <- regex_escape(kable_info$contents, T)
if (kable_info$tabular == "longtable" & !is.na(kable_info$caption)) {
kable_info$contents <- kable_info$contents[-1]
}
@@ -87,15 +87,6 @@
return(kable_info)
}
-latex_contents_escape <- function(x) {
- x <- gsub("\\\\", "\\\\\\\\", x)
- x <- gsub("\\$", "\\\\\\$", x)
- x <- gsub("\\(", "\\\\(", x)
- x <- gsub("\\)", "\\\\)", x)
- x <- gsub("\\[", "\\\\]", x)
- x <- gsub("\\[", "\\\\]", x)
-}
-
#' Magic Mirror for html table --------
#'
#' @param kable_input The output of kable
diff --git a/R/util.R b/R/util.R
index a500879..802a56a 100644
--- a/R/util.R
+++ b/R/util.R
@@ -68,4 +68,18 @@
return(mapping_matrix)
}
+regex_escape <- function(x, double_backslash = FALSE) {
+ if (double_backslash) {
+ x <- gsub("\\\\", "\\\\\\\\", x)
+ }
+ x <- gsub("\\$", "\\\\\\$", x)
+ x <- gsub("\\(", "\\\\(", x)
+ x <- gsub("\\)", "\\\\)", x)
+ x <- gsub("\\[", "\\\\]", x)
+ x <- gsub("\\[", "\\\\]", x)
+ x <- gsub("\\{", "\\\\{", x)
+ x <- gsub("\\}", "\\\\}", x)
+ x <- gsub("\\*", "\\\\*", x)
+ return(x)
+}
diff --git a/docs/awesome_table_in_html.Rmd b/docs/awesome_table_in_html.Rmd
index 7f5e00d..14e5584 100644
--- a/docs/awesome_table_in_html.Rmd
+++ b/docs/awesome_table_in_html.Rmd
@@ -227,3 +227,14 @@
column_spec(7, bold = T) %>%
row_spec(5, bold = T)
```
+
+# Add header column to the left
+An alternative way of grouping rows is being added to `kableExtra` 0.3.0. Unlike `group_rows`, the new function `add_header_left` adopts a similar syntax with `add_header_above`. It allows users to add multiple layers of row groups, which is a limitation of `group_rows`. Currently, `add_header_left` in HTML is in good shape with exception that it doesn't work with `group_rows`.
+```{r}
+mtcars[1:10, 1:6] %>%
+ kable("html") %>%
+ kable_styling() %>%
+ add_header_above(c(" ", "Data 1" = 3, "Data 2" = 3)) %>%
+ add_header_left(c("Group A" = 3, "Group B" = 7), "Group") %>%
+ add_header_left(c("Team X" = 4, "Team Y" = 2, "Team Z" = 4), "Team")
+```
diff --git a/docs/awesome_table_in_html.html b/docs/awesome_table_in_html.html
index 983cb62..72832f9 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-06-14" />
+<meta name="date" content="2017-06-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-06-14</em></h4>
+<h4 class="date"><em>2017-06-15</em></h4>
</div>
@@ -3435,6 +3435,309 @@
</tbody>
</table>
</div>
+<div id="add-header-column-to-the-left" class="section level1">
+<h1>Add header column to the left</h1>
+<p>An alternative way of grouping rows is being added to <code>kableExtra</code> 0.3.0. Unlike <code>group_rows</code>, the new function <code>add_header_left</code> adopts a similar syntax with <code>add_header_above</code>. It allows users to add multiple layers of row groups, which is a limitation of <code>group_rows</code>. Currently, <code>add_header_left</code> in HTML is in good shape with exception that it doesn’t work with <code>group_rows</code>.</p>
+<pre class="r"><code>mtcars[1:10, 1:6] %>%
+ kable("html") %>%
+ kable_styling() %>%
+ add_header_above(c(" ", "Data 1" = 3, "Data 2" = 3)) %>%
+ add_header_left(c("Group A" = 3, "Group B" = 7), "Group") %>%
+ add_header_left(c("Team X" = 4, "Team Y" = 2, "Team Z" = 4), "Team") </code></pre>
+<?xml version="1.0" encoding="UTF-8" ?>
+<table class="table" style="margin-left: auto; margin-right: auto;">
+<thead>
+<tr>
+<th style="text-align:center; vertical-align: bottom;" rowspan="2">
+Team
+</th>
+<th style="text-align:center; vertical-align: bottom;" rowspan="2">
+Group
+</th>
+<th style="border-bottom:hidden"></th>
+<th style="text-align:center; border-bottom:hidden; padding-bottom:0; padding-left:3px;padding-right:3px;" colspan="3">
+<div style="border-bottom: 1px solid #ddd;padding-bottom: 5px;">
+Data 1
+</div>
+</th>
+<th style="text-align:center; border-bottom:hidden; padding-bottom:0; padding-left:3px;padding-right:3px;" colspan="3">
+<div style="border-bottom: 1px solid #ddd;padding-bottom: 5px;">
+Data 2
+</div>
+</th>
+</tr>
+<tr>
+<th style="text-align:left;">
+</th>
+<th style="text-align:right;">
+mpg
+</th>
+<th style="text-align:right;">
+cyl
+</th>
+<th style="text-align:right;">
+disp
+</th>
+<th style="text-align:right;">
+hp
+</th>
+<th style="text-align:right;">
+drat
+</th>
+<th style="text-align:right;">
+wt
+</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td style="text-align:center; vertical-align: middle;" rowspan="4">
+Team X
+</td>
+<td style="text-align:center; vertical-align: middle;" rowspan="3">
+Group A
+</td>
+<td style="text-align:left;">
+Mazda RX4
+</td>
+<td style="text-align:right;">
+21.0
+</td>
+<td style="text-align:right;">
+6
+</td>
+<td style="text-align:right;">
+160.0
+</td>
+<td style="text-align:right;">
+110
+</td>
+<td style="text-align:right;">
+3.90
+</td>
+<td style="text-align:right;">
+2.620
+</td>
+</tr>
+<tr>
+<td style="text-align:left;">
+Mazda RX4 Wag
+</td>
+<td style="text-align:right;">
+21.0
+</td>
+<td style="text-align:right;">
+6
+</td>
+<td style="text-align:right;">
+160.0
+</td>
+<td style="text-align:right;">
+110
+</td>
+<td style="text-align:right;">
+3.90
+</td>
+<td style="text-align:right;">
+2.875
+</td>
+</tr>
+<tr>
+<td style="text-align:left;">
+Datsun 710
+</td>
+<td style="text-align:right;">
+22.8
+</td>
+<td style="text-align:right;">
+4
+</td>
+<td style="text-align:right;">
+108.0
+</td>
+<td style="text-align:right;">
+93
+</td>
+<td style="text-align:right;">
+3.85
+</td>
+<td style="text-align:right;">
+2.320
+</td>
+</tr>
+<tr>
+<td style="text-align:center; vertical-align: middle;" rowspan="7">
+Group B
+</td>
+<td style="text-align:left;">
+Hornet 4 Drive
+</td>
+<td style="text-align:right;">
+21.4
+</td>
+<td style="text-align:right;">
+6
+</td>
+<td style="text-align:right;">
+258.0
+</td>
+<td style="text-align:right;">
+110
+</td>
+<td style="text-align:right;">
+3.08
+</td>
+<td style="text-align:right;">
+3.215
+</td>
+</tr>
+<tr>
+<td style="text-align:center; vertical-align: middle;" rowspan="2">
+Team Y
+</td>
+<td style="text-align:left;">
+Hornet Sportabout
+</td>
+<td style="text-align:right;">
+18.7
+</td>
+<td style="text-align:right;">
+8
+</td>
+<td style="text-align:right;">
+360.0
+</td>
+<td style="text-align:right;">
+175
+</td>
+<td style="text-align:right;">
+3.15
+</td>
+<td style="text-align:right;">
+3.440
+</td>
+</tr>
+<tr>
+<td style="text-align:left;">
+Valiant
+</td>
+<td style="text-align:right;">
+18.1
+</td>
+<td style="text-align:right;">
+6
+</td>
+<td style="text-align:right;">
+225.0
+</td>
+<td style="text-align:right;">
+105
+</td>
+<td style="text-align:right;">
+2.76
+</td>
+<td style="text-align:right;">
+3.460
+</td>
+</tr>
+<tr>
+<td style="text-align:center; vertical-align: middle;" rowspan="4">
+Team Z
+</td>
+<td style="text-align:left;">
+Duster 360
+</td>
+<td style="text-align:right;">
+14.3
+</td>
+<td style="text-align:right;">
+8
+</td>
+<td style="text-align:right;">
+360.0
+</td>
+<td style="text-align:right;">
+245
+</td>
+<td style="text-align:right;">
+3.21
+</td>
+<td style="text-align:right;">
+3.570
+</td>
+</tr>
+<tr>
+<td style="text-align:left;">
+Merc 240D
+</td>
+<td style="text-align:right;">
+24.4
+</td>
+<td style="text-align:right;">
+4
+</td>
+<td style="text-align:right;">
+146.7
+</td>
+<td style="text-align:right;">
+62
+</td>
+<td style="text-align:right;">
+3.69
+</td>
+<td style="text-align:right;">
+3.190
+</td>
+</tr>
+<tr>
+<td style="text-align:left;">
+Merc 230
+</td>
+<td style="text-align:right;">
+22.8
+</td>
+<td style="text-align:right;">
+4
+</td>
+<td style="text-align:right;">
+140.8
+</td>
+<td style="text-align:right;">
+95
+</td>
+<td style="text-align:right;">
+3.92
+</td>
+<td style="text-align:right;">
+3.150
+</td>
+</tr>
+<tr>
+<td style="text-align:left;">
+Merc 280
+</td>
+<td style="text-align:right;">
+19.2
+</td>
+<td style="text-align:right;">
+6
+</td>
+<td style="text-align:right;">
+167.6
+</td>
+<td style="text-align:right;">
+123
+</td>
+<td style="text-align:right;">
+3.92
+</td>
+<td style="text-align:right;">
+3.440
+</td>
+</tr>
+</tbody>
+</table>
+</div>
diff --git a/docs/awesome_table_in_pdf.Rmd b/docs/awesome_table_in_pdf.Rmd
index aaded10..c20f16f 100644
--- a/docs/awesome_table_in_pdf.Rmd
+++ b/docs/awesome_table_in_pdf.Rmd
@@ -251,3 +251,14 @@
column_spec(7, bold = T) %>%
row_spec(5, bold = T)
```
+
+# Add header column to the left
+An alternative way of grouping rows is being added to `kableExtra` 0.3.0. Unlike `group_rows`, the new function `add_header_left` adopts a similar syntax with `add_header_above`. It allows users to add multiple layers of row groups, which is a limitation of `group_rows`. A limitation of `add_header_left` is that, you can only use it in `booktabs` tables. There is no future plan to extend support to LaTeX table without booktabs because when a new layer of heading columns being added, every `cline` in normal table needs to be changed. Other limitations include incompatible with `group_rows` and a little in-stable `striped` row coloring behavior. If you don't have special need for multiple layers of heading columns or special love to this format, I will recommend you stick with `group_rows`.
+
+```{r}
+mtcars[1:10, 1:6] %>%
+ kable("latex", booktabs= T) %>%
+ add_header_above(c(" ", "Data 1" = 3, "Data 2" = 3)) %>%
+ add_header_left(c("Group A" = 3, "Group B" = 7), "Group") %>%
+ add_header_left(c("Team X" = 4, "Team Y" = 2, "Team Z" = 4), "Team")
+```
diff --git a/docs/awesome_table_in_pdf.pdf b/docs/awesome_table_in_pdf.pdf
index 5d6a188..0f92239 100644
--- a/docs/awesome_table_in_pdf.pdf
+++ b/docs/awesome_table_in_pdf.pdf
Binary files differ
diff --git a/inst/NEWS b/inst/NEWS
index a4ea393..3ac8695 100644
--- a/inst/NEWS
+++ b/inst/NEWS
@@ -12,6 +12,8 @@
* Add a new LaTeX option `repeat_header` in `kable_styling` for repeating
header rows in a longtable environment.
+* Fixed a bug in add_header_above to allow special symbol in extra header rows.
+
kableExtra 0.2.1
--------------------------------------------------------------------------------
diff --git a/tests/visual_tests/add_header_left.Rmd b/tests/visual_tests/add_header_left.Rmd
new file mode 100644
index 0000000..6d1f6c6
--- /dev/null
+++ b/tests/visual_tests/add_header_left.Rmd
@@ -0,0 +1,20 @@
+---
+title: "add_header_left"
+output:
+ pdf_document:
+ keep_tex: true
+---
+
+```{r}
+library(knitr)
+library(kableExtra)
+
+mtcars[1:10, 1:6] %>%
+ kable("latex", booktabs= T) %>%
+ # kable_styling(latex_options = "striped") %>%
+ add_header_above(c(" ", "a%" = 3, "b" = 3)) %>%
+ add_header_left(c("a%" = 3, "b" = 7), "new") %>%
+ add_header_left(c("a" = 4, "b" = 6), "new2") %>%
+ group_rows("aasd", 4, 6)
+
+```
diff --git a/tests/visual_tests/add_header_left_html.Rmd b/tests/visual_tests/add_header_left_html.Rmd
index 2fe83de..794543f 100644
--- a/tests/visual_tests/add_header_left_html.Rmd
+++ b/tests/visual_tests/add_header_left_html.Rmd
@@ -11,5 +11,6 @@
kable("html") %>%
kable_styling() %>%
add_header_above(c(" ", "a" = 3, "b" = 3)) %>%
- add_header_left(c("a" = 2, "b" = 3))
+ add_header_left(c("a" = 2, "b" = 3)) %>%
+ add_header_left(c("a%" = 3, "b" = 7))
```
diff --git a/tests/visual_tests/indent_and_row_group.Rmd b/tests/visual_tests/indent_and_row_group.Rmd
index 4ad0262..789fff8 100644
--- a/tests/visual_tests/indent_and_row_group.Rmd
+++ b/tests/visual_tests/indent_and_row_group.Rmd
@@ -18,3 +18,19 @@
add_indent(c(3, 5)) %>%
add_indent(5)
```
+
+```{r}
+library(knitr)
+library(kableExtra)
+for (i in 1:nrow(mtcars)) {
+ mtcars$hp[i] <- paste0(mtcars$hp[i], " (", 1, ")")
+ mtcars$wt[i] <- paste0(mtcars$wt[i], " &")
+ mtcars$mpg[i] <- paste0(mtcars$mpg[i], "%")
+}
+kable(head(mtcars, n = 20), "latex", caption = "test", booktabs = T) %>%
+ kable_styling() %>%
+ # group_rows("these rows", 4, 16) %>%
+ # group_rows("Those rows", 17,20) %>%
+ # add_header_above(c(" ", "aaa$" = 5, "bbb%" = 6)) %>%
+ add_header_left(c("jj", "aaa" = 5, "bbb" = 6))
+```
diff --git a/tests/visual_tests/longtable.Rmd b/tests/visual_tests/longtable.Rmd
index 1c27632..b586d79 100644
--- a/tests/visual_tests/longtable.Rmd
+++ b/tests/visual_tests/longtable.Rmd
@@ -31,3 +31,15 @@
add_header_above(c(" ", "a" = 6, "b" = 5)) %>%
kable_styling(latex_options = "repeat_header", repeat_header_text = "(cont.)")
```
+
+```{r}
+df <- data.frame(replicate(13, sample(1000000:9000000, 60,replace=TRUE)))
+df$Sum <- rowSums(df)
+totals <- colSums(df)
+df <- rbind(df, totals)
+names(df) <- c("Jan 2014", "Feb 2014", "Mar 2014", "Apr 2014", "May 2014", "Jun 2014", "Jul 2014",
+ "Aug 2014", "Sep 2014", "Oct 2014", "Nov 2014", "Dec 2014", "Jan 2015", "Sum")
+kable(df, "latex", longtable = T, booktabs = T) %>%
+ kable_styling(latex_options = c("repeat_header"), font_size = 7) %>%
+ landscape()
+```