Merge branch 'master' of https://github.com/haozhu233/kableExtra
diff --git a/R/column_spec.R b/R/column_spec.R
index 71a4b22..693bc80 100644
--- a/R/column_spec.R
+++ b/R/column_spec.R
@@ -216,7 +216,8 @@
message("Usually it is recommended to use column_spec before collapse_rows,",
" especially in LaTeX, to get a desired result. ")
}
- align_collapse <- ifelse(table_info$booktabs, "", "\\|")
+ align_collapse <- ifelse(table_info$booktabs | !is.null(table_info$xtable),
+ "", "\\|")
kable_align_old <- paste(table_info$align_vector, collapse = align_collapse)
table_info$align_vector[column] <- unlist(lapply(
diff --git a/R/xtable2kable.R b/R/xtable2kable.R
index 862d7a1..3c13658 100644
--- a/R/xtable2kable.R
+++ b/R/xtable2kable.R
@@ -51,6 +51,7 @@
if ("tabular.environment" %in% names(xtable_print_options)) {
out_meta$tabular <- xtable_print_options$tabular.environment
}
+ out_meta$xtable <- TRUE
attr(out, "kable_meta") <- out_meta
return(out)
}
diff --git a/docs/xtable.Rmd b/docs/xtable.Rmd
new file mode 100644
index 0000000..820ac60
--- /dev/null
+++ b/docs/xtable.Rmd
@@ -0,0 +1,30 @@
+---
+title: "xtable & kableExtra"
+author: "Hao"
+date: "2/13/2019"
+output: pdf_document
+---
+
+```{r setup, include=FALSE}
+knitr::opts_chunk$set(message = FALSE)
+```
+
+Recent versions of kableExtra (since 1.0) offers a function `xtable2kable`, which, as suggested by its name, turns a `xtable` object to a `kable` object so you can use functions in kableExtra after that. I tested some basic examples and it seem to work.
+
+```{r}
+library(xtable)
+library(kableExtra)
+
+xtable(mtcars[1:5, 1:5]) %>%
+ xtable2kable() %>%
+ column_spec(1, width = "5cm")
+```
+
+```{r}
+xtable(mtcars[1:5, 1:5], caption = "Some long caption") %>%
+ xtable2kable(caption.width = "10em") %>%
+ column_spec(1, color = "red")
+```
+
+
+
diff --git a/docs/xtable.pdf b/docs/xtable.pdf
new file mode 100644
index 0000000..d034c91
--- /dev/null
+++ b/docs/xtable.pdf
Binary files differ