-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.
###\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
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
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
## 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
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
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
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
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
## 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
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
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
###
### 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
###\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
###
### 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
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)
\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}
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
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
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
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