You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
R-common/LongtableXtableHeader.R

31 lines
1.3 KiB
R

LongtableXtableHeader <- function(xtobject, caption.text, caption.label) {
# this function uses the \booktabs package
# should NOT be used together with booktabs = TRUE
ltxt.header <-
paste(paste("\\caption{", caption.text, "}", sep = "", collapse = ""),
paste("\\label{", caption.label, "}\\\\ ", sep = "", collapse = ""),
"\\toprule ",
attr(xtobject, "names")[1],
paste(" &", attr(xtobject, "names")[2:length(attr(xtobject, "names"))], collapse = ""),
"\\\\\\midrule ",
"\\endfirsthead ",
paste("\\multicolumn{",
ncol(xtobject),
"}{c}{{\\tablename\\ \\thetable{} -- continued from previous page}}\\\\ ",
sep = ""),
"\\toprule ",
attr(xtobject, "names")[1],
paste("&", attr(xtobject, "names")[2:length(attr(xtobject, "names"))], collapse = ""),
"\\\\\\midrule ",
"\\endhead ",
"\\midrule ",
paste("\\multicolumn{",
as.character(ncol(xtobject)),
"}{r}{{Continued on next page}}\\\\ ",
sep = "", collapse = ""),
"\\bottomrule \\endfoot ",
"\\bottomrule \\endlastfoot ",
collapse = "")
return(ltxt.header)
}