diff --git a/R/group_tabularray.R b/R/group_tabularray.R index 9ad70746..54d82aa5 100644 --- a/R/group_tabularray.R +++ b/R/group_tabularray.R @@ -44,11 +44,13 @@ group_tabularray_col <- function(x, j) { for (k in seq_along(j)) { z <- min(j[[k]]) - args <- list(x = out, + args <- list(tt_build_now = TRUE, + x = out, # the new header is always first row and # style_tt always adds nhead to index i = 1 - meta(out)$nhead, j = z, + align = "c", colspan = max(j[[k]]) - min(j[[k]]) + 1) out <- do.call(style_tt, args) } diff --git a/R/group_tt.R b/R/group_tt.R index 07a42484..c3664186 100644 --- a/R/group_tt.R +++ b/R/group_tt.R @@ -4,7 +4,6 @@ #' @inheritParams tt #' @inheritParams style_tt #' @param indent integer number of `pt` to use when indenting the non-labelled rows. -#' @param ... All additional arguments (ex: `italic`, `bold`, `color`) are automatically passed to the `style_tt()` function and applied to the labels. group_tt <- function(x, i = NULL, j = NULL, indent = 1) { if (is.null(meta(x))) stop("`x` must be generated by `tinytable::tt()`.", call. = FALSE) @@ -26,7 +25,7 @@ group_tt <- function(x, i = NULL, j = NULL, indent = 1) { if (meta(out)$output == "latex") { cal <- call("group_tabularray", i = i, j = j, indent = indent) } else if (meta(out)$output == "html") { - cal <- call("group_botstrap", i = i, j = j, indent = indent) + cal <- call("group_bootstrap", i = i, j = j, indent = indent) } out <- meta(out, "lazy_group", c(meta(out)$lazy_group, list(cal))) diff --git a/R/style_tt.R b/R/style_tt.R index 2ddacde7..72921377 100644 --- a/R/style_tt.R +++ b/R/style_tt.R @@ -30,6 +30,7 @@ #' @param bootstrap_css_rule A string with complete CSS rules that apply to the table class specified using the `theme` argument of the `tt()` function. #' @param tabularray_inner A string that specifies the "inner" settings of a tabularray LaTeX table. #' @param tabularray_outer A string that specifies the "outer" settings of a tabularray LaTeX table. +#' @param ... extra arguments are ignored #' @return Returns a modified `tinytable` object with the applied styles. #' @template latex_preamble #' @export @@ -59,7 +60,8 @@ style_tt <- function (x, tabularray_inner = NULL, tabularray_outer = NULL, bootstrap_css = NULL, - bootstrap_css_rule = NULL) { + bootstrap_css_rule = NULL, + ...) { out <- x cal <- call("style_tt_lazy", @@ -84,7 +86,11 @@ style_tt <- function (x, bootstrap_css = bootstrap_css, bootstrap_css_rule = bootstrap_css_rule) - out <- meta(out, "lazy_style", c(meta(out)$lazy_style, list(cal))) + if (isTRUE(list(...)[["tt_build_now"]])) { + out <- eval(cal) + } else { + out <- meta(out, "lazy_style", c(meta(out)$lazy_style, list(cal))) + } return(out) } diff --git a/inst/tinytest/test-format_tt.R b/inst/tinytest/test-format_tt.R index b481f222..28d4d67d 100644 --- a/inst/tinytest/test-format_tt.R +++ b/inst/tinytest/test-format_tt.R @@ -7,9 +7,9 @@ # ) # # Q -pkgload::load_all() -k = dat |> tt("latex") |> - style_tt(color = "orange") |> - format_tt(j = 1, digits = 10, num_fmt = "decimal") |> - format_tt(j = 2, date = "%Y") -print(k) +# pkgload::load_all() +# k = dat |> tt("latex") |> +# style_tt(color = "orange") |> +# format_tt(j = 1, digits = 10, num_fmt = "decimal") |> +# format_tt(j = 2, date = "%Y") +# print(k) diff --git a/man/group_tt.Rd b/man/group_tt.Rd index 0193a5ed..79561cf9 100644 --- a/man/group_tt.Rd +++ b/man/group_tt.Rd @@ -4,7 +4,7 @@ \alias{group_tt} \title{Spanning labels to identify groups of rows or columns} \usage{ -group_tt(x, i = NULL, j = NULL, indent = 1, ...) +group_tt(x, i = NULL, j = NULL, indent = 1) } \arguments{ \item{x}{A data frame or data table to be rendered as a table.} @@ -14,8 +14,6 @@ group_tt(x, i = NULL, j = NULL, indent = 1, ...) \item{j}{Column indices where the styling should be applied. Can be a single value, a vector, or a Perl-style regular expression applied to column names of the original data frame. If \code{colspan} is used, \code{j} must be of length 1.} \item{indent}{integer number of \code{pt} to use when indenting the non-labelled rows.} - -\item{...}{All additional arguments (ex: \code{italic}, \code{bold}, \code{color}) are automatically passed to the \code{style_tt()} function and applied to the labels.} } \description{ Spanning labels to identify groups of rows or columns diff --git a/man/style_tt.Rd b/man/style_tt.Rd index dbe94852..6fa4081d 100644 --- a/man/style_tt.Rd +++ b/man/style_tt.Rd @@ -23,7 +23,8 @@ style_tt( tabularray_inner = NULL, tabularray_outer = NULL, bootstrap_css = NULL, - bootstrap_css_rule = NULL + bootstrap_css_rule = NULL, + ... ) } \arguments{ @@ -78,6 +79,8 @@ style_tt( \item{bootstrap_css}{A vector of CSS style declarations to be applied (ex: \code{"font-weight: bold"}). Each element corresponds to a cell defined by \code{i} and \code{j}.} \item{bootstrap_css_rule}{A string with complete CSS rules that apply to the table class specified using the \code{theme} argument of the \code{tt()} function.} + +\item{...}{extra arguments are ignored} } \value{ Returns a modified \code{tinytable} object with the applied styles. diff --git a/vignettes/tutorial.qmd b/vignettes/tutorial.qmd index 87d512db..a8282d65 100644 --- a/vignettes/tutorial.qmd +++ b/vignettes/tutorial.qmd @@ -544,7 +544,7 @@ Here is a table with both row and column headers, as well as some styling: ```{r} dat <- mtcars[1:9, 1:8] tt(dat) |> - group_tt(color = "teal", italic = TRUE, + group_tt( i = list("I like (fake) hamburgers" = 3, "She prefers halloumi" = 4, "They love tofu" = 7),