]> git.donarmstrong.com Git - xtable.git/commitdiff
repeat captions when using longtable
authorDon Armstrong <don@donarmstrong.com>
Mon, 5 Dec 2016 21:38:42 +0000 (13:38 -0800)
committerDon Armstrong <don@donarmstrong.com>
Mon, 5 Dec 2016 21:38:42 +0000 (13:38 -0800)
pkg/R/print.xtable.R

index 75bf09e4f03203ede4b9e45be8d05a069e293385..d748924366c5a4ecc434a8aa92eb2e7309e9b7da 100644 (file)
@@ -524,9 +524,11 @@ print.xtable <- function(x,
     ## Claudio Agostinelli <claudio@unive.it> dated 2006-07-28\r
     ## include.colnames, include.rownames\r
     if (include.colnames) {\r
-        result <- result + BROW + BTH\r
+        COLNAMES <- string("", file = file, append = append)\r
+\r
+        COLNAMES <- COLNAMES + BROW + BTH\r
         if (include.rownames) {\r
-            result <- result + STH\r
+            COLNAMES <- COLNAMES + STH\r
        }\r
         ## David G. Whiting in e-mail 2007-10-09\r
         if (is.null(sanitize.colnames.function)) {\r
@@ -538,9 +540,24 @@ print.xtable <- function(x,
             ##added by Markus Loecher, 2009-11-16\r
             CNAMES <- paste("\\begin{sideways}", CNAMES, "\\end{sideways}")\r
        }\r
-        result <- result + paste(CNAMES, collapse = STH)\r
-\r
-        result <- result + ETH + EROW\r
+        COLNAMES <- COLNAMES + paste(CNAMES, collapse = STH)\r
+\r
+        COLNAMES <- COLNAMES + ETH + EROW\r
+        result <- result + COLNAMES\r
+        if (tabular.environment=="longtable") {\r
+            result <- result + "\\endfirsthead\n"\r
+            if (booktabs) {\r
+                if (!is.null(caption)) {\r
+                    result <- result + "\\caption[]{"+caption+"} \\\\\n"\r
+                }\r
+                result <- result + "\\toprule\n"+ COLNAMES + "\\midrule\n\\endhead\n"\r
+            } else {\r
+                if (!is.null(caption)) {\r
+                    result <- result + "\\caption[]{"+caption+"}\n"\r
+                }\r
+                result <- result + COLNAMES + "\\endhead\n"\r
+            }\r
+        }\r
     }\r
 \r
     cols <- matrix("", nrow = nrow(x), ncol = ncol(x)+pos)\r