]> git.donarmstrong.com Git - xtable.git/commitdiff
Added "short.caption" argument to "print.xtable()". This was added to print.xtable...
authorroosen <roosen@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Mon, 30 Jan 2012 14:24:31 +0000 (14:24 +0000)
committerroosen <roosen@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Mon, 30 Jan 2012 14:24:31 +0000 (14:24 +0000)
git-svn-id: svn://scm.r-forge.r-project.org/svnroot/xtable@22 edb9625f-4e0d-4859-8d74-9fd3b1da38cb

pkg/NEWS
pkg/R/print.xtable.R
pkg/man/print.xtable.Rd
pkg/man/xtable.Rd

index 25520a5806884552700bb4d91eaa22256bc3ab5d..d9b5d53fa3c00ebfe5ed6ea89b5060a7f4041abe 100644 (file)
--- a/pkg/NEWS
+++ b/pkg/NEWS
@@ -1,16 +1,17 @@
 1.6-1 (NOT YET RELEASED)
-
   * Added some vectorization code to improve performance.
   * Added "toLatex" method.
-  * Included "print" 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. 
   * Added an "is.null()" check on the "table.placement" argument.
+  * Included "print.xtable" in the exported methods in the NAMESPACE file.
   * Added an example of header and footer specification with longtable
     to the vignette.  
-  * Added "format.args" argument to "print" that can be used to
-    pass additional arguments such as "big.marks" to "formatC()".
-
+       
 1.6-0 (2011-10-07)
   * Allow "table*" as a value for "floating.environment" in print.xtable().
   * Fix bug under which multiple logical columns were formatted incorrectly.
@@ -30,4 +31,3 @@
   * Accommodated logicals by converting to characters.
   * Add an extra space at end of each line for LaTeX tables.
   * Fixed typographical error in documentation.
-
index aadbc62ea554e85b9d79693814ddd03612baa331..a69f927cc8ff2aaa9e709ee678f21a052d839d1a 100644 (file)
@@ -46,6 +46,7 @@ print.xtable <- function(
   html.table.attributes="border=1",\r
   print.results=TRUE,\r
   format.args=NULL,\r
+  short.caption=NULL,\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
@@ -171,7 +172,11 @@ print.xtable <- function(
     ## 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
-        BCAPTION <- "\\caption{"\r
+               if (is.null(short.caption)){\r
+                       BCAPTION <- "\\caption{"\r
+               } else {\r
+                       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
     }\r
@@ -193,7 +198,11 @@ print.xtable <- function(
     }\r
     BLABEL <- "\\label{"\r
     ELABEL <- "}\n"\r
-    BCAPTION <- "\\caption{"\r
+       if (is.null(short.caption)){\r
+               BCAPTION <- "\\caption{"\r
+       } else {\r
+               BCAPTION <- paste("\\caption[", short.caption, "]{", sep="")\r
+       }       \r
     ECAPTION <- "}\n"\r
     BROW <- ""\r
     EROW <- " \\\\ \n"\r
index 5d1ffd5f5ae9149a50e2a865cfc9b9ceb394d1ae..fdf2df9af81d33ee11d81c290f3f33d365912c60 100644 (file)
@@ -12,7 +12,8 @@
                sanitize.colnames.function=sanitize.text.function, math.style.negative=FALSE, 
                html.table.attributes="border=1", 
                print.results=TRUE, 
-        format.args=NULL, ...)}
+        format.args=NULL, 
+               short.caption=NULL, ...)}
 \arguments{
   \item{x}{An object of class \code{"xtable"}.}
   \item{type}{Type of table to produce.  Possible values for \code{type} are \code{"latex"} or \code{"html"}.
@@ -47,6 +48,7 @@
   \item{html.table.attributes}{In an HTML table, attributes associated with the \code{<TABLE>} tag.  Default value is \code{border=1}.}
   \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.}
   \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 = ","))}.}
+  \item{short.caption}{A "short caption" can be specified that gets used as the table descriptor when LaTeX generates a "List of Tables".}
   \item{...}{Additional arguments.  (Currently ignored.)}
 }
 \details{
index 60736f81938c18cb4d523b32ce5d0fe43e1a860e..7211a83ef6e89346805b18d06f83a03075071068 100644 (file)
@@ -196,6 +196,13 @@ 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.
+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")
+
 ## Demonstration of longtable support.
 ## Remember to insert \usepackage{longtable} on your LaTeX preamble
 x <- matrix(rnorm(1000), ncol = 10)