library(dplyr)
library(huxtable)
knitr::opts_chunk$set(echo = FALSE)
options(
  huxtable.bookdown = TRUE,
  huxtable.add_colnames = TRUE
)
long_caption <- 'This is a long caption. This is a long caption. This is a long caption. This is a long caption. This is a long caption. This is a long caption. This is a long caption. This is a long caption. This is a long caption.'

Left aligned layout

This is the layout I personally would like to use. But I feel like huxtable's caption looks crammed:

head(mtcars[, 1:2], 10) %>% 
  tibble::rownames_to_column() %>% 
  as_huxtable() %>%
  theme_article() %>% 
  huxtable::set_position("left") %>% 
  set_caption(long_caption)

I would prefer it to span the whole width like this one by kable (but without having the table also span the whole width):

knitr::kable(
  head(mtcars[, 1:2], 10),
  caption = long_caption
)

More like in this figure:

plot(runif(10))

Centered layout

When using a centered layout I feel the same. This seems too crammed:

head(mtcars[, 1:2], 10) %>% 
  tibble::rownames_to_column() %>% 
  as_huxtable() %>%
  theme_article() %>% 
  set_caption(long_caption)

This looks better:

plot(runif(10))


hughjonesd/huxtable documentation built on Feb. 17, 2024, 12:20 a.m.