Skip to content

Commit

Permalink
fix a bug causing issues in tables' cran check
Browse files Browse the repository at this point in the history
  • Loading branch information
haozhu233 committed Oct 22, 2020
1 parent 75e2ad0 commit b6b4f50
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion 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')),
Expand Down
10 changes: 5 additions & 5 deletions R/row_spec.R
Expand Up @@ -203,14 +203,14 @@ row_spec_latex <- function(kable_input, row, bold, italic, monospace,
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]
}
}
Expand Down
3 changes: 2 additions & 1 deletion R/util.R
Expand Up @@ -110,7 +110,8 @@ latex_pkg_list <- function() {
"\\usepackage[normalem]{ulem}",
"\\usepackage[normalem]{ulem}",
"\\usepackage[utf8]{inputenc}",
"\\usepackage{makecell}"
"\\usepackage{makecell}",
"\\usepackage{xcolor}"
))
}

Expand Down
2 changes: 1 addition & 1 deletion R/zzz.R
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion docs/awesome_table_in_pdf.Rmd
Expand Up @@ -99,9 +99,12 @@ header-includes:
- \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.
Expand Down
Binary file modified docs/awesome_table_in_pdf.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions docs/awesome_table_in_pdf.toc
Expand Up @@ -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}%
Expand All @@ -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}%
Expand Down
5 changes: 4 additions & 1 deletion vignettes/awesome_table_in_pdf.Rmd
Expand Up @@ -99,9 +99,12 @@ header-includes:
- \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.
Expand Down

0 comments on commit b6b4f50

Please sign in to comment.