From 955c587afd3103d36904e481c0b2a252a57d4bce Mon Sep 17 00:00:00 2001 From: Chris Grandin Date: Tue, 3 Oct 2023 15:23:48 -0700 Subject: [PATCH 1/2] Fix bug where unescaped curly brackets from latex-declared column types cause error for non-longtables --- R/kable_styling.R | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/R/kable_styling.R b/R/kable_styling.R index 0d41372..5683a85 100644 --- a/R/kable_styling.R +++ b/R/kable_styling.R @@ -595,6 +595,18 @@ styling_latex_position_float <- function(x, table_info, option, table.envir, styling_latex_font_size <- function(x, table_info, font_size) { row_height <- font_size + 2 if (table_info$tabular != "longtable" & table_info$table_env) { + # Following two lines use negative lookbehinds to find curly braces + # which have not been escaped and escape them. This situation arises + # when the user has declared latex column types like this (C = center): + # + # \newcommand{\PreserveBackslash}[1]{\let\temp=\\#1\let\\=\temp} + # \newcolumntype{C}[1]{>{\PreserveBackslash\centering}p{#1}} + table_info$begin_tabular <- gsub("(? Date: Tue, 29 Oct 2024 09:04:53 -0700 Subject: [PATCH 2/2] small fix checking meta value in rmarkdown --- R/zzz.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/zzz.R b/R/zzz.R index c12793b..b76683a 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -20,7 +20,8 @@ } auto_format <- getOption("kableExtra.auto_format", default = TRUE) if (auto_format) auto_set_format() - if (!is.null(rmarkdown::metadata$output) && + + if (!is.null(rmarkdown::metadata$output[[1]]) && rmarkdown::metadata$output %in% c( "ioslides_presentation", "slidy_presentation", "gitbook", "bookdown::gitbook", "radix_article", "radix::radix_article",