Made changes to add_header_left.
Change the name of attr original_kable_meta to kable_meta
diff --git a/R/add_footnote.R b/R/add_footnote.R
index 024df3b..3e1b130 100644
--- a/R/add_footnote.R
+++ b/R/add_footnote.R
@@ -239,6 +239,6 @@
# Paste footer to the table
export[1] <- gsub("</tbody>\n", paste0("</tbody>\n", footer), export[1])
}
- attr(export, "original_kable_meta") <- table_info
+ attr(export, "kable_meta") <- table_info
return(export)
}
diff --git a/R/add_header_above.R b/R/add_header_above.R
index 39b6273..1242868 100644
--- a/R/add_header_above.R
+++ b/R/add_header_above.R
@@ -11,6 +11,8 @@
#' for a 3-column table with "title" spanning across column 2 and 3. For
#' convenience, when `colspan` equals to 1, users can drop the ` = 1` part.
#' As a result, `c(" ", "title" = 2)` is the same as `c(" " = 1, "title" = 2)`.
+#' @param bold A T/F value to control whether the text should be bolded.
+#' @param italic A T/F value to control whether the text should to be emphasized.
#'
#' @examples x <- knitr::kable(head(mtcars), "html")
#' # Add a row of header with 3 columns on the top of the table. The column
@@ -18,22 +20,22 @@
#' add_header_above(x, c(" ", "Group 1" = 5, "Group 2" = 6))
#'
#' @export
-add_header_above <- function(kable_input, header = NULL) {
+add_header_above <- function(kable_input, header = NULL, bold = F, italic = F) {
kable_format <- attr(kable_input, "format")
if (!kable_format %in% c("html", "latex")) {
stop("Please specify output format in your kable function. Currently ",
"generic markdown table using pandoc is not supported.")
}
if (kable_format == "html") {
- return(htmlTable_add_header_above(kable_input, header))
+ return(htmlTable_add_header_above(kable_input, header, bold, italic))
}
if (kable_format == "latex") {
- return(pdfTable_add_header_above(kable_input, header))
+ return(pdfTable_add_header_above(kable_input, header, bold, italic))
}
}
# HTML
-htmlTable_add_header_above <- function(kable_input, header = NULL) {
+htmlTable_add_header_above <- function(kable_input, header, bold, italic) {
if (is.null(header)) return(kable_input)
kable_attrs <- attributes(kable_input)
kable_xml <- read_xml(as.character(kable_input), options = c("COMPACT"))
@@ -49,7 +51,7 @@
"columns with the original kable output.")
}
- new_header_row <- htmlTable_new_header_generator(header)
+ new_header_row <- htmlTable_new_header_generator(header, bold, italic)
xml_add_child(kable_xml_thead, new_header_row, .where = 0)
out <- structure(as.character(kable_xml), format = "html",
class = "knitr_kable")
@@ -72,13 +74,19 @@
return(data.frame(header = names(header), colspan = header, row.names = NULL))
}
-htmlTable_new_header_generator <- function(header_df) {
+htmlTable_new_header_generator <- function(header_df, bold, italic) {
+ row_style <- paste0(
+ ifelse(bold, "font-weight: bold; ", ""),
+ ifelse(italic, "font-style: italic; ", "")
+ )
header_items <- apply(header_df, 1, function(x) {
if (trimws(x[1]) == "") {
paste0('<th style="border-bottom:hidden"></th>')
} else {
paste0('<th style="text-align:center; border-bottom:hidden; ',
- 'padding-bottom:0; padding-left:3px;padding-right:3px;" colspan="',
+ 'padding-bottom:0; padding-left:3px;padding-right:3px;',
+ row_style,
+ '" colspan="',
x[2], '"><div style="border-bottom: 1px solid #ddd;padding-bottom: 5px;">',
x[1], '</div></th>')
}
@@ -89,13 +97,14 @@
}
# Add an extra header row above the current header in a LaTeX table ------
-pdfTable_add_header_above <- function(kable_input, header = NULL) {
+pdfTable_add_header_above <- function(kable_input, header, bold, italic) {
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_split <- pdfTable_new_header_generator(header, table_info$booktabs,
+ bold, italic)
new_header <- paste0(new_header_split[1], "\n", new_header_split[2])
out <- sub(hline_type,
paste0(hline_type, "\n", new_header),
@@ -109,11 +118,12 @@
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
+ attr(out, "kable_meta") <- table_info
return(out)
}
-pdfTable_new_header_generator <- function(header_df, booktabs = F) {
+pdfTable_new_header_generator <- function(header_df, booktabs = FALSE,
+ bold, italic) {
if (booktabs) {
header_df$align <- "c"
} else {
@@ -123,7 +133,10 @@
}
header_items <- apply(header_df, 1, function(x) {
# if(x[2] == 1) return(x[1])
- paste0('\\\\multicolumn{', x[2], '}{', x[3], '}{', x[1], "}")
+ paste0('\\\\multicolumn{', x[2], '}{', x[3], '}{',
+ ifelse(bold, "\\\\bfseries ", ""),
+ ifelse(italic, "\\\\em ", ""),
+ x[1], "}")
})
header_text <- paste(paste(header_items, collapse = " & "), "\\\\\\\\")
cline <- cline_gen(header_df, booktabs)
diff --git a/R/add_header_left.R b/R/add_header_left.R
index ba713a1..4129203 100644
--- a/R/add_header_left.R
+++ b/R/add_header_left.R
@@ -14,14 +14,19 @@
#' ` = 1` part. As a result, `c("xxx", "title" = 2)` is the same as
#' `c("xxx" = 1, "title" = 2)`.
#' @param header_name Column name that that extra column
+#' @param width A character string for the width of the new column. Values
+#' could be "10cm", "3in" or "30em", etc..
#' @param align Column alignment. you can choose from "c", "l" or "r"
-#' @param ... extra variables for latex or html. For LaTeX table, you can have
-#' a TRUE/FALSE option `full_midline` to control if the mid line needs to be
-#' extended to the end of row.
+#' @param bold A T/F value to control whether the text should be bolded.
+#' @param italic A T/F value to control whether the text should to be emphasized.
+#' @param full_midline This option currently only work in LaTeX. It's a
+#' TRUE/FALSE option to control if the mid line needs to be extended to the end
+#' of row.
#'
#' @export
add_header_left <- function(kable_input, header = NULL, header_name = "",
- align = "c", ...) {
+ align = "c", width = NULL, bold = F, italic = F,
+ full_midline) {
if (is.null(header)) return(kable_input)
kable_format <- attr(kable_input, "format")
if (!kable_format %in% c("html", "latex")) {
@@ -29,25 +34,35 @@
"generic markdown table using pandoc is not supported.")
}
if (kable_format == "html") {
- return(add_header_left_html(kable_input, header, header_name, align))
+ return(add_header_left_html(kable_input, header, header_name, align,
+ width, bold, italic))
}
if (kable_format == "latex") {
- return(add_header_left_latex(kable_input, header, header_name, align, ...))
+ return(add_header_left_latex(kable_input, header, header_name, align,
+ width, bold, italic, full_midline))
}
}
# HTML
-add_header_left_html <- function(kable_input, header, header_name, align) {
+add_header_left_html <- function(kable_input, header, header_name, align,
+ width, bold, italic) {
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 <- match.arg(align, c("c", "l", "r"))
align <- switch(align, "c" = "center", "l" = "left", "r" = "right")
+ column_style <- paste0(
+ ifelse(!is.null(width), paste0("width: ", width, "; "), ""),
+ ifelse(bold, "font-weight: bold; ", ""),
+ ifelse(italic, "font-style: italic; ", "")
+ )
+
new_header <- paste0(
- '<th style="text-align:', align, '; vertical-align: bottom;" rowspan="',
- length(xml_children(kable_thead)), '">', header_name, '</th>'
+ '<th style="text-align:', align, '; vertical-align: bottom;', column_style,
+ '" 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)
@@ -55,7 +70,8 @@
header <- standardize_header(header, length(xml_children(kable_tbody)))
for (i in 1:nrow(header)) {
new_row_item <- paste0(
- '<td style="text-align:', align, '; vertical-align: middle;" rowspan="',
+ '<td style="text-align:', align, '; vertical-align: middle;',
+ column_style, '" 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])
@@ -64,7 +80,30 @@
out <- structure(as.character(kable_xml), format = "html",
class = "knitr_kable")
+
+ # Adjust for column_spec
+ if (is.null(kable_attrs$column_adjust)) {
+ table_nrow <- length(xml_children(kable_tbody))
+ # if (!is.null(kable_attrs$group_header_rows)) {
+ # table_nrow <- table_nrow - length(kable_attrs$group_header_rows)
+ # }
+ table_ncol <- length(xml_children(
+ xml_child(kable_thead, length(xml_children(kable_thead)))
+ ))
+ kable_attrs$column_adjust$matrix <- matrix(
+ rep(TRUE, table_nrow * table_ncol), ncol = table_nrow)
+ kable_attrs$column_adjust$count <- 1
+ new_row_index <- rep(FALSE, table_nrow)
+ } else {
+ new_row_index <- rep(FALSE, ncol(kable_attrs$column_adjust$matrix))
+ kable_attrs$column_adjust$count <- 1 + kable_attrs$column_adjust$count
+ }
+ new_row_index[header$row] <- TRUE
+ kable_attrs$column_adjust$matrix <- rbind(
+ new_row_index, kable_attrs$column_adjust$matrix
+ )
attributes(out) <- kable_attrs
+
return(out)
}
@@ -92,7 +131,7 @@
}
add_header_left_latex <- function(kable_input, header, header_name, align,
- full_midline = F) {
+ width, bold, italic, full_midline = F) {
table_info <- magic_mirror(kable_input)
usepackage_latex("multirow")
if (!table_info$booktabs) {
@@ -109,13 +148,16 @@
header$row_end <- header$row + header$rowspan - 1
# Align
+ align_row <- latex_column_align_builder(align, width, bold, italic)
+
out <- sub(paste0(table_info$begin_tabular, "\\{"),
- paste0(table_info$begin_tabular, "{", align,
+ paste0(table_info$begin_tabular, "{", align_row,
ifelse(table_info$booktabs, "", "|")),
out, perl = T)
- table_info$align_vector <- c(align, table_info$align_vector)
+ # table_info$align_vector <- c(align, table_info$align_vector)
# Header
+ ## Extra header rows introduced by add_header_above
if (!is.null(table_info$new_header_row)) {
new_header_row <- table_info$new_header_row
for (i in 1:length(new_header_row)) {
@@ -131,6 +173,7 @@
out <- sub(cline_old, cline_new, out)
}
}
+ ## Base Header row
out <- sub(contents[1], paste0(header_name, " & ", contents[1]), out)
table_info$contents[1] <- paste0(header_name, " & ", contents[1])
@@ -156,7 +199,14 @@
for (j in 1:nrow(header)) {
new_row_pre <- paste0(
- "\\\\multirow\\{", -header$rowspan[j], "\\}\\{\\*\\}\\{", header$header[j], "\\} & "
+ "\\\\multirow\\{", -header$rowspan[j], "\\}\\{",
+ ifelse(is.null(width), "\\*", width),
+ "\\}\\{",
+ switch(align,
+ "l" = "\\\\raggedright",
+ "c" = "\\\\centering ",
+ "r" = "\\\\raggedleft "),
+ 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)
@@ -181,7 +231,8 @@
}
out <- structure(out, format = "latex", class = "knitr_kable")
- attr(out, "original_kable_meta") <- table_info
+
+ attr(out, "kable_meta") <- table_info
return(out)
}
diff --git a/R/add_indent.R b/R/add_indent.R
index ae3548f..abcf058 100644
--- a/R/add_indent.R
+++ b/R/add_indent.R
@@ -42,7 +42,7 @@
table_info$contents[i + 1] <- latex_indent_unit(rowtext)
}
out <- structure(out, format = "latex", class = "knitr_kable")
- attr(out, "original_kable_meta") <- table_info
+ attr(out, "kable_meta") <- table_info
return(out)
}
diff --git a/R/collapse_rows.R b/R/collapse_rows.R
index d3b8255..a0e0ac8 100644
--- a/R/collapse_rows.R
+++ b/R/collapse_rows.R
@@ -76,7 +76,7 @@
#
# out <- sub(target_row, new_row, as.character(kable_input), perl = T)
# out <- structure(out, format = "latex", class = "knitr_kable")
- # attr(out, "original_kable_meta") <- table_info
+ # attr(out, "kable_meta") <- table_info
# return(out)
kable_input
}
diff --git a/R/column_spec.R b/R/column_spec.R
index 0c383d5..d4dd1ac 100644
--- a/R/column_spec.R
+++ b/R/column_spec.R
@@ -41,14 +41,23 @@
kable_tbody <- xml_tpart(kable_xml, "tbody")
group_header_rows <- attr(kable_input, "group_header_rows")
- all_contents_rows <- seq(1, length(xml_children(kable_tbody)))
+ if (is.null(kable_attrs$column_adjust)) {
+ all_contents_rows <- seq(1, length(xml_children(kable_tbody)))
+ all_contents_array <- rep(column, length(all_contents_rows))
+ } else {
+ column <- column + kable_attrs$column_adjust$count
+ all_contents_array <- colSums(kable_attrs$column_adjust$matrix[1:column, ])
+ all_contents_rows <- which(all_contents_array != 0 &
+ kable_attrs$column_adjust$matrix[column, ])
+ }
+
if (!is.null(group_header_rows)) {
all_contents_rows <- all_contents_rows[!all_contents_rows %in%
group_header_rows]
}
for (i in all_contents_rows) {
- target_cell <- xml_child(xml_child(kable_tbody, i), column)
+ target_cell <- xml_child(xml_child(kable_tbody, i), all_contents_array[i])
if (!is.null(width)) {
xml_attr(target_cell, "style") <- paste0(xml_attr(target_cell, "style"),
"width: ", width, "; ")
@@ -73,25 +82,36 @@
align_collapse <- ifelse(table_info$booktabs, "", "\\|")
kable_align_old <- paste(table_info$align_vector, collapse = align_collapse)
- if (!is.null(width)) {
- table_info$align_vector[column] <- paste0("p\\{", width, "\\}")
- }
-
- if (bold | italic) {
- usepackage_latex("array")
- latex_array_options <- c("\\\\bfseries", "\\\\em")[c(bold, italic)]
- latex_array_options <- paste0(
- "\\>\\{", paste(latex_array_options, collapse = ""), "\\}"
- )
- table_info$align_vector[column] <- paste0(latex_array_options,
- table_info$align_vector[column])
- }
+ table_info$align_vector[column] <- latex_column_align_builder(
+ table_info$align_vector[column], width, bold, italic)
kable_align_new <- paste(table_info$align_vector, collapse = align_collapse)
out <- sub(kable_align_old, kable_align_new, as.character(kable_input),
perl = T)
out <- structure(out, format = "latex", class = "knitr_kable")
- attr(out, "original_kable_meta") <- table_info
+ attr(out, "kable_meta") <- table_info
return(out)
}
+
+latex_column_align_builder <- function(x, width, bold, italic) {
+ extra_align <- ""
+ if (!is.null(width)) {
+ extra_align <- switch(x,
+ "l" = "\\\\raggedright",
+ "c" = "\\\\centering",
+ "r" = "\\\\raggedleft")
+ x <- paste0("p\\{", width, "\\}")
+ }
+
+ if (bold | italic | extra_align != "") {
+ latex_array_options <- c("\\\\bfseries", "\\\\em")[c(bold, italic)]
+ latex_array_options <- c(latex_array_options, extra_align)
+ latex_array_options <- paste0(
+ "\\>\\{", paste(latex_array_options, collapse = ""), "\\}"
+ )
+ x <- paste0(latex_array_options, x)
+ }
+
+ return(x)
+}
diff --git a/R/group_rows.R b/R/group_rows.R
index 2df22ca..7b2ad33 100644
--- a/R/group_rows.R
+++ b/R/group_rows.R
@@ -98,7 +98,8 @@
)
}
out <- sub(rowtext, new_rowtext, out)
- attr(out, "original_kable_meta") <- table_info
+ table_info$group_rows_used <- TRUE
+ attr(out, "kable_meta") <- table_info
out <- add_indent(out, seq(start_row, end_row))
return(out)
}
diff --git a/R/kable_styling.R b/R/kable_styling.R
index 5460bfa..71a3074 100644
--- a/R/kable_styling.R
+++ b/R/kable_styling.R
@@ -210,7 +210,7 @@
out <- styling_latex_position(out, table_info, position, latex_options)
out <- structure(out, format = "latex", class = "knitr_kable")
- attr(out, "original_kable_meta") <- table_info
+ attr(out, "kable_meta") <- table_info
return(out)
}
diff --git a/R/magic_mirror.R b/R/magic_mirror.R
index d200a9d..9a05fc5 100644
--- a/R/magic_mirror.R
+++ b/R/magic_mirror.R
@@ -12,8 +12,8 @@
warning("magic_mirror may not be able to produce correct result if the",
" input table is not rendered by knitr::kable. ")
}
- if ("original_kable_meta" %in% names(attributes(kable_input))) {
- return(attr(kable_input, "original_kable_meta"))
+ if ("kable_meta" %in% names(attributes(kable_input))) {
+ return(attr(kable_input, "kable_meta"))
}
kable_format <- attr(kable_input, "format")
if (kable_format == "latex") {
diff --git a/R/row_spec.R b/R/row_spec.R
index 1e12327..4944f6d 100644
--- a/R/row_spec.R
+++ b/R/row_spec.R
@@ -82,6 +82,6 @@
out <- sub(target_row, new_row, as.character(kable_input), perl = T)
out <- structure(out, format = "latex", class = "knitr_kable")
- attr(out, "original_kable_meta") <- table_info
+ attr(out, "kable_meta") <- table_info
return(out)
}
diff --git a/R/zzz.R b/R/zzz.R
index 848679b..2096511 100644
--- a/R/zzz.R
+++ b/R/zzz.R
@@ -1,4 +1,5 @@
.onLoad <- function(libname = find.package("kableExtra"), pkgname = "kableExtra") {
usepackage_latex("booktabs")
usepackage_latex("longtable")
+ usepackage_latex("array")
}
diff --git a/docs/awesome_table_in_pdf.pdf b/docs/awesome_table_in_pdf.pdf
index edebef7..cc7cf6c 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 f3c08a1..ecad9ef 100644
--- a/inst/NEWS
+++ b/inst/NEWS
@@ -17,6 +17,8 @@
* Added add_header_left() feature so people can insert heading columns as they
do for heading rows.
+* Added alignment feature to column_spec when width is specified.
+
kableExtra 0.2.1
--------------------------------------------------------------------------------
diff --git a/man/add_header_above.Rd b/man/add_header_above.Rd
index 09b976d..cbe6988 100644
--- a/man/add_header_above.Rd
+++ b/man/add_header_above.Rd
@@ -4,7 +4,7 @@
\alias{add_header_above}
\title{Add a header row on top of current header}
\usage{
-add_header_above(kable_input, header = NULL)
+add_header_above(kable_input, header = NULL, bold = F, italic = F)
}
\arguments{
\item{kable_input}{Output of `knitr::kable()` with `format` specified}
@@ -14,6 +14,10 @@
for a 3-column table with "title" spanning across column 2 and 3. For
convenience, when `colspan` equals to 1, users can drop the ` = 1` part.
As a result, `c(" ", "title" = 2)` is the same as `c(" " = 1, "title" = 2)`.}
+
+\item{bold}{A T/F value to control whether the text should be bolded.}
+
+\item{italic}{A T/F value to control whether the text should to be emphasized.}
}
\description{
Tables with multiple rows of header rows are extremely useful
diff --git a/man/add_header_left.Rd b/man/add_header_left.Rd
index 54515a4..51b2ae6 100644
--- a/man/add_header_left.Rd
+++ b/man/add_header_left.Rd
@@ -5,7 +5,7 @@
\title{Add a heading column to the left side of the table}
\usage{
add_header_left(kable_input, header = NULL, header_name = "", align = "c",
- ...)
+ width = NULL, bold = F, italic = F, full_midline)
}
\arguments{
\item{kable_input}{Output of `knitr::kable()` with `format` specified}
@@ -21,9 +21,16 @@
\item{align}{Column alignment. you can choose from "c", "l" or "r"}
-\item{...}{extra variables for latex or html. For LaTeX table, you can have
-a TRUE/FALSE option `full_midline` to control if the mid line needs to be
-extended to the end of row.}
+\item{width}{A character string for the width of the new column. Values
+could be "10cm", "3in" or "30em", etc..}
+
+\item{bold}{A T/F value to control whether the text should be bolded.}
+
+\item{italic}{A T/F value to control whether the text should to be emphasized.}
+
+\item{full_midline}{This option currently only work in LaTeX. It's a
+TRUE/FALSE option to control if the mid line needs to be extended to the end
+of row.}
}
\description{
This function uses the same syntax as add_header_above. It will
diff --git a/tests/visual_tests/add_header_above_html.Rmd b/tests/visual_tests/add_header_above_html.Rmd
index 8451d6c..0eb1c65 100644
--- a/tests/visual_tests/add_header_above_html.Rmd
+++ b/tests/visual_tests/add_header_above_html.Rmd
@@ -14,7 +14,7 @@
kable_styling(bootstrap_options = c("striped", "condensed"),
latex_options = c("striped", "hold_position"),
full_width = F) %>%
- add_header_above(c(" ", "Group 1" = 2, "Group 2[note]" = 2)) %>%
+ add_header_above(c(" ", "Group 1" = 2, "Group 2[note]" = 2), italic = T) %>%
add_footnote(c("table footnote"))
```
diff --git a/tests/visual_tests/add_header_above_pdf.Rmd b/tests/visual_tests/add_header_above_pdf.Rmd
index 39797bf..1b91989 100644
--- a/tests/visual_tests/add_header_above_pdf.Rmd
+++ b/tests/visual_tests/add_header_above_pdf.Rmd
@@ -16,8 +16,8 @@
kable(dt, format = "latex", booktabs = T, caption = "Demo Table") %>%
kable_styling() %>%
- add_header_above(c(" ", "Group 1" = 2, "Group 2[note]" = 2)) %>%
- add_footnote(c("table footnote"))
+ add_header_above(c(" ", "Group 1" = 2, "Group 2[note]" = 2), bold = T, italic = T) %>%
+ add_footnote(c("table footnote"))
```
```{r}
diff --git a/tests/visual_tests/add_header_left.Rmd b/tests/visual_tests/add_header_left.Rmd
index 6d1f6c6..be34a14 100644
--- a/tests/visual_tests/add_header_left.Rmd
+++ b/tests/visual_tests/add_header_left.Rmd
@@ -14,7 +14,6 @@
# 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)
-
+ add_header_left(c("aadjfoi adlfsjs adsa" = 4, "b" = 6), "new2", width = "1.5cm") %>%
+ add_header_left(c("a" = 5, "b" = 5), "xx", width = "1cm", align = "r")
```
diff --git a/tests/visual_tests/add_header_left_html.Rmd b/tests/visual_tests/add_header_left_html.Rmd
index 794543f..09e739f 100644
--- a/tests/visual_tests/add_header_left_html.Rmd
+++ b/tests/visual_tests/add_header_left_html.Rmd
@@ -11,6 +11,7 @@
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%" = 3, "b" = 7))
+ add_header_left(c("a" = 2, "b" = 3), width = "3cm", bold = T) %>%
+ add_header_left(c("a%" = 3, "b" = 7)) %>%
+ column_spec(1, bold = T, width = "1cm")
```
diff --git a/tests/visual_tests/column_row_spec_html.Rmd b/tests/visual_tests/column_row_spec_html.Rmd
index 5ef4f21..aee5f70 100644
--- a/tests/visual_tests/column_row_spec_html.Rmd
+++ b/tests/visual_tests/column_row_spec_html.Rmd
@@ -55,3 +55,17 @@
column_spec(7, bold = T) %>%
row_spec(5, bold = T, italic = T)
```
+
+```{r}
+dt <- mtcars[1:5, 1:6]
+dt$wt <- paste(dt$wt, "%")
+dt$mpg <- paste(dt$mpg, "&")
+dt$cyl <- paste(dt$cyl, "$")
+
+kable(dt, "html") %>%
+ kable_styling(full_width = F) %>%
+ add_header_left(c("aaa" = 4, "bbb"), "A") %>%
+ add_header_left(c("cccasjof jsafjiosadjfxclxz cjoiwdjosfns daflasfj asiofjsdfio" = 2, "ddd" = 3), "B") %>%
+ column_spec(1, bold = T, width = "2cm") %>%
+ column_spec(2, italic = T)
+```
diff --git a/tests/visual_tests/column_row_spec_pdf.Rmd b/tests/visual_tests/column_row_spec_pdf.Rmd
index 4b9b31e..d76c802 100644
--- a/tests/visual_tests/column_row_spec_pdf.Rmd
+++ b/tests/visual_tests/column_row_spec_pdf.Rmd
@@ -57,3 +57,17 @@
row_spec(5, bold = T, italic = T)
```
+
+```{r}
+dt <- mtcars[1:5, 1:6]
+dt$wt <- paste(dt$wt, "%")
+dt$mpg <- paste(dt$mpg, "&")
+dt$cyl <- paste(dt$cyl, "$")
+
+kable(dt, "latex", booktabs = T) %>%
+ add_header_left(c("aaa aaa aaa aaa aaa" = 2, "bbb" = 3), "A") %>%
+ column_spec(8, bold = T) %>%
+ column_spec(1, bold = T, width = "1em") %>%
+ row_spec(5, bold = T, italic = T)
+```
+