[Rd] xtable feature addition suggestion

Fernando Henrique Ferraz feferraz at ime.usp.br
Sun Jan 18 00:30:18 MET 2004


	Hi, attached follows a patch to add a feature that I think it would be useful having in the print.xtable function of the xtable package. It adds the option 'tabular.environment' to that function, which could be used to set an alternative tabular environment, as the name already suggests. 

	This is particulary useful when dealing with long tables, which do not fit in a single page. In the default behaviour, using \begin{tabular} ... \end{tabular}, everything that doesn't fit on the page dissappears. By using the LaTeX package 'longtable' and the 'tabular.environment="longtable"' option to print.xtable() this and other problems can be overcome, adding more flexiblity to the package.

	Thank you,

--
[]'s
Fernando Henrique Ferraz P. da Rosa
-------------- next part --------------
--- xtable_1.2-2/R/print.xtable.R	2004-01-17 20:43:04.000000000 -0200
+++ xtable_1.2-2-patched/R/print.xtable.R	2004-01-17 20:33:55.000000000 -0200
@@ -19,7 +19,7 @@
 ### License along with this program; if not, write to the Free
 ### Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 ### MA 02111-1307, USA
-print.xtable <- function(x,type="latex",file="",append=FALSE,floating=TRUE,table.placement="ht",caption.placement="bottom",latex.environments=c("center"),...) {
+print.xtable <- function(x,type="latex",file="",append=FALSE,floating=TRUE,table.placement="ht",caption.placement="bottom",latex.environments=c("center"),tabular.environment="tabular",...) {
 
   if (length(type)>1)
     stop("\"type\" must have length 1")
@@ -63,12 +63,12 @@
     }
 #    BTABULAR <- string("\\begin{tabular}{|") + paste(attr(x,"align"),collapse="|") + "|}\n\\hline\n"
 #    See e-mail from "BXC (Bendix Carstensen)" <bxc at novonordisk.com> dated Mon, 27 Aug 2001 10:11:54 +0200
-    BTABULAR <- paste("\\begin{tabular}{",
+    BTABULAR <- paste("\\begin{",tabular.environment,"}{",
                       paste(attr(x, "vsep"),
                             c(attr(x, "align"), "}\n\\hline\n"),
                             sep="", collapse=""),
                       sep="")
-    ETABULAR <- "\\hline\n\\end{tabular}\n"
+    ETABULAR <- paste("\\hline\n\\end{",tabular.environment,"}\n",sep="")
     BLABEL <- "\\label{"
     ELABEL <- "}\n"
     BCAPTION <- "\\caption{"


More information about the R-devel mailing list