From 81ec2fe816fa84a7303463a7271158bfcfc065d1 Mon Sep 17 00:00:00 2001 From: Duncan Murdoch Date: Mon, 4 Dec 2023 06:24:31 -0500 Subject: [PATCH] Fix centering of three part table. Fixes #692. --- R/kable_styling.R | 5 +++-- inst/NEWS.md | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/R/kable_styling.R b/R/kable_styling.R index c6d72d8..2ec6ab1 100644 --- a/R/kable_styling.R +++ b/R/kable_styling.R @@ -558,7 +558,7 @@ styling_latex_position <- function(x, table_info, position, latex_options, styling_latex_position_center <- function(x, table_info, hold_position, table.envir) { - if (!table_info$table_env & table_info$tabular == "tabular") { + if (!table_info$table_env && table_info$tabular == "tabular") { x <- paste0("\\begin{", table.envir, "}\n\\centering", x, "\n\\end{", table.envir, "}") if (hold_position == "hold_position") { @@ -566,7 +566,8 @@ styling_latex_position_center <- function(x, table_info, hold_position, } else if(hold_position == "HOLD_position") { x <- styling_latex_HOLD_position(x) } - } + } else if (table_info$table_env) + x <- sub("^\\\\begin\\{table}", "\\\\begin{table}\n\\\\centering", x) return(x) } diff --git a/inst/NEWS.md b/inst/NEWS.md index 7e7e63f..6084046 100644 --- a/inst/NEWS.md +++ b/inst/NEWS.md @@ -8,6 +8,7 @@ should be supported. * cell_spec() colors like "darkgoldenrod2" weren't shown (issue #726). * placement of collapsed row labels was incorrect (issue #719). +* centering of three part table wasn't working (issue #692)