nutterb / pixiedust

Tables So Beautifully Fine-Tuned You Will Believe It's Magic.
178 stars 18 forks source link

Streamline multiline cells #120

Open nutterb opened 5 years ago

nutterb commented 5 years ago

It seems like it should be easier to do something like the following:

inspired by https://stackoverflow.com/questions/52036731/r-kableextra-latex-add-linebreaks-to-rotated-header-row

See also https://tex.stackexchange.com/questions/2441/how-to-add-a-forced-line-break-inside-a-table-cell

Will require adding makecell as a LaTeX package that pixiedust uses.

library(pixiedust)

dt_lb <- data.frame(
  Item = c("Hello\nWorld", "This\nis a cat"),
  Value = c(10, 100)
)

dust(dt_lb) %>% 
  sprinkle_colnames("Item\nName", "Value\nNumber") %>% 
  sprinkle(rotate_degree = -90,
           part = "head") %>% 
  sprinkle_print_method("html")