fix a bug causing issues in tables' cran check
diff --git a/DESCRIPTION b/DESCRIPTION
index fbb9a6e..83f72a3 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,7 +1,7 @@
Package: kableExtra
Type: Package
Title: Construct Complex Table with 'kable' and Pipe Syntax
-Version: 1.3.0
+Version: 1.3.1
Authors@R: c(
person('Hao', 'Zhu', email = 'haozhu233@gmail.com', role = c('aut', 'cre'),
comment = c(ORCID = '0000-0002-3386-6076')),
diff --git a/R/row_spec.R b/R/row_spec.R
index 3d08857..ea96971 100644
--- a/R/row_spec.R
+++ b/R/row_spec.R
@@ -203,14 +203,14 @@
hline_after, extra_latex_after)
temp_sub <- ifelse(i == 1 & (table_info$tabular == "longtable" |
!is.null(table_info$repeat_header_latex)),
- stringr::str_replace_all, stringr::str_replace)
+ gsub, sub)
if (length(new_row) == 1) {
- out <- temp_sub(out, paste0(target_row, "\\\\\\\\"),
- paste0(new_row, "\\\\\\\\"))
+ out <- temp_sub(paste0(target_row, "\\\\\\\\"),
+ paste0(new_row, "\\\\\\\\"), out, perl = T)
table_info$contents[i] <- new_row
} else {
- out <- temp_sub(out, paste0(target_row, "\\\\\\\\"),
- paste(new_row, collapse = ""))
+ out <- temp_sub(paste0(target_row, "\\\\\\\\"),
+ paste(new_row, collapse = ""), out, perl = T)
table_info$contents[i] <- new_row[1]
}
}
diff --git a/R/util.R b/R/util.R
index 785c6ad..474f352 100644
--- a/R/util.R
+++ b/R/util.R
@@ -110,7 +110,8 @@
"\\usepackage[normalem]{ulem}",
"\\usepackage[normalem]{ulem}",
"\\usepackage[utf8]{inputenc}",
- "\\usepackage{makecell}"
+ "\\usepackage{makecell}",
+ "\\usepackage{xcolor}"
))
}
diff --git a/R/zzz.R b/R/zzz.R
index 36133e7..c12793b 100644
--- a/R/zzz.R
+++ b/R/zzz.R
@@ -15,7 +15,7 @@
usepackage_latex("threeparttablex")
usepackage_latex("ulem", "normalem")
usepackage_latex("makecell")
- # usepackage_latex("xcolor")
+ usepackage_latex("xcolor")
}
}
auto_format <- getOption("kableExtra.auto_format", default = TRUE)
diff --git a/docs/awesome_table_in_pdf.Rmd b/docs/awesome_table_in_pdf.Rmd
index 043e8a7..7025dd7 100644
--- a/docs/awesome_table_in_pdf.Rmd
+++ b/docs/awesome_table_in_pdf.Rmd
@@ -99,9 +99,12 @@
- \usepackage{threeparttablex}
- \usepackage[normalem]{ulem}
- \usepackage{makecell}
+ - \usepackage{xcolor}
```
-Note: `kableExtra` was using `xcolor` for alternative row color before 1.0. However, the recent updates in `fancyvbr` causes a clash in `xcolor` option. Therefore, we removed the `xcolor` dependency in version 1.0 and started to rely on `colortbl` completely. If you experience any issues, please report on github.
+Note: `kableExtra` was using `xcolor` with the `table` option for alternative row color before 1.0. However, the recent updates in `fancyvbr` causes a clash in `xcolor` option. Therefore, we removed the `xcolor` dependency in version 1.0 and started to rely on `colortbl` completely.
+
+In reality, most cases, you still need `xcolor` to define new colors. The tricky part is that, if you are using a older version of `rmarkdown`, `xcolor` is not included in the template while in recent version, after `rmarkdown` started to use the default pandoc template, `xcolor` is included by default. To minimize the effort, we chose to load `xcolor` in the end.
## Plain LaTeX
Plain LaTeX table looks relatively ugly in 2017.
diff --git a/docs/awesome_table_in_pdf.pdf b/docs/awesome_table_in_pdf.pdf
index 605a3e1..64acf25 100644
--- a/docs/awesome_table_in_pdf.pdf
+++ b/docs/awesome_table_in_pdf.pdf
Binary files differ
diff --git a/docs/awesome_table_in_pdf.toc b/docs/awesome_table_in_pdf.toc
index ca565b0..31d88d3 100644
--- a/docs/awesome_table_in_pdf.toc
+++ b/docs/awesome_table_in_pdf.toc
@@ -15,7 +15,7 @@
\contentsline {subsection}{Font Size}{10}{section*.16}%
\contentsline {section}{Column / Row Specification}{10}{section*.17}%
\contentsline {subsection}{Column spec}{10}{section*.18}%
-\contentsline {subsection}{Insert Images into Columns}{11}{section*.19}%
+\contentsline {subsection}{Insert Images into Columns}{12}{section*.19}%
\contentsline {subsection}{Row spec}{13}{section*.20}%
\contentsline {subsection}{Header Rows}{14}{section*.21}%
\contentsline {section}{Cell/Text Specification}{14}{section*.22}%
@@ -24,7 +24,7 @@
\contentsline {subsection}{Text Specification}{16}{section*.25}%
\contentsline {section}{Grouped Columns / Rows}{17}{section*.26}%
\contentsline {subsection}{Add header rows to group columns}{17}{section*.27}%
-\contentsline {subsection}{Group rows via labeling}{17}{section*.28}%
+\contentsline {subsection}{Group rows via labeling}{18}{section*.28}%
\contentsline {subsection}{Row indentation}{19}{section*.29}%
\contentsline {subsection}{Group rows via multi-row cell}{19}{section*.30}%
\contentsline {section}{Table Footnote}{23}{section*.31}%
diff --git a/vignettes/awesome_table_in_pdf.Rmd b/vignettes/awesome_table_in_pdf.Rmd
index 043e8a7..7025dd7 100644
--- a/vignettes/awesome_table_in_pdf.Rmd
+++ b/vignettes/awesome_table_in_pdf.Rmd
@@ -99,9 +99,12 @@
- \usepackage{threeparttablex}
- \usepackage[normalem]{ulem}
- \usepackage{makecell}
+ - \usepackage{xcolor}
```
-Note: `kableExtra` was using `xcolor` for alternative row color before 1.0. However, the recent updates in `fancyvbr` causes a clash in `xcolor` option. Therefore, we removed the `xcolor` dependency in version 1.0 and started to rely on `colortbl` completely. If you experience any issues, please report on github.
+Note: `kableExtra` was using `xcolor` with the `table` option for alternative row color before 1.0. However, the recent updates in `fancyvbr` causes a clash in `xcolor` option. Therefore, we removed the `xcolor` dependency in version 1.0 and started to rely on `colortbl` completely.
+
+In reality, most cases, you still need `xcolor` to define new colors. The tricky part is that, if you are using a older version of `rmarkdown`, `xcolor` is not included in the template while in recent version, after `rmarkdown` started to use the default pandoc template, `xcolor` is included by default. To minimize the effort, we chose to load `xcolor` in the end.
## Plain LaTeX
Plain LaTeX table looks relatively ugly in 2017.