Merge branch 'master' of https://github.com/haozhu233/kableExtra
diff --git a/R/add_footnote.R b/R/add_footnote.R
index 3e1b130..abb618a 100644
--- a/R/add_footnote.R
+++ b/R/add_footnote.R
@@ -99,6 +99,7 @@
label <- escape_latex(label)
label <- gsub("\\\\", "\\\\\\\\", label)
+ export <- enc2utf8(export)
table_info <- magic_mirror(input)
if (table_info$tabular == "longtable") {
if (notation != "number") {
diff --git a/R/add_header_above.R b/R/add_header_above.R
index 95e587d..e716b69 100644
--- a/R/add_header_above.R
+++ b/R/add_header_above.R
@@ -125,7 +125,7 @@
new_header <- paste0(new_header_split[1], "\n", new_header_split[2])
out <- sub(hline_type,
paste0(hline_type, "\n", new_header),
- as.character(kable_input))
+ enc2utf8(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)) {
diff --git a/R/add_indent.R b/R/add_indent.R
index 4ae84da..8932eaa 100644
--- a/R/add_indent.R
+++ b/R/add_indent.R
@@ -35,7 +35,7 @@
"add_indent_latex.")
}
- out <- kable_input
+ out <- enc2utf8(kable_input)
for (i in positions) {
rowtext <- table_info$contents[i + 1]
out <- sub(rowtext, latex_indent_unit(rowtext), out, perl = TRUE)
diff --git a/R/collapse_rows.R b/R/collapse_rows.R
index 3b13997..8ba1250 100644
--- a/R/collapse_rows.R
+++ b/R/collapse_rows.R
@@ -89,7 +89,7 @@
if (is.null(columns)) {
columns <- seq(1, table_info$ncol)
}
- out <- as.character(kable_input)
+ out <- enc2utf8(as.character(kable_input))
contents <- table_info$contents
kable_dt <- kable_dt_latex(contents)
collapse_matrix <- collapse_row_matrix(kable_dt, columns, html = F)
diff --git a/R/column_spec.R b/R/column_spec.R
index 1702f2d..409ea0c 100644
--- a/R/column_spec.R
+++ b/R/column_spec.R
@@ -144,7 +144,8 @@
kable_align_new <- paste(table_info$align_vector, collapse = align_collapse)
- out <- sub(kable_align_old, kable_align_new, as.character(kable_input),
+ out <- sub(kable_align_old, kable_align_new,
+ enc2utf8(as.character(kable_input)),
perl = T)
out <- structure(out, format = "latex", class = "knitr_kable")
if (!is.null(width)) {
diff --git a/R/group_rows.R b/R/group_rows.R
index 47a02f0..1d848b7 100644
--- a/R/group_rows.R
+++ b/R/group_rows.R
@@ -85,7 +85,7 @@
group_rows_latex <- function(kable_input, group_label, start_row, end_row,
gap_space, escape) {
table_info <- magic_mirror(kable_input)
- out <- kable_input
+ out <- enc2utf8(as.character(kable_input))
if (escape) {
group_label <- escape_latex(group_label)
@@ -110,6 +110,7 @@
}
out <- sub(rowtext, new_rowtext, out)
out <- gsub("\\\\addlinespace\n", "", out)
+ out <- structure(out, format = "latex", class = "knitr_kable")
table_info$group_rows_used <- TRUE
attr(out, "kable_meta") <- table_info
out <- add_indent(out, seq(start_row, end_row))
diff --git a/R/kable_styling.R b/R/kable_styling.R
index 2a3248d..a33f820 100644
--- a/R/kable_styling.R
+++ b/R/kable_styling.R
@@ -187,7 +187,7 @@
repeat_header_method <- match.arg(repeat_header_method)
out <- NULL
- out <- as.character(kable_input)
+ out <- enc2utf8(as.character(kable_input))
table_info <- magic_mirror(kable_input)
if ("striped" %in% latex_options) {
diff --git a/R/landscape.R b/R/landscape.R
index 75d9255..fd7789e 100644
--- a/R/landscape.R
+++ b/R/landscape.R
@@ -28,7 +28,9 @@
kable_attrs <- attributes(kable_input)
usepackage_latex("pdflscape")
out <- paste0(
- "\n\\begin{landscape}", kable_input, "\n\\end{landscape}"
+ "\n\\begin{landscape}",
+ enc2utf8(as.character(kable_input)),
+ "\n\\end{landscape}"
)
if (!is.null(margin)) {
diff --git a/R/row_spec.R b/R/row_spec.R
index 060c27f..1d5d500 100644
--- a/R/row_spec.R
+++ b/R/row_spec.R
@@ -114,7 +114,8 @@
new_row <- paste0("\\\\rowcolor{", background, "} ", new_row)
}
- out <- sub(target_row, new_row, as.character(kable_input), perl = T)
+ out <- sub(target_row, new_row, enc2utf8(as.character(kable_input)),
+ perl = T)
out <- structure(out, format = "latex", class = "knitr_kable")
attr(out, "kable_meta") <- table_info
return(out)
diff --git a/docs/awesome_table_in_pdf.Rmd b/docs/awesome_table_in_pdf.Rmd
index f6e73e3..7bb5585 100644
--- a/docs/awesome_table_in_pdf.Rmd
+++ b/docs/awesome_table_in_pdf.Rmd
@@ -185,7 +185,7 @@
## Group rows via labeling
Sometimes we want a few rows of the table being grouped together. They might be items under the same topic (e.g., animals in one species) or just different data groups for a categorical variable (e.g., age < 40, age > 40). With the new function `group_rows()` in `kableExtra`, this kind of task can be completed in one line. Please see the example below. Note that when you count for the start/end rows of the group, you don't need to count for the header rows nor other group label rows. You only need to think about the row numbers in the "original R dataframe".
```{r}
-kable(mtcars[1:10, 1:6], caption = "Group Rows", booktabs = T) %>%
+kable(mtcars[1:10, 1:6],"latex", caption = "Group Rows", booktabs = T) %>%
kable_styling() %>%
group_rows("Group 1", 4, 7) %>%
group_rows("Group 2", 8, 10)
diff --git a/docs/awesome_table_in_pdf.pdf b/docs/awesome_table_in_pdf.pdf
index f7bace8..6e3ddd2 100644
--- a/docs/awesome_table_in_pdf.pdf
+++ b/docs/awesome_table_in_pdf.pdf
Binary files differ