diff --git a/NEWS.md b/NEWS.md index dd61b9cd63..f1c09576a0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -18,6 +18,8 @@ - Trailing spaces escaped by `\` should not be trimmed in `kable()` (thanks, @mjsmith037, #2308). +- `kable()` fails when the value of the `caption` argument is of length > 1 (thanks, @LeeMendelowitz, #2312). + ## MAJOR CHANGES - Unbalanced chunk delimiters (fences) in R Markdown documents are no longer allowed, as announced two years ago at (#2306). This means the opening delimiter must strictly match the closing delimiter, e.g., if a code chunk starts with four backticks, it must also end with four; or if a chunk header is indented by two spaces, the closing fence must be indented by exactly two spaces. For authors who cannot update their R Markdown documents for any reason at the moment, setting `options(knitr.unbalanced.chunk = TRUE)` (e.g., in `.Rprofile`) can temporarily prevent **knitr** from throwing an error, but it is strongly recommended that you fix the problems as soon as possible, because this workaround will be removed in future. diff --git a/R/table.R b/R/table.R index cc631748f6..5eec071e12 100644 --- a/R/table.R +++ b/R/table.R @@ -172,7 +172,7 @@ kable_caption = function(label, caption, format) { # create a label for bookdown if applicable if (is.null(label)) label = opts_current$get('label') if (is.null(label)) label = NA - if (!is.null(caption) && !is.na(caption) && !is.na(label)) caption = paste0( + if (!is.null(caption) && !anyNA(caption) && !anyNA(label)) caption = paste0( create_label( opts_knit$get('label.prefix')[['table']], label, latex = (format == 'latex')