]> git.donarmstrong.com Git - xtable.git/commitdiff
Merge branch 'master' into repeat_caption_in_longtable repeat_caption_in_longtable
authorDon Armstrong <don@donarmstrong.com>
Mon, 5 Dec 2016 22:18:18 +0000 (14:18 -0800)
committerDon Armstrong <don@donarmstrong.com>
Mon, 5 Dec 2016 22:18:18 +0000 (14:18 -0800)
pkg/R/print.xtable.R

index ce9c7bc52d0cae77f0f0860d9655b21012f0e4dd..aa1079dd73369d2c0122cfaafaf1a4118b7749e6 100644 (file)
@@ -439,9 +439,10 @@ 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
+    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
@@ -453,11 +454,25 @@ 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
+    COLNAMES <- COLNAMES + paste(CNAMES, collapse = STH)\r
     \r
-    result <- result + ETH + EROW\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
   if (include.rownames) {\r
     ## David G. Whiting in e-mail 2007-10-09\r