move row label justification from latex_options to its own parameter so that it can be used in html tables
diff --git a/R/kable_styling.R b/R/kable_styling.R
index 40498e5..bad743d 100644
--- a/R/kable_styling.R
+++ b/R/kable_styling.R
@@ -23,8 +23,7 @@
#' `scale_down` is useful for super wide table. It will automatically adjust
#' the table to page width. `repeat_header` in only meaningful in a longtable
#' environment. It will let the header row repeat on every page in that long
-#' table. `row_label_right` will right justify the row labels and `row_label_center`
-#' will center justify the row labels. Default justification is left.
+#' table.
#' @param full_width A `TRUE` or `FALSE` variable controlling whether the HTML
#' table should have 100\% width. Since HTML and pdf have different flavors on
#' the preferable format for `full_width`. If not specified, a HTML table will
@@ -36,6 +35,9 @@
#' a `LaTeX` table, if `float_*` is selected, `LaTeX` package `wrapfig` will be
#' imported.
#' @param font_size A numeric input for table font size
+#' @param row_label_position A character string determining the justification of the row
+#' labels in a table. Possible values inclued `l` for left, `c` for center, and `r` for
+#' right. The default value is `l` for left justifcation.
#' @param ... extra options for HTML or LaTeX. See `details`.
#'
#' @details For LaTeX, extra options includes:
@@ -60,6 +62,7 @@
full_width = NULL,
position = "center",
font_size = NULL,
+ row_label_position = "l",
...) {
if (length(bootstrap_options) == 1 && bootstrap_options == "basic") {
@@ -89,6 +92,9 @@
if (is.null(full_width)) {
full_width <- getOption("kable_styling_full_width", T)
}
+ if(!missing(row_label_position)) {
+ warning("'row_label_position' is not active for HTML tables yet and parameter will not be used.")
+ }
return(htmlTable_styling(kable_input,
bootstrap_options = bootstrap_options,
full_width = full_width,
@@ -103,7 +109,9 @@
latex_options = latex_options,
full_width = full_width,
position = position,
- font_size = font_size, ...))
+ font_size = font_size,
+ row_label_position = row_label_position,
+ ...))
}
}
@@ -187,12 +195,12 @@
repeat_header_method = c("append", "replace"),
repeat_header_continued = FALSE,
stripe_color = "gray!6",
- latex_table_env = NULL) {
+ latex_table_env = NULL,
+ row_label_position) {
latex_options <- match.arg(
latex_options,
- c("basic", "striped", "hold_position", "HOLD_position", "scale_down", "repeat_header",
- "row_label_right","row_label_center"),
+ c("basic", "striped", "hold_position", "HOLD_position", "scale_down", "repeat_header"),
several.ok = T
)
@@ -252,22 +260,16 @@
out <- structure(out, format = "latex", class = "knitr_kable")
attr(out, "kable_meta") <- table_info
- if ("row_label_right" %in% latex_options | "row_label_center" %in% latex_options) {
- if ( "row_label_right" %in% latex_options ) {
- row_label_orientation <- "r"
- } else {
- row_label_orientation <- "c"
- }
-
+ if (row_label_position != "l") {
if(table_info$tabular=="longtable") {
out <- sub("\\\\begin\\{longtable\\}\\{l",
paste0("\\\\begin\\{longtable\\}\\{",
- row_label_orientation),
+ row_label_position),
out)
} else {
out <- sub("\\\\begin\\{tabular\\}\\{l",
paste0("\\\\begin\\{tabular\\}\\{",
- row_label_orientation),
+ row_label_position),
out)
}
}