jthomasmock / gtExtras

A Collection of Helper Functions for the gt Package.
https://jthomasmock.github.io/gtExtras/
Other
193 stars 26 forks source link

render to PDF #65

Closed julianmatthewman closed 2 years ago

julianmatthewman commented 2 years ago

Hi,

thanks for creating an awesome package! I'm trying to create tables with inline visualisations and render these to PDF via quarto or directly with knitr, however this throws a "compilation failed- error". HTML and Word formats work fine.

Apologies, I'm not sure if this should be a bug report or a feature request, and also if this should be reported as a issue here or at the gt repository. I'm also not able to render tables with inline visualisations to PDF when using functions from kableExtra within gt as described in your blog-post "Embedding custom HTML in gt tables"(https://themockup.blog/posts/2020-10-31-embedding-custom-features-in-gt-tables/#gt-kableextra). Rendering to PDF does however work for kables including visualisations created with kableExtra.

Many thanks in advance! Rendering to PDF would be a brilliant feature addition, but I do understand that gtExtras is HTML focused.

---
title: "gtExtras reprex"
format: pdf
---
library(gt)
library(gtExtras)

mtcars |>
    gt() |> 
    gt_plt_bar(hp)
compilation failed- error
You can't use `macro parameter character #' in restricted horizontal mode.
jthomasmock commented 2 years ago

Howdy, thanks for the reprex!

Unfortunately, I have no expectation that gtExtras will work with PDF as most of the internals are generating complex HTML output.

One option, albeit not ideal, is to output to .png with gtsave() and then bring the image of the table back in with knitr::include_graphics() or a ![](image.png).

I have no plans to backport gtExtras features to PDF support, as I don't have the expertise to enable it via LaTeX.

julianmatthewman commented 2 years ago

Makes sense; thank you for considering and suggesting a workaround!