From 55c416e210f95eee3d02fcfd6b4298c5e0b2209d Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Mon, 5 Dec 2016 13:38:42 -0800 Subject: [PATCH] repeat captions when using longtable --- pkg/R/print.xtable.R | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/pkg/R/print.xtable.R b/pkg/R/print.xtable.R index 75bf09e..d748924 100644 --- a/pkg/R/print.xtable.R +++ b/pkg/R/print.xtable.R @@ -524,9 +524,11 @@ print.xtable <- function(x, ## Claudio Agostinelli dated 2006-07-28 ## include.colnames, include.rownames if (include.colnames) { - result <- result + BROW + BTH + COLNAMES <- string("", file = file, append = append) + + COLNAMES <- COLNAMES + BROW + BTH if (include.rownames) { - result <- result + STH + COLNAMES <- COLNAMES + STH } ## David G. Whiting in e-mail 2007-10-09 if (is.null(sanitize.colnames.function)) { @@ -538,9 +540,24 @@ print.xtable <- function(x, ##added by Markus Loecher, 2009-11-16 CNAMES <- paste("\\begin{sideways}", CNAMES, "\\end{sideways}") } - result <- result + paste(CNAMES, collapse = STH) - - result <- result + ETH + EROW + COLNAMES <- COLNAMES + paste(CNAMES, collapse = STH) + + COLNAMES <- COLNAMES + ETH + EROW + result <- result + COLNAMES + if (tabular.environment=="longtable") { + result <- result + "\\endfirsthead\n" + if (booktabs) { + if (!is.null(caption)) { + result <- result + "\\caption[]{"+caption+"} \\\\\n" + } + result <- result + "\\toprule\n"+ COLNAMES + "\\midrule\n\\endhead\n" + } else { + if (!is.null(caption)) { + result <- result + "\\caption[]{"+caption+"}\n" + } + result <- result + COLNAMES + "\\endhead\n" + } + } } cols <- matrix("", nrow = nrow(x), ncol = ncol(x)+pos) -- 2.39.5