<<include=FALSE>>=\r
library(knitr)\r
opts_chunk$set(fig.path='figdir/fig', debug=TRUE, echo=TRUE)\r
+set.seed(1234)\r
@\r
\r
The first step is to load the package and set an option for this document.\r
\code{math.style.exponents} option to \code{print.xtable} is useful:\r
\r
<<results='asis'>>=\r
-print(xtable(data.frame(text=c("foo","bar"),\r
- googols=c(10e10,50e10),\r
- small=c(8e-24,7e-5),\r
- row.names=c("A","B")),\r
- display=c("s","s","g","g")),\r
- math.style.exponents=TRUE\r
- )\r
+print(xtable(data.frame(text = c("foo","bar"),\r
+ googols = c(10e10,50e10),\r
+ small = c(8e-24,7e-5),\r
+ row.names = c("A","B")),\r
+ display = c("s","s","g","g")),\r
+ math.style.exponents = TRUE)\r
@ \r
\r
this option also supports the values \code{ensuremath} which uses\r
print(x.big, hline.after=c(-1, 0), tabular.environment = "longtable")\r
@\r
\r
-%% The column name alignment is off in the following example.\r
-%% It needs some revision before exposing it. - CR, 7/2/2012\r
-%\r
-%% Tried to fix this and got some of the way, but \hlines are wrong\r
-%% and first column is too wide. - DJS 4/10/2014\r
-%% \subsubsection{Long tables with the header on each page}\r
-%% The \code{add.to.row} argument can be used to display the header\r
-%% for a long table on each page, and to add a "continued" footer\r
-%% on all pages except the last page.\r
-\r
-%% \newcommand{\head}[1]{\centercell{\bfseries#1}}\r
-\r
-%% <<results='asis'>>=\r
-%% x <- matrix(rnorm(1000), ncol = 10)\r
-%% hdr <- paste(paste("\\multicolumn{1}{c}{",1:9,"} & ", collapse = ""),\r
-%% "\\multicolumn{1}{c}{10}\\\\")\r
-%% addtorow <- list()\r
-%% addtorow$pos <- list()\r
-%% addtorow$pos[[1]] <- c(0)\r
-%% addtorow$command <- c(paste(\r
-%% hdr,\r
-%% " \\hline \n",\r
-%% " \\endhead \n",\r
-%% " \\hline \n",\r
-%% " {\\footnotesize Continued on next page} \n",\r
-%% " \\endfoot \n",\r
-%% " \\endlastfoot \n", sep = ""))\r
-%% x.big2 <- xtable(x, label = "tabbig2", align = "lrrrrrrrrrr",\r
-%% caption = "Example of longtable with the header on each page")\r
-%% print(x.big2, tabular.environment = "longtable",\r
-%% include.rownames = FALSE, include.colnames = FALSE,\r
-%% add.to.row = addtorow)\r
-%% @\r
+Extra features of the \pkg{longtable} \LaTeX{} package can typically\r
+be activated using \code{add.to.row}, as shown below.\r
+\r
+<<results='asis'>>=\r
+add.to.row <- list(pos = list(0), command = NULL)\r
+command <- paste0("\\hline\n\\endhead\n",\r
+ "\\hline\n",\r
+ "\\multicolumn{", dim(x)[2] + 1, "}{l}",\r
+ "{\\footnotesize Continued on next page}\n",\r
+ "\\endfoot\n",\r
+ "\\endlastfoot\n") \r
+add.to.row$command <- command\r
+print(x.big, hline.after=c(-1), add.to.row = add.to.row,\r
+ tabular.environment = "longtable")\r
+@\r
+\r
\r
\newpage\r
\r