]> git.donarmstrong.com Git - xtable.git/commitdiff
Removed the "short.caption" argument. Instead, "caption" can be length 2 in which...
authorroosen <roosen@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Mon, 6 Feb 2012 15:27:05 +0000 (15:27 +0000)
committerroosen <roosen@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Mon, 6 Feb 2012 15:27:05 +0000 (15:27 +0000)
git-svn-id: svn://scm.r-forge.r-project.org/svnroot/xtable@27 edb9625f-4e0d-4859-8d74-9fd3b1da38cb

pkg/DESCRIPTION
pkg/NEWS
pkg/R/print.xtable.R
pkg/R/table.attributes.R
pkg/man/print.xtable.Rd
pkg/man/xtable.Rd

index d3bfaedb6f8faadf1235f64b7b363a341ca63412..58971d808d1c8179afa8adcec5d25cdb13ed3b78 100644 (file)
@@ -1,6 +1,6 @@
 Package: xtable
 Version: 1.7-0
-Date: 2011/10/06
+Date: 2012/02/06
 Title: Export tables to LaTeX or HTML
 Author: David B. Dahl <dahl@stat.tamu.edu>
 Maintainer: Charles Roosen <croosen@mango-solutions.com>
index 4e41217fc628caf3231a965e7b5666b15405800e..48e7441b5f5d205da4e4cb968203a700912f00d5 100644 (file)
--- a/pkg/NEWS
+++ b/pkg/NEWS
@@ -1,16 +1,13 @@
 1.7-0 (NOT YET RELEASED)
   * 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.
   * Added "toLatex" method.
   * Included "print.xtable" in the exported methods in the NAMESPACE file.
   * Added "print.results" argument to "print" that can be used to
     suppress the printing.
   * Added "format.args" argument to "print" that can be used to
     pass additional arguments such as "big.marks" to "formatC()".
-  * Added "short.caption" argument to "print" to let the user 
-    specify a Latex short caption used when creating a list of tables.
-    Conceptually this should really be an argument to "xtable()", but
-    it was added to "print()" so authors of other packages don't need
-    to change their "xtable" methods.  
   * Added "rotate.colnames" and "rotate.rownames" arguments to
     "print.xtable".  
   * Added "booktabs" argument to use the "\toprule", "\midrule", and  
index 282e2a2e7dcf94eda26962690879d7dba17e704e..bae66a1679d36869295c81e5b4274d5feda4e4ea 100644 (file)
@@ -48,11 +48,18 @@ print.xtable <- function(
   html.table.attributes=getOption("xtable.html.table.attributes", "border=1"),\r
   print.results=getOption("xtable.print.results", TRUE),\r
   format.args=getOption("xtable.format.args", NULL),\r
-  short.caption=getOption("xtable.short.caption", NULL),\r
   rotate.rownames=getOption("xtable.rotate.rownames", FALSE),\r
   rotate.colnames=getOption("xtable.rotate.colnames", FALSE),\r
   booktabs = getOption("xtable.booktabs", FALSE),\r
   ...) {\r
+  # If caption is length 2, treat the second value as the "short caption"\r
+  caption <- attr(x,"caption",exact=TRUE)\r
+  short.caption <- NULL\r
+  if (!is.null(caption) && length(caption) > 1){\r
+    short.caption <- caption[2]\r
+       caption <- caption[1]\r
+  }\r
+  \r
   # Claudio Agostinelli <claudio@unive.it> dated 2006-07-28 hline.after\r
   # By default it print an \hline before and after the columns names independently they are printed or not and at the end of the table\r
   # Old code that set hline.after should include c(-1, 0, nrow(x)) in the hline.after vector\r
@@ -209,7 +216,7 @@ print.xtable <- function(
                        BCAPTION <- paste("\\caption[", short.caption, "]{", sep="")\r
                }       \r
         ECAPTION <- "} \\\\ \n"\r
-        if ((!is.null(attr(x,"caption",exact=TRUE))) && (type=="latex")) BTABULAR <- paste(BTABULAR,  BCAPTION, attr(x,"caption",exact=TRUE), ECAPTION, sep="")\r
+        if ((!is.null(caption)) && (type=="latex")) BTABULAR <- paste(BTABULAR,  BCAPTION, caption, ECAPTION, sep="")\r
     }\r
     # Claudio Agostinelli <claudio@unive.it> dated 2006-07-28 add.to.row position -1\r
     BTABULAR <- paste(BTABULAR,lastcol[1], sep="")\r
@@ -341,7 +348,7 @@ print.xtable <- function(
     result <- result + BTABLE\r
     result <- result + BENVIRONMENT\r
     if ( floating == TRUE ) {\r
-      if ((!is.null(attr(x,"caption",exact=TRUE))) && (type=="html" || caption.placement=="top")) result <- result + BCAPTION + attr(x,"caption",exact=TRUE) + ECAPTION\r
+      if ((!is.null(caption)) && (type=="html" || caption.placement=="top")) result <- result + BCAPTION + caption + ECAPTION\r
       if (!is.null(attr(x,"label",exact=TRUE)) && (type=="latex" && caption.placement=="top")) result <- result + BLABEL + attr(x,"label",exact=TRUE) + ELABEL  \r
     }\r
     result <- result + BSIZE\r
@@ -477,7 +484,7 @@ print.xtable <- function(
       ## fix 10-27-09 Liviu Andronic (landronimirc@gmail.com) the following 'if' condition is inserted in order to avoid\r
       ## that bottom caption interferes with a top caption of a longtable\r
       if(caption.placement=="bottom"){\r
-        if ((!is.null(attr(x,"caption",exact=TRUE))) && (type=="latex")) result <- result + BCAPTION + attr(x,"caption",exact=TRUE) + ECAPTION\r
+        if ((!is.null(caption)) && (type=="latex")) result <- result + BCAPTION + caption + ECAPTION\r
       }\r
       if (!is.null(attr(x,"label",exact=TRUE))) result <- result + BLABEL + attr(x,"label",exact=TRUE) + ELABEL\r
       ETABULAR <- "\\end{longtable}\n"\r
@@ -485,7 +492,7 @@ print.xtable <- function(
     result <- result + ETABULAR\r
     result <- result + ESIZE\r
     if ( floating == TRUE ) {\r
-      if ((!is.null(attr(x,"caption",exact=TRUE))) && (type=="latex" && caption.placement=="bottom")) result <- result + BCAPTION + attr(x,"caption",exact=TRUE) + ECAPTION\r
+      if ((!is.null(caption)) && (type=="latex" && caption.placement=="bottom")) result <- result + BCAPTION + caption + ECAPTION\r
       if (!is.null(attr(x,"label",exact=TRUE)) && caption.placement=="bottom") result <- result + BLABEL + attr(x,"label",exact=TRUE) + ELABEL  \r
     }\r
     result <- result + EENVIRONMENT\r
index f2a08c7de6511489667bacabee1017800d1692d7..ca09e98b5fdedefb39771380ff2af8934fe78f4b 100644 (file)
@@ -22,8 +22,8 @@
 
 "caption<-" <- function(x,value) UseMethod("caption<-")
 "caption<-.xtable" <- function(x,value) {
-  if (length(value)>1)
-    stop("\"caption\" must have length 1")
+  if (length(value)>2)
+    stop("\"caption\" must have length 1 or 2")
   attr(x,"caption") <- value
   return(x)
 }
index 62d05b13a05e3185c252b7016c8fce637db468c0..03faef6bc331bf119ddb19c4cd8a936f9b57a286 100644 (file)
@@ -29,7 +29,6 @@
   html.table.attributes=getOption("xtable.html.table.attributes", "border=1"),\r
   print.results=getOption("xtable.print.results", TRUE),\r
   format.args=getOption("xtable.format.args", NULL),\r
-  short.caption=getOption("xtable.short.caption", NULL),\r
   rotate.rownames=getOption("xtable.rotate.rownames", FALSE),\r
   rotate.colnames=getOption("xtable.rotate.colnames", FALSE),\r
   booktabs = getOption("xtable.booktabs", FALSE),\r
@@ -68,7 +67,6 @@
   \item{html.table.attributes}{In an HTML table, attributes associated with the \code{<TABLE>} tag.  Default value is \code{border=1}.}\r
   \item{print.results}{If \code{TRUE}, the generated table is printed to standard output.  Set this to \code{FALSE} if you will just be using the character vector that is returned invisibly.}\r
   \item{format.args}{List of arguments for the \code{formatC} function.  For example, standard German number separators can be specified as \code{format.args=list(big.mark = "'", decimal.mark = ","))}.}\r
-  \item{short.caption}{A "short caption" can be specified that gets used as the table descriptor when LaTeX generates a "List of Tables".}\r
   \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
index 41628acc3728390d339eab3e06f2f408de445c0d..b8a7f996d6b352b9ba7ae609b50e4431826b943b 100644 (file)
@@ -26,7 +26,8 @@ xtable(x, caption=NULL, label=NULL, align=NULL, digits=NULL,
 \arguments{
   \item{x}{An R object of class found among \code{methods(xtable)}.  See below on how to write additional method functions
            for \code{xtable}.}
-  \item{caption}{Character vector of length 1 containing the table's caption or title.
+  \item{caption}{Character vector of length 1 or 2 containing the table's caption or title.  If length 2, the second item 
+               is the "short caption" used when LaTeX generates a "List of Tables".
                  Set to \code{NULL} to suppress the caption.  Default value is \code{NULL}.}
   \item{label}{Character vector of length 1 containing the LaTeX label or HTML anchor.
                Set to \code{NULL} to suppress the label.  Default value is \code{NULL}.}
@@ -196,12 +197,12 @@ print(xtable(anova(glm.D93)),hline.after=c(1),size="small")
 ## Demonstration of additional formatC() arguments.
 print(fm1.table, format.args=list(big.mark = "'", decimal.mark = ","))
 
-## Demonstration of short caption support.
+## Demonstration of "short caption" support.
 fm1sc <- aov(tlimth ~ sex + ethnicty + grade, data=tli)
 fm1sc.table <- xtable(fm1sc, 
-  caption="ANOVA Model with Predictors Sex, Ethnicity, and Grade")
-print(fm1sc.table,
-  short.caption="ANOVA: Sex, Ethnicity, Grade")
+  caption=c("ANOVA Model with Predictors Sex, Ethnicity, and Grade",
+    "ANOVA: Sex, Ethnicity, Grade"))
+print(fm1sc.table)
 
 ## Demonstration of longtable support.
 ## Remember to insert \usepackage{longtable} on your LaTeX preamble