thomasp85 / patchwork

The Composer of ggplots
https://patchwork.data-imaginist.com
Other
2.47k stars 163 forks source link

`wrap_table()` removes `gt::fmt_markdown()` #402

Open jack-davison opened 4 weeks ago

jack-davison commented 4 weeks ago

gt version 0.11.0

patchwork version 1.3.0


reprex:

gt <- data.frame(x = "ug m<sup>-3</sup>") |> gt::gt() |> gt::fmt_markdown()

gt

image

patchwork::wrap_table(gt)

image


I wasn't sure if a) this was a known issue and b) whether there's a workaround to get subscripts/superscripts/etc. in a "wrapped table" in a patchwork assembly?

Cheers!

(I don't know if I should cc @teunbrand as I know you worked on gt grob outputs!)

teunbrand commented 4 weeks ago

R graphics doesn't really support markdown or html formatting out of the box, so I'm afraid you're hitting the limitations of the graphics system. You can swap out the text generating function, but I think there currently is no easy way to forward this from within {patchwork}.

gt <- data.frame(x = "ug m<sup>-3</sup>") |> gt::gt()
plot(gt::as_gtable(gt, text_grob = gridtext::richtext_grob))

Created on 2024-10-15 with reprex v2.1.1

jack-davison commented 4 weeks ago

Thanks - that makes sense to me!

plot(gt::as_gtable(gt, text_grob = gridtext::richtext_grob))

This actually does the job for my use-case as I don't necessarily need the other nice patchwork things (e.g., table header alignment with "space" etc.), just to stick a small table to a plot.

Happy to mark as closed if this is an impossible/unlikely to be achieved thing for patchwork.