hughjonesd / huxtable

An R package to create styled tables in multiple output formats, with a friendly, modern interface.
http://hughjonesd.github.io/huxtable
Other
321 stars 28 forks source link

Greek symbols not working in huxtable #217

Closed stanleesocca closed 2 years ago

stanleesocca commented 2 years ago

Hi,

Thanks for creating this package. I was working with Huxtable earlier on a larger problem case, but struggle to get the table formatted the way I wanted it. I needed to provide a header (colnames) with greek and scientific notation as text. Using huxtable, it seem greek latex formatting is not supported. Is there a way you can help me to solve this problem?

Here is a code snippet, I'm working with.

cnames <- c("Time (days)", "$O_2$ flux\n($mmol~O_2~m^{-2}d^{-1}$)","$SO_4^{2-}$ flux\n($mmol~SO_4~m^{-2}d^{-1}$)", "DIC flux\n($mmol~DIC~m^{-2}d^{-1}$)")

flux_tab <- matrix(1:12, ncol = 4)
flux_tab <- as.data.frame(flux_tab) %>% 
  huxtable() %>%  
  set_contents(1, 1:4, cnames)

flux_tab

Thanks and hopefully, I can get this package to work on my use case.

hughjonesd commented 2 years ago

What does "not supported" mean? Please explain what happens when you use the snippet above.

When I run quick_pdf(flux_tab) it shows me the column names escaped, i.e. exactly as written. If I run escape_contents(flux_tab) <- FALSE and then run quick_pdf, everything seems to work fine. This is expected behaviour.