I've been trying to create a table with a header that contains a like break. I am not too ambitious here and do not really care whether I just break extremely long strings or just have a two-line header in general.
dat <- matrix(round(rnorm(9, 20, 10)), 3, 3)
colnames(dat) <- c("some very long colname","short","another toooooooolong colname")
require(xtable)
m <- xtable(dat)
print(m,
floating=FALSE,
hline.after=NULL,
size="\\footnotesize",
tabular.environment="tabular",
add.to.row=list(pos=list(-1,0,nrow(m),0
),
command=c('\\toprule ',
'\\midrule ',
'\\bottomrule',
'\\\\ \\rowcolor[gray]{.9}'
)
)
)
Is there a way to line break the header, because my table is not fitting on the page anymore, though I use landscape
already. Some sanitize.rownames
based trick? Fiddled around with \shortstack
but could not get it to go...