bug fix to column_spec
diff --git a/R/add_header_left.R b/R/add_header_left.R
index 4129203..1b4e1fe 100644
--- a/R/add_header_left.R
+++ b/R/add_header_left.R
@@ -19,14 +19,14 @@
#' @param align Column alignment. you can choose from "c", "l" or "r"
#' @param bold A T/F value to control whether the text should be bolded.
#' @param italic A T/F value to control whether the text should to be emphasized.
-#' @param full_midline This option currently only work in LaTeX. It's a
-#' TRUE/FALSE option to control if the mid line needs to be extended to the end
-#' of row.
+#' @param ... Extra options to be passed into HTML or LaTeX. Right now there is
+#' only one for LaTeX. Option full_midline is a TRUE/FALSE option to control
+#' if the mid line needs to be extended to the end of row.
#'
#' @export
add_header_left <- function(kable_input, header = NULL, header_name = "",
align = "c", width = NULL, bold = F, italic = F,
- full_midline) {
+ ...) {
if (is.null(header)) return(kable_input)
kable_format <- attr(kable_input, "format")
if (!kable_format %in% c("html", "latex")) {
@@ -39,7 +39,7 @@
}
if (kable_format == "latex") {
return(add_header_left_latex(kable_input, header, header_name, align,
- width, bold, italic, full_midline))
+ width, bold, italic, ...))
}
}
@@ -203,9 +203,9 @@
ifelse(is.null(width), "\\*", width),
"\\}\\{",
switch(align,
- "l" = "\\\\raggedright",
- "c" = "\\\\centering ",
- "r" = "\\\\raggedleft "),
+ "l" = "\\\\raggedright\\\\arraybackslash ",
+ "c" = "\\\\centering\\\\arraybackslash ",
+ "r" = "\\\\raggedleft\\\\arraybackslash "),
header$header[j], "\\} & "
)
new_row_text <- paste0(new_row_pre, contents[header$row_end[j]])
diff --git a/R/column_spec.R b/R/column_spec.R
index d4dd1ac..851861a 100644
--- a/R/column_spec.R
+++ b/R/column_spec.R
@@ -5,7 +5,9 @@
#' bold text and italic text.
#'
#' @param kable_input Output of `knitr::kable()` with `format` specified
-#' @param column A numeric value indicating which column to be selected
+#' @param column A numeric value indicating which column to be selected. When
+#' you do the counting, ignore the extra header columns you added through
+#' add_header_left.
#' @param width A character string telling HTML & LaTeX how wide the column
#' needs to be, e.g. "10cm", "3in" or "30em".
#' @param bold A T/F value to control whether the text of the selected column
@@ -98,9 +100,9 @@
extra_align <- ""
if (!is.null(width)) {
extra_align <- switch(x,
- "l" = "\\\\raggedright",
- "c" = "\\\\centering",
- "r" = "\\\\raggedleft")
+ "l" = "\\\\raggedright\\\\arraybackslash",
+ "c" = "\\\\centering\\\\arraybackslash",
+ "r" = "\\\\raggedleft\\\\arraybackslash")
x <- paste0("p\\{", width, "\\}")
}