]> git.donarmstrong.com Git - xtable.git/commitdiff
Introduced John Leonard's change regarding the inclusion of newline and hline when...
authorroosen <roosen@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Mon, 30 Jan 2012 15:06:10 +0000 (15:06 +0000)
committerroosen <roosen@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Mon, 30 Jan 2012 15:06:10 +0000 (15:06 +0000)
git-svn-id: svn://scm.r-forge.r-project.org/svnroot/xtable@23 edb9625f-4e0d-4859-8d74-9fd3b1da38cb

pkg/NEWS
pkg/R/print.xtable.R

index d9b5d53fa3c00ebfe5ed6ea89b5060a7f4041abe..0498e4202d63558c13b3feab2772dffc3814f988 100644 (file)
--- a/pkg/NEWS
+++ b/pkg/NEWS
@@ -8,6 +8,8 @@
   * Added "short.caption" argument to "print" to let the user 
     specify a Latex short caption used when creating a list of tables. 
   * Added an "is.null()" check on the "table.placement" argument.
+  * Put in some changes from John Leonard regarding the placement
+    of newlines when "longtable" and "add.to.row" are used together.
   * Included "print.xtable" in the exported methods in the NAMESPACE file.
   * Added an example of header and footer specification with longtable
     to the vignette.  
index a69f927cc8ff2aaa9e709ee678f21a052d839d1a..9b73f311045df0c0d8d7929b2d49dc16e5d71a97 100644 (file)
@@ -93,6 +93,11 @@ print.xtable <- function(
   # Add further commands at the end of rows\r
   if (type=="latex") {\r
      PHEADER <- "\\hline\n"\r
+        # John Leonard <jleonard99@gmail.com> October 21, 2011\r
+        # The extra \hline gets in the way when using longtable and add.to.row\r
+        if(tabular.environment=="longtable" && !is.null(add.to.row) ) {\r
+          PHEADER <- ""\r
+     }    \r
   } else {\r
      PHEADER <- ""\r
   }\r
@@ -418,6 +423,14 @@ print.xtable <- function(
   full[,multiplier*(0:(ncol(x)+pos-1))+6] <- ETD\r
 \r
   full[,multiplier*(ncol(x)+pos)+2] <- paste(EROW, lastcol[-(1:2)], sep=" ")\r
+  \r
+  # John Leonard <jleonard99@gmail.com> October 21, 2011\r
+  # Removes the "\\" from the last row of the contents so that \r
+  # booktabs (\bottomline) appears in the correct position.\r
+  if(tabular.environment=="longtable" & !is.null(add.to.row)) {\r
+    full[dim(full)[1],multiplier*(ncol(x)+pos)+2] <- "%\n" \r
+  }\r
+  \r
   if (type=="latex") full[,2] <- ""\r
   result <- result + lastcol[2] + paste(t(full),collapse="")\r
   if (!only.contents) {\r