]> git.donarmstrong.com Git - xtable.git/commitdiff
CR: Updates for next release
authorroosen <roosen@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Sun, 24 Feb 2013 17:37:47 +0000 (17:37 +0000)
committerroosen <roosen@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Sun, 24 Feb 2013 17:37:47 +0000 (17:37 +0000)
git-svn-id: svn://scm.r-forge.r-project.org/svnroot/xtable@40 edb9625f-4e0d-4859-8d74-9fd3b1da38cb

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

index 10a193a3e35a58ad98527193d4a6ee2601552f8f..0a7101592a6648f6bdf9cf087c3962d7775c92b8 100644 (file)
--- a/pkg/NEWS
+++ b/pkg/NEWS
@@ -1,14 +1,23 @@
-1.7-1 (NOT YET RELEASED)
-  * Fixed logicals bug (number 1911)
+1.7-1 (2013-02-24)
+  * Fixed logicals bug (Req #1911)
   * Changed implementation of centering of tables. Instead of
-    inserting a centred environment, now a \centering command is
-    inserted. Response to request #2104.
-  * Implemented request #2168 which allows for margin tables as
-    possible with document class tufte-handout. An example of usage is
-    found in the vignette produced by margintable.Rnw which is in
-    inst/doc.
-
-1.7-0
+    inserting a centered environment, now a \centering command is
+    inserted. (Req #2104)
+  * Allow for margin tables as possible with document class 
+    tufte-handout. An example of usage is found in the vignette 
+       produced by margintable.Rnw which is in inst/doc. (Req #2168)
+  * Added "timestamp" argument to print.xtable().  Set it to NULL
+    if no timestamp is desired. (Req #2246)
+  * Added "comment" argument to print.xtable().  Set it to FALSE
+    to exclude the version and timestamp comment. (Req #2246)
+  * Added "caption.width" argument.  If not NULL then the caption
+    is placed in a "parbox" of the specified width. (Req #2247)
+  * Remove the check on whether the "floating.environment" is
+    in a list of known floating environments. Users want to use
+       floating environments from multiple options LaTeX 
+       packages (Req #2488, #2578)
+       
+1.7-0 (2012-02-10)
   * Added some vectorization code to improve performance.
   * Let "caption" be length 2, in which case the second value is 
     the short caption used when creating a list of tables.
index c0cce93ef7f9a2a37050769bf1b71e3a141a4fc2..0060222bae9236e666b613c2a3d152675ee2d49c 100644 (file)
@@ -2,7 +2,7 @@
 ###\r
 ### Produce LaTeX and HTML tables from R objects.\r
 ###\r
-### Copyright 2000-2012 David B. Dahl <dahl@stat.tamu.edu>\r
+### Copyright 2000-2013 David B. Dahl <dahl@stat.tamu.edu>\r
 ###\r
 ### Maintained by Charles Roosen <croosen@mango-solutions.com>\r
 ###\r
@@ -29,6 +29,7 @@ print.xtable <- function(x,
   floating.environment = getOption("xtable.floating.environment", "table"),\r
   table.placement = getOption("xtable.table.placement", "ht"),\r
   caption.placement = getOption("xtable.caption.placement", "bottom"),\r
+  caption.width = getOption("xtable.caption.width", NULL),\r
   latex.environments = getOption("xtable.latex.environments", c("center")),\r
   tabular.environment = getOption("xtable.tabular.environment", "tabular"),\r
   size = getOption("xtable.size", NULL),\r
@@ -52,7 +53,8 @@ print.xtable <- function(x,
   booktabs = getOption("xtable.booktabs", FALSE),\r
   scalebox = getOption("xtable.scalebox", NULL),\r
   width = getOption("xtable.width", NULL),\r
-  timestamp = date(),\r
+  comment = getOption("xtable.comment", TRUE),\r
+  timestamp = getOption("xtable.timestamp", date()),\r
   ...)\r
 {\r
     ## If caption is length 2, treat the second value as the "short caption"\r
@@ -121,11 +123,11 @@ print.xtable <- function(x,
         ## Original code before changes in version 1.6-1\r
         ## PHEADER <- "\\hline\n"\r
 \r
-       ## booktabs code from Matthieu Stigler <matthieu.stigler@gmail.com>,\r
+           ## booktabs code from Matthieu Stigler <matthieu.stigler@gmail.com>,\r
         ## 1 Feb 2012\r
         if(!booktabs){\r
             PHEADER <- "\\hline\n"\r
-       } else {\r
+           } else {\r
             PHEADER <- ifelse(-1%in%hline.after, "\\toprule\n", "")\r
             if(0%in%hline.after) {\r
                 PHEADER <- c(PHEADER, "\\midrule\n")\r
@@ -142,13 +144,13 @@ print.xtable <- function(x,
     if (!is.null(hline.after)) {\r
         ## booktabs change - Matthieu Stigler: fill the hline arguments\r
         ## separately, 1 Feb 2012\r
-       ##\r
+           ##\r
         ## Code before booktabs change was:\r
-       ##    add.to.row$pos[[npos+1]] <- hline.after\r
+           ##    add.to.row$pos[[npos+1]] <- hline.after\r
 \r
         if (!booktabs){\r
             add.to.row$pos[[npos+1]] <- hline.after\r
-       } else {\r
+           } else {\r
             for(i in 1:length(hline.after)) {\r
                 add.to.row$pos[[npos+i]] <- hline.after[i]\r
             }\r
@@ -165,7 +167,7 @@ print.xtable <- function(x,
                 lastcol[addpos[j]+2] <- paste(lastcol[addpos[j]+2],\r
                                               paste(rep(add.to.row$command[i],\r
                                                         freq[j]),\r
-                                                    sep = "", collapse = ""),\r
+                                                sep = "", collapse = ""),\r
                                               sep = " ")\r
             }\r
         }\r
@@ -176,11 +178,13 @@ print.xtable <- function(x,
     if (!all(!is.na(match(type, c("latex","html"))))) {\r
         stop("\"type\" must be in {\"latex\", \"html\"}")\r
     }\r
-    if (!all(!is.na(match(floating.environment,\r
-                          c("table","table*","sidewaystable",\r
-                            "margintable"))))) {\r
-        stop("\"type\" must be in {\"table\", \"table*\", \"sidewaystable\", \"margintable\"}")\r
-    }\r
+    ## Disabling the check on known floating environments as many users \r
+    ## want to use additional environments.    \r
+    #    if (!all(!is.na(match(floating.environment,\r
+    #                          c("table","table*","sidewaystable",\r
+    #                            "margintable"))))) {\r
+    #        stop("\"type\" must be in {\"table\", \"table*\", \"sidewaystable\", \"margintable\"}")\r
+    #    }\r
     if (("margintable" %in% floating.environment)\r
         & (!is.null(table.placement))) {\r
         warning("margintable does not allow for table placement; setting table.placement to NULL")\r
@@ -256,17 +260,17 @@ print.xtable <- function(x,
                 tmp.index.start <- tmp.index.start + 1\r
             tmp.index.start <- tmp.index.start + 1\r
         }\r
-       ## Added "width" argument for use with "tabular*" or\r
+        ## Added "width" argument for use with "tabular*" or\r
         ## "tabularx" environments - CR, 7/2/12\r
-       if (is.null(width)){\r
+        if (is.null(width)){\r
             WIDTH <-""\r
-       } else if (is.element(tabular.environment,\r
+        } else if (is.element(tabular.environment,\r
                               c("tabular", "longtable"))){\r
             warning("Ignoring 'width' argument.  The 'tabular' and 'longtable' environments do not support a width specification.  Use another environment such as 'tabular*' or 'tabularx' to specify the width.")\r
             WIDTH <- ""\r
-       } else {\r
+        } else {\r
             WIDTH <- paste("{", width, "}", sep = "")\r
-       }\r
+        }\r
 \r
         BTABULAR <-\r
             paste("\\begin{", tabular.environment, "}",\r
@@ -300,12 +304,12 @@ print.xtable <- function(x,
         ## 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
+        ## Add scalebox - CR, 7/2/12\r
+        if (!is.null(scalebox)){\r
             BTABULAR <- paste("\\scalebox{", scalebox, "}{\n", BTABULAR,\r
                               sep = "")\r
             ETABULAR <- paste(ETABULAR, "}\n", sep = "")\r
-       }\r
+        }\r
 \r
         ## BSIZE contributed by Benno <puetz@mpipsykl.mpg.de> in e-mail\r
         ## dated Wednesday, December 01, 2004\r
@@ -320,13 +324,21 @@ print.xtable <- function(x,
             ESIZE <- "}\n"\r
         }\r
         BLABEL <- "\\label{"\r
-        ELABEL <- "}\n"\r
-        if (is.null(short.caption)){\r
-        BCAPTION <- "\\caption{"\r
-    } else {\r
-        BCAPTION <- paste("\\caption[", short.caption, "]{", sep = "")\r
-    }\r
-        ECAPTION <- "}\n"\r
+        ELABEL <- "}\n"                \r
+        ## Added caption width (jeff.laake@nooa.gov)\r
+           if(!is.null(caption.width)){\r
+               BCAPTION <- paste("\\parbox{",caption.width,"}{",sep="")\r
+               ECAPTION <- "}"\r
+           } else {\r
+               BCAPTION <- NULL\r
+               ECAPTION <- NULL\r
+           }             \r
+           if (is.null(short.caption)){\r
+                  BCAPTION <- paste(BCAPTION,"\\caption{",sep="")\r
+           } else {\r
+                  BCAPTION <- paste(BCAPTION,"\\caption[", short.caption, "]{", sep="")\r
+           }   \r
+        ECAPTION <- paste(ECAPTION,"} \n",sep="")                              \r
         BROW <- ""\r
         EROW <- " \\\\ \n"\r
         BTH <- ""\r
@@ -436,12 +448,14 @@ print.xtable <- function(x,
     info <- R.Version()\r
     ## modified Claudio Agostinelli <claudio@unive.it> dated 2006-07-28\r
     ## to set automatically the package version\r
-    result <- result + BCOMMENT + type + " table generated in " +\r
+       if (comment){\r
+        result <- result + BCOMMENT + type + " table generated in " +\r
               info$language + " " + info$major + "." + info$minor +\r
               " by xtable " +  packageDescription('xtable')$Version +\r
               " package" + ECOMMENT\r
-    if (!is.null(timestamp)){            \r
-        result <- result + BCOMMENT + timestamp + ECOMMENT\r
+        if (!is.null(timestamp)){                \r
+            result <- result + BCOMMENT + timestamp + ECOMMENT\r
+        }\r
     }          \r
     ## Claudio Agostinelli <claudio@unive.it> dated 2006-07-28 only.contents\r
     if (!only.contents) {\r
index b228f6832903a3d02ed871c9ac607c4c5f667f6d..ed3f9c06eac5111a86c3f43f9298ca2fa2542a38 100644 (file)
@@ -2,7 +2,7 @@
 ###
 ### Produce LaTeX and HTML tables from R objects.
 ###
-### Copyright 2000-2007 David B. Dahl <dahl@stat.tamu.edu>
+### Copyright 2000-2013 David B. Dahl <dahl@stat.tamu.edu>
 ###
 ### This file is part of the `xtable' library for R and related languages.
 ### It is made available under the terms of the GNU General Public
index ceb8320d40e47be8f7d7ad7d729a21bbdc250365..a67934d84074ae12437b09a33bd06e980264f50b 100644 (file)
@@ -2,7 +2,7 @@
 ###\r
 ### Produce LaTeX and HTML tables from R objects.\r
 ###\r
-### Copyright 2000-2012 David B. Dahl <dahl@stat.tamu.edu>\r
+### Copyright 2000-2013 David B. Dahl <dahl@stat.tamu.edu>\r
 ###\r
 ### Maintained by Charles Roosen <croosen@mango-solutions.com>\r
 ###\r
index 6c65954d31ad642905cac55842e49360c0e8ce7e..47af4d4d6077d0815ad8676ec4d4488ff9a9f6b6 100644 (file)
@@ -2,7 +2,7 @@
 ###
 ### Produce LaTeX and HTML tables from R objects.
 ###
-### Copyright 2000-2007 David B. Dahl <dahl@stat.tamu.edu>
+### Copyright 2000-2013 David B. Dahl <dahl@stat.tamu.edu>
 ###
 ### This file is part of the `xtable' library for R and related languages.
 ### It is made available under the terms of the GNU General Public
index 4922c5122cf647aabe4337ccc67a462da72b715b..3994324da874c656ab29bbb4e5b9c4c7161224f5 100644 (file)
@@ -244,9 +244,9 @@ temp.ts <- ts(cumsum(1+round(rnorm(100), 0)), start = c(1954, 7), frequency=12)
 if (FALSE) {
   for(i in c("latex","html")) {
     outFileName <- paste("xtable.",ifelse(i=="latex","tex",i),sep="")
-    print(xtable(lm.D9),type=i,file=outFileName,append=TRUE,latex.environment=NULL)
-    print(xtable(lm.D9),type=i,file=outFileName,append=TRUE,latex.environment="")
-    print(xtable(lm.D9),type=i,file=outFileName,append=TRUE,latex.environment="center")
+    print(xtable(lm.D9),type=i,file=outFileName,append=TRUE,latex.environments=NULL)
+    print(xtable(lm.D9),type=i,file=outFileName,append=TRUE,latex.environments="")
+    print(xtable(lm.D9),type=i,file=outFileName,append=TRUE,latex.environments="center")
     print(xtable(anova(glm.D93,test="Chisq")),type=i,file=outFileName,append=TRUE)
     print(xtable(anova(glm.D93)),hline.after=c(1),size="small",type=i,file=outFileName,append=TRUE)
       # print(xtable(pr2),type=i,file=outFileName,append=TRUE)
@@ -298,9 +298,9 @@ print(xtable(money),sanitize.rownames.function=function(x) {x})
 \section{Format examples}
 \subsection{Adding a centering environment }
 <<results=tex>>=
-   print(xtable(lm.D9,caption="\\tt latex.environment=NULL"),latex.environment=NULL)
-    print(xtable(lm.D9,caption="\\tt latex.environment=\"\""),latex.environment="")
-    print(xtable(lm.D9,caption="\\tt latex.environment=\"center\""),latex.environment="center")
+   print(xtable(lm.D9,caption="\\tt latex.environments=NULL"),latex.environments=NULL)
+    print(xtable(lm.D9,caption="\\tt latex.environments=\"\""),latex.environments="")
+    print(xtable(lm.D9,caption="\\tt latex.environments=\"center\""),latex.environments="center")
 @
 \subsection{Column alignment}
 
index 879543b10f6e13b8eeea83bd2cf63efb73b42802..efb537f36c87ff5b4d93bd899407d614d7bab311 100644 (file)
@@ -14,6 +14,7 @@
   floating.environment = getOption("xtable.floating.environment", "table"),\r
   table.placement = getOption("xtable.table.placement", "ht"),\r
   caption.placement = getOption("xtable.caption.placement", "bottom"),\r
+  caption.width = getOption("xtable.caption.width", NULL),\r
   latex.environments = getOption("xtable.latex.environments", c("center")),\r
   tabular.environment = getOption("xtable.tabular.environment", "tabular"),\r
   size = getOption("xtable.size", NULL),\r
@@ -38,7 +39,8 @@
   booktabs = getOption("xtable.booktabs", FALSE),\r
   scalebox = getOption("xtable.scalebox", NULL),\r
   width = getOption("xtable.width", NULL),\r
-  timestamp = date(),\r
+  comment = getOption("xtable.comment", TRUE),\r
+  timestamp = getOption("xtable.timestamp", date()),\r
   ...)}\r
 \arguments{\r
   \item{x}{An object of class \code{"xtable"}.}\r
@@ -60,9 +62,8 @@
     Default value is \code{TRUE}. }\r
   \item{floating.environment}{If \code{floating=TRUE} and\r
     \code{type="latex"}, the resulting table uses the specified floating\r
-    environment. Possible values are \code{"table"}, \code{"table*"}, or\r
-    \code{"sidewaystable"} (defined in the LaTeX package\r
-    'rotating').\r
+    environment. Possible values include \code{"table"}, \code{"table*"}, \r
+    and other floating environments defined in LaTeX packages.\r
     Default value is \code{"table"}.}\r
   \item{table.placement}{If \code{floating=TRUE} and\r
     \code{type="latex"}, the floating table will have placement given by\r
@@ -74,6 +75,9 @@
     of the table if \code{caption.placement} is \code{"bottom"} and at\r
     the top of the table if it equals \code{"top"}.\r
     Default value is \code{"bottom"}.}\r
+  \item{caption.width}{The caption will be placed in a \code{"parbox"}\r
+    of the specified width if \code{caption.width} is not \code{NULL} and\r
+       \code{type="latex"}. Default value is \code{NULL}.}\r
   \item{latex.environments}{If \code{floating=TRUE} and\r
     \code{type="latex"}, the specificed latex environments (provided as\r
     a character vector) will enclose the tabular environment.\r
     width when using tabular environments such as \code{tabular*} and\r
     \code{tabularx}.  Note that table width specification is not\r
     supported with the \code{tabular} or \code{longtable} environments. }\r
+  \item{comment}{If \code{TRUE}, the version and timestamp comment is\r
+    included.  Default value is \code{TRUE}. }  \r
   \item{timestamp}{Timestamp to include in LaTeX comment.  Set this\r
-    to \code{NULL} to exclude the timestamp.}  \r
-  \item{...}{Additional arguments.  (Currently ignored.)}\r
+    to \code{NULL} to exclude the timestamp. Default value is \code{date()}. }  \r
+  \item{...}{Additional arguments.  (Currently ignored.) }\r
 }\r
 \details{\r
   This function displays or writes to disk the code to produce a table\r