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

Automatically break wide tables #46

Closed kusmi closed 6 years ago

kusmi commented 6 years ago

If I have a wide table, it just overflows the paper on latex output. E.g.:

Example.pdf

library(huxtable)
ht <- hux(
        Huxtable = c('John Smith', 'Jane Doe', 'David Hugh-Jones'),
        Salary = c(50000, 50000, 40000),
        Salary2 = c(50000, 50000, 40000),
        Salary3 = c(50000, 50000, 40000),
        Salary4 = c(50000, 50000, 40000),
        Salary5 = c(50000, 50000, 40000),
        Salary6 = c(50000, 50000, 40000),
        Salary7 = c(50000, 50000, 40000),
        Salary8 = c(50000, 50000, 40000),
        add_colnames = TRUE
      )

bold(ht)[1,]           <- TRUE
bottom_border(ht)[1,]  <- 1
align(ht)[,2]          <- 'right'
right_padding(ht)      <- 10
left_padding(ht)       <- 10
#width(ht)              <- 0.35
number_format(ht)      <- 0

ht

so it would be nice, if huxtable would support that as well. The only other table package which supports breaking wide tables seems to be pander.

hughjonesd commented 6 years ago

I understand the issue, but I don't know how to automatically decide if a table will overrun or not from within LaTeX itself - let alone programmatically from within R. Suggestions welcome!

hughjonesd commented 6 years ago

I just wondered if you realised you can do

ht1 <- ht[, 1:5]
ht2 <- ht[, c(1, 6:9)]

and break the files yourself.

hughjonesd commented 6 years ago

Closing. Feel free to reopen if you have suggestions.