]> git.donarmstrong.com Git - xtable.git/commitdiff
Added "scalebox" argument to print.xtable. Commented out longtable example with...
authorroosen <roosen@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Tue, 7 Feb 2012 09:11:53 +0000 (09:11 +0000)
committerroosen <roosen@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Tue, 7 Feb 2012 09:11:53 +0000 (09:11 +0000)
git-svn-id: svn://scm.r-forge.r-project.org/svnroot/xtable@28 edb9625f-4e0d-4859-8d74-9fd3b1da38cb

pkg/NEWS
pkg/R/print.xtable.R
pkg/inst/doc/xtableGallery.snw
pkg/man/print.xtable.Rd

index 48e7441b5f5d205da4e4cb968203a700912f00d5..1c407bd27abf632d22af71e3276186c84886ce06 100644 (file)
--- a/pkg/NEWS
+++ b/pkg/NEWS
   * Added "booktabs" argument to use the "\toprule", "\midrule", and  
     "\bottomrule" tags from the Latex "booktabs" package rather than
        using "\hline" for all horizontal lines.
+  * Added "scalebox" argument to include a "\scalebox" clause around
+    the tabular environment with the specified value used as the
+    scaling factor.    
   * Changed the "print.xtable()" arguments to use "getOption()"
     to check the options for a default value.  This was suggested
        since "print.xtable()" has a lot of arguments that the user
        will typically leave unchanged between tables.
   * Added an "is.null()" check on the "table.placement" argument.
-  * Added an example of header and footer specification with longtable
-    to the vignette.  
   * Added examples using the new arguments to the vignette.
        
 1.6-0 (2011-10-07)
index bae66a1679d36869295c81e5b4274d5feda4e4ea..8c56c33875fe660c5ef4fde002e50ea7ab39db8b 100644 (file)
@@ -51,6 +51,7 @@ print.xtable <- function(
   rotate.rownames=getOption("xtable.rotate.rownames", FALSE),\r
   rotate.colnames=getOption("xtable.rotate.colnames", FALSE),\r
   booktabs = getOption("xtable.booktabs", FALSE),\r
+  scalebox = getOption("xtable.scalebox", NULL),\r
   ...) {\r
   # If caption is length 2, treat the second value as the "short caption"\r
   caption <- attr(x,"caption",exact=TRUE)\r
@@ -206,7 +207,7 @@ print.xtable <- function(
                       paste(c(attr(x, "align",exact=TRUE)[tmp.index.start:length(attr(x,"align",exact=TRUE))], "}\n"),\r
                             sep="", collapse=""),\r
                       sep="")\r
-    \r
+\r
     ## fix 10-26-09 (robert.castelo@upf.edu) the following 'if' condition is added here to support\r
     ## a caption on the top of a longtable\r
     if (tabular.environment == "longtable" && caption.placement=="top") {\r
@@ -222,6 +223,12 @@ print.xtable <- function(
     BTABULAR <- paste(BTABULAR,lastcol[1], sep="")\r
     # the \hline at the end, if present, is set in full matrix    \r
     ETABULAR <- paste("\\end{",tabular.environment,"}\n",sep="")\r
+\r
+       ## Add scalebox - CR, 7/2/12\r
+       if (!is.null(scalebox)){\r
+         BTABULAR <- paste("\\scalebox{", scalebox, "}{\n", BTABULAR, sep="")\r
+         ETABULAR <- paste(ETABULAR, "}\n", sep="")\r
+       }\r
     \r
     # BSIZE contributed by Benno <puetz@mpipsykl.mpg.de> in e-mail dated Wednesday, December 01, 2004\r
     if (is.null(size) || !is.character(size)) {\r
index da839116f7ab2ee00bae3bd762e725475d42e3dc..c69c98e4176719d8a04120dd4ef1be7431bbc1db 100644 (file)
@@ -430,7 +430,6 @@ print(xtable(anova(glm.D93)),size="small",floating=FALSE)
 
 \subsection{Long tables}
 Remember to insert \verb|\usepackage{longtable}| in your \LaTeX preamble.
-See Table \ref{tabbig}.
 
 <<longtable>>=
 
@@ -443,37 +442,40 @@ x.big <- xtable(x,label='tabbig',
 print(x.big,tabular.environment='longtable',floating=FALSE)
 @
 
-\subsubsection{Long tables with the header on each page}
-
-The {\tt add.to.row} argument can be used to display the header 
-for a long table on each page, and to add a "continued" footer
-on all pages except the last page.  See Table \ref{tabbig2}.
-
-<<results=tex>>=
-library(xtable)
-x<-matrix(rnorm(1000), ncol = 10)
-
-addtorow<-list()
-addtorow$pos<-list()
-addtorow$pos[[1]]<-c(0)
-addtorow$command<-c(paste(
-    "\\hline \n",
-    "  \\endhead \n",
-    "  \\hline \n",
-    "  {\\footnotesize Continued on next page} \n",
-    "  \\endfoot \n",
-    "  \\endlastfoot \n",sep=""))
-x.big2 <- xtable(x, label = "tabbig2", 
-    caption = "Example of longtable with the header on each page")
-print(x.big2, tabular.environment = "longtable", floating = FALSE,
-include.rownames=FALSE,add.to.row=addtorow,hline.after=c(-1) )
-@
+%%
+%% The column name alignment is off in the following example.
+%% It needs some revision before exposing it. - CR, 7/2/2012
+%%
+%
+%\subsubsection{Long tables with the header on each page}
+%
+%The {\tt add.to.row} argument can be used to display the header 
+%for a long table on each page, and to add a "continued" footer
+%on all pages except the last page. 
+%
+%<<results=tex>>=
+%library(xtable)
+%x<-matrix(rnorm(1000), ncol = 10)
+%addtorow<-list()
+%addtorow$pos<-list()
+%addtorow$pos[[1]]<-c(0)
+%addtorow$command<-c(paste(
+%    "\\hline \n",
+%    "  \\endhead \n",
+%    "  \\hline \n",
+%    "  {\\footnotesize Continued on next page} \n",
+%    "  \\endfoot \n",
+%    "  \\endlastfoot \n",sep=""))
+%x.big2 <- xtable(x, label = "tabbig2", 
+%    caption = "Example of longtable with the header on each page")
+%print(x.big2, tabular.environment = "longtable", floating = FALSE,
+%include.rownames=FALSE, add.to.row=addtorow, hline.after=c(-1) )
+%@
 
 \subsection{Sideways tables} 
 Remember to insert \verb|\usepackage{rotating}| in your LaTeX preamble.
 Sideways tables can't be forced in place with the `H' specifier, but you can 
 use the \verb|\clearpage| command to get them fairly nearby.
-See Table \ref{tabsmall}.
 
 <<>>=
 x <- x[1:30,]
@@ -485,6 +487,18 @@ print(x.small,floating.environment='sidewaystable')
 @
 \clearpage
 
+\subsection{Rescaled tables} 
+Specify a \code{scalebox} value to rescale the table.
+
+<<>>=
+x <- x[1:20,]
+x.rescale <- xtable(x,label='tabrescaled',caption='A rescaled table')
+@
+
+<<results=tex>>=
+print(x.rescale, scalebox=0.7)
+@
+
 \section{Suppressing Printing}
 By default the {\tt print} method will print the LaTeX or HTML to standard
 output and also return the character strings invisibly.  The printing to
index 03faef6bc331bf119ddb19c4cd8a936f9b57a286..1f7271e8368daf165d398e98a4e63c7c159e2db0 100644 (file)
@@ -32,6 +32,7 @@
   rotate.rownames=getOption("xtable.rotate.rownames", FALSE),\r
   rotate.colnames=getOption("xtable.rotate.colnames", FALSE),\r
   booktabs = getOption("xtable.booktabs", FALSE),\r
+  scalebox = getOption("xtable.scalebox", NULL),\r
   ...)}\r
 \arguments{\r
   \item{x}{An object of class \code{"xtable"}.}\r
@@ -70,6 +71,7 @@
   \item{rotate.rownames}{If \code{TRUE}, the row names are displayed vertically in LaTeX.}\r
   \item{rotate.colnames}{If \code{TRUE}, the column names are displayed vertically in LaTeX.}\r
   \item{booktabs}{If \code{TRUE}, the \code{toprule}, \code{midrule} and \code{bottomrule} tags from the LaTex "booktabs" package are used rather than \code{hline} for the horizontal line tags.}\r
+  \item{scalebox}{If not \code{NULL}, a \code{scalebox} clause will be added around the tabular environment with the specified value used as the scaling factor.}\r
   \item{...}{Additional arguments.  (Currently ignored.)}\r
 }\r
 \details{\r