diff --git a/R/utils.R b/R/utils.R index 42a3bc693b5191310cc31c361cbaf3751903563d..4b82bd6175d29d9799bc7879cf0541e4381adab7 100644 --- a/R/utils.R +++ b/R/utils.R @@ -249,6 +249,7 @@ print_table <- function(d, na = "\\textemdash", rm_dup = NULL, landscape = FALSE, + file = "", ...) { stopifnot(inherits(d, c("matrix", "data.frame"))) @@ -375,6 +376,7 @@ print_table <- function(d, } print_xtable <- xtable::print.xtable + formals(print_xtable)$file <- file formals(print_xtable)$type <- "latex" formals(print_xtable)$caption.placement <- "top" formals(print_xtable)$size <- "\\small" @@ -391,9 +393,9 @@ print_table <- function(d, formals(print_xtable)$comment <- FALSE for (i in seq_along(n)) { - if (i > 1) cat("\n\\clearpage\n") - if (i == 2) cat("\\captionsetup[table]{list=no}\n") - if (landscape) cat("\\begin{landscape}\n") + if (i > 1) cat("\n\\clearpage\n", file = file, append = TRUE) + if (i == 2) cat("\\captionsetup[table]{list=no}\n", file = file, append = TRUE) + if (landscape) cat("\\begin{landscape}\n", file = file, append = TRUE) if (i == 1) { idxs <- 1:n[i] @@ -402,7 +404,7 @@ print_table <- function(d, idxs <- (n[i - 1] + 1):n[i] caption <- sprintf("%s---Continued", cap1) label <- NULL - cat("\\addtocounter{table}{-1}\n") + cat("\\addtocounter{table}{-1}\n", file = file, append = TRUE) } tbl <- d[idxs, ] @@ -444,8 +446,12 @@ print_table <- function(d, print_xtable(x = tbl, hline.after = hline_after, add.to.row = add_to_row, ...) - if (landscape) cat("\\end{landscape}\n") - if (i > 1 && i == length(n)) cat("\\captionsetup[table]{list=yes}\n") + if (landscape) { + cat("\\end{landscape}\n", file = file, append = TRUE) + } + if (i > 1 && i == length(n)) { + cat("\\captionsetup[table]{list=yes}\n", file = file, append = TRUE) + } } invisible() diff --git a/inst/tinytest/test_colors.R b/inst/tinytest/test_colors.R index 7779e4e98a52dae66cfa475dedf52c4064a5d043..be89bcb17087eff0fe88ddc372464491d1aaeaef 100644 --- a/inst/tinytest/test_colors.R +++ b/inst/tinytest/test_colors.R @@ -6,10 +6,10 @@ using("checkmate") # test retrieval of color palettes n <- 10L x <- get_colors(n = n) -checkmate::expect_character(x, len = n, any.missing = FALSE, unique = TRUE) +expect_character(x, len = n, any.missing = FALSE, unique = TRUE) # test setting the hinge location in color palette n <- 19L fun <- set_hinge(x = c(-3, 7), hinge = 0) x <- fun(n) -checkmate::expect_character(x, len = n, any.missing = FALSE, unique = TRUE) +expect_character(x, len = n, any.missing = FALSE, unique = TRUE)