From 5ddeb8133f2fc83a0b5ef66e3ce9c315d0f58163 Mon Sep 17 00:00:00 2001 From: roosen Date: Mon, 30 Jan 2012 15:06:10 +0000 Subject: [PATCH] Introduced John Leonard's change regarding the inclusion of newline and hline when longtable and add.to.rows are both used. git-svn-id: svn://scm.r-forge.r-project.org/svnroot/xtable@23 edb9625f-4e0d-4859-8d74-9fd3b1da38cb --- pkg/NEWS | 2 ++ pkg/R/print.xtable.R | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/pkg/NEWS b/pkg/NEWS index d9b5d53..0498e42 100644 --- 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. diff --git a/pkg/R/print.xtable.R b/pkg/R/print.xtable.R index a69f927..9b73f31 100644 --- a/pkg/R/print.xtable.R +++ b/pkg/R/print.xtable.R @@ -93,6 +93,11 @@ print.xtable <- function( # Add further commands at the end of rows if (type=="latex") { PHEADER <- "\\hline\n" + # John Leonard October 21, 2011 + # The extra \hline gets in the way when using longtable and add.to.row + if(tabular.environment=="longtable" && !is.null(add.to.row) ) { + PHEADER <- "" + } } else { PHEADER <- "" } @@ -418,6 +423,14 @@ print.xtable <- function( full[,multiplier*(0:(ncol(x)+pos-1))+6] <- ETD full[,multiplier*(ncol(x)+pos)+2] <- paste(EROW, lastcol[-(1:2)], sep=" ") + + # John Leonard October 21, 2011 + # Removes the "\\" from the last row of the contents so that + # booktabs (\bottomline) appears in the correct position. + if(tabular.environment=="longtable" & !is.null(add.to.row)) { + full[dim(full)[1],multiplier*(ncol(x)+pos)+2] <- "%\n" + } + if (type=="latex") full[,2] <- "" result <- result + lastcol[2] + paste(t(full),collapse="") if (!only.contents) { -- 2.39.2