patchwork icon indicating copy to clipboard operation
patchwork copied to clipboard

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

Open jack-davison opened this issue 1 year ago • 2 comments

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!)

jack-davison avatar Oct 15 '24 12:10 jack-davison

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

teunbrand avatar Oct 15 '24 14:10 teunbrand

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.

jack-davison avatar Oct 15 '24 15:10 jack-davison