From 7b0087bd724f4319783675a301e5564f8f0db6ae Mon Sep 17 00:00:00 2001 From: Vincent Arel-Bundock Date: Thu, 12 Dec 2024 21:35:45 -0500 Subject: [PATCH] pdf fixes --- R/save_tt.R | 2 +- R/style_string.R | 13 ------------- inst/tinytest/test-pdf.R | 10 ++++++++++ 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/R/save_tt.R b/R/save_tt.R index dc7813d7..b11caee4 100644 --- a/R/save_tt.R +++ b/R/save_tt.R @@ -158,7 +158,7 @@ latex_standalone <- " \\usepackage{rotating} \\usepackage{float} \\usepackage[normalem]{ulem} -\\usepackage[HTML]{xcolor} +\\usepackage[x11names, svgnames]{xcolor} \\UseTblrLibrary{booktabs} \\UseTblrLibrary{siunitx} \\newcommand{\\tinytableTabularrayUnderline}[1]{\\underline{#1}} diff --git a/R/style_string.R b/R/style_string.R index 1e78b1eb..4e009fc7 100644 --- a/R/style_string.R +++ b/R/style_string.R @@ -81,19 +81,6 @@ style_string_typst <- function(n, styles) { } - -style_notes <- function(x) { - fun <- switch(x@output, - "typst" = style_string_typst, - "html" = style_string_html, - "html_portable" = style_string_html, - "latex" = style_string_latex, - function(k, ...) identity(k) - ) - x@notes <- lapply(x@notes, fun, x@style_notes) - return(x) -} - style_notes <- function(x) { fun <- switch(x@output, "typst" = style_string_typst, diff --git a/inst/tinytest/test-pdf.R b/inst/tinytest/test-pdf.R index 432dd384..18073675 100644 --- a/inst/tinytest/test-pdf.R +++ b/inst/tinytest/test-pdf.R @@ -30,5 +30,15 @@ expect_warning( expect_true("somelog.log" %in% list.files(dest_dir)) +# Issue #395 +x <- mtcars[1:4, 1:5] +fn <- tempfile(fileext = ".pdf") +cap <- "A simple \\texttt{tinytable} example." +not <- "Nullam odio est, ullamcorper scelerisque lectus a, eleifend luctus nisl. Etiam ullamcorper, nibh vel interdum auctor, odio nulla mollis tortor, vel fringilla ante quam quis est." +tt(x, caption = cap, notes = not, width = .5) |> + style_tt( i = 1:3, j = 1:2, background = "#1ecebf", bold = TRUE) |> + group_tt(j = list("Halloumi" = 1:2, "Tofu" = 4:5)) |> + save_tt(fn, overwrite = TRUE) + # Clean slate suppressWarnings(invisible(file.remove(list.files(dest_dir))))