]> git.donarmstrong.com Git - xtable.git/commitdiff
Vignette: article class, TOC, subsubsection
authorarnima <arnima@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Tue, 30 Sep 2014 13:42:27 +0000 (13:42 +0000)
committerarnima <arnima@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Tue, 30 Sep 2014 13:42:27 +0000 (13:42 +0000)
git-svn-id: svn://scm.r-forge.r-project.org/svnroot/xtable@60 edb9625f-4e0d-4859-8d74-9fd3b1da38cb

pkg/vignettes/xtableGallery.Rnw

index 2c771d854fdc6849d2bed1f5153974803705ab8e..9fccd7be959c3d290f36f8ae0492dfe3ff844b76 100644 (file)
@@ -5,22 +5,28 @@
 % !Rnw weave = knitr\r
 % \VignetteEngine{knitr::knitr}\r
 %**************************************************************************\r
-\documentclass[article, nojss]{jss}\r
+\documentclass{article}\r
+\usepackage[a4paper,height=24cm]{geometry}\r
+\usepackage{parskip}\r
+\usepackage{titlesec}\r
+\titleformat\subsubsection{\bfseries\itshape}{}{0pt}{}\r
 \usepackage{booktabs}\r
 \usepackage{longtable}\r
 \usepackage{rotating}\r
 \usepackage{tabularx}\r
-\title{The xtable Gallery}\r
-\author{Jonathan Swinton and others\\<jonathan@swintons.net>}\r
-\Abstract{This document gives a gallery of tables which can be made by using the\r
-  \texttt{xtable} package to create \LaTeX\ output. It doubles as a regression\r
-  check for the package.}\r
-\Keywords{Reproducible research, \LaTeX}\r
-\Shorttitle{\pkg{xtable} Gallery} %% JSS header\r
-\Address{Jonathan Swinton\\E-mail: \email{jonathan@swintons.net}} %% JSS last pg\r
+\newcommand\code[1]{\texttt{#1}}\r
 \newcommand\p{\vspace{2ex}}\r
+\setcounter{tocdepth}{2}\r
 \begin{document}\r
 \r
+\title{The xtable Gallery}\r
+\author{Jonathan Swinton and others}\r
+\maketitle\r
+\r
+\tableofcontents\r
+\r
+\newpage\r
+\r
 <<include=FALSE>>=\r
 library(knitr)\r
 opts_chunk$set(fig.path='figdir/fig', debug=TRUE, echo=TRUE)\r
@@ -35,8 +41,6 @@ data(tli)
 xtable(tli[1:10, ])\r
 @\r
 \r
-\newpage\r
-\r
 \subsection{Matrix}\r
 <<results='asis'>>=\r
 design.matrix <- model.matrix(~ sex*grade, data = tli[1:10, ])\r
@@ -49,18 +53,20 @@ fm1 <- aov(tlimth ~ sex + ethnicty + grade + disadvg, data = tli)
 xtable(fm1)\r
 @\r
 \r
+\newpage\r
+\r
 \subsection{lm}\r
 <<results='asis'>>=\r
 fm2 <- lm(tlimth ~ sex*ethnicty, data = tli)\r
 xtable(fm2)\r
 @\r
 \r
-\p\textbf{\itshape Anova table (one model)}\r
+\subsubsection{Anova table (one model)}\r
 <<results='asis'>>=\r
 xtable(anova(fm2))\r
 @\r
 \r
-\p\textbf{\itshape Anova table (two models)}\r
+\subsubsection{Anova table (two models)}\r
 <<results='asis'>>=\r
 fm2b <- lm(tlimth ~ ethnicty, data = tli)\r
 xtable(anova(fm2b, fm2))\r
@@ -72,7 +78,7 @@ fm3 <- glm(disadvg ~ ethnicty*grade, data = tli, family = binomial)
 xtable(fm3)\r
 @\r
 \r
-\p\textbf{\itshape Anova table}\r
+\p\r
 <<results='asis'>>=\r
 xtable(anova(fm3))\r
 @\r
@@ -101,6 +107,9 @@ xtable(anova(npk.aov))
 xtable(summary(npk.aov))\r
 @\r
 \r
+\newpage\r
+\r
+\p\r
 <<results='asis'>>=\r
 ## Alternative multistratum model\r
 op <- options(contrasts = c("contr.helmert", "contr.treatment"))\r
@@ -109,6 +118,7 @@ options(op)
 xtable(npk.aovE)\r
 @\r
 \r
+\p\r
 <<results='asis'>>=\r
 xtable(summary(npk.aovE))\r
 @\r
@@ -124,10 +134,13 @@ lm.D9 <- lm(weight ~ group)
 xtable(lm.D9)\r
 @\r
 \r
+\p\r
 <<results='asis'>>=\r
 xtable(anova(lm.D9))\r
 @\r
 \r
+\newpage\r
+\r
 \subsection{More glm}\r
 <<results='asis'>>=\r
 ## Dobson (1990, p. 93) randomized controlled trial\r
@@ -145,6 +158,7 @@ pr1 <- prcomp(USArrests)
 xtable(pr1)\r
 @\r
 \r
+\p\r
 <<results='asis'>>=\r
 xtable(summary(pr1))\r
 @\r
@@ -206,6 +220,8 @@ display(x) <- xdisplay(x)
 x\r
 @\r
 \r
+\newpage\r
+\r
 \section{Sanitization}\r
 <<results='asis'>>=\r
 insane <- data.frame(Name = c("Ampersand","Greater than","Less than",\r
@@ -228,6 +244,8 @@ print(wanttex, sanitize.text.function =
       function(str) gsub("_", "\\_", str, fixed = TRUE))\r
 @\r
 \r
+\newpage\r
+\r
 \subsection{Markup in tables}\r
 Markup can be included in tables, including in column and row names, by using\r
 a custom \code{sanitize.text.function}.\r
@@ -272,18 +290,20 @@ align(tli.table) <- rep("r", 6)
 tli.table\r
 @\r
 \r
-\p\textbf{\itshape Left aligned strings with column lines}\r
+\subsubsection{Left aligned strings with column lines}\r
 <<results='asis'>>=\r
 align(tli.table) <- "|rrl|l|lr|"\r
 tli.table\r
 @\r
 \r
-\p\textbf{\itshape Fixed width columns}\r
+\subsubsection{Fixed width columns}\r
 <<results='asis'>>=\r
 align(tli.table) <- "|rr|lp{3cm}l|r|"\r
 tli.table\r
 @\r
 \r
+\newpage\r
+\r
 \subsection{Number of digits}\r
 One number for all columns,\r
 <<results='asis'>>=\r
@@ -306,6 +326,8 @@ digits(tli.table) <- matrix(0:4, nrow = 10, ncol = ncol(tli)+1)
 tli.table\r
 @\r
 \r
+\newpage\r
+\r
 \subsection{Suppress row names}\r
 <<results='asis'>>=\r
 tli.table <- xtable(tli[1:10, ])\r
@@ -326,6 +348,8 @@ Revert the alignment to what is was before.
 align(tli.table) <- "|rr|lp{3cm}l|r|"\r
 @\r
 \r
+\newpage\r
+\r
 \subsection{Suppress column names}\r
 <<results='asis'>>=\r
 print(tli.table, include.colnames = FALSE)\r
@@ -343,6 +367,8 @@ print(tli.table, include.colnames = FALSE,
 print(tli.table, include.colnames = FALSE, include.rownames = FALSE)\r
 @\r
 \r
+\newpage\r
+\r
 \subsection{Rotate row and column names}\r
 The \code{rotate.rownames} and \code{rotate.colnames} arguments can be used to\r
 rotate the row and/or column names. This requires \verb|\usepackage{rotating}|\r
@@ -352,9 +378,10 @@ in the \LaTeX\ preamble.
 print(tli.table, rotate.rownames = TRUE, rotate.colnames = TRUE)\r
 @\r
 \r
-\subsection{Horizontal lines}\r
-\p\textbf{\itshape Line locations}\r
+\newpage\r
 \r
+\subsection{Horizontal lines}\r
+\subsubsection{Line locations}\r
 Use the \code{hline.after} argument to specify the position of the\r
 horizontal lines.\r
 \r
@@ -362,8 +389,7 @@ horizontal lines.
 print(xtable(anova(glm.D93)), hline.after = c(1))\r
 @\r
 \r
-\p\textbf{\itshape Line styles}\r
-\r
+\subsubsection{Line styles}\r
 Specifying \code{booktabs = TRUE} will generate three line types. By default,\r
 when no value is given for \code{hline.after}, a \verb|\toprule| will be drawn\r
 above the table, a \verb|\midrule| after the table headings and a\r
@@ -413,8 +439,7 @@ print(x.big, hline.after=c(-1, 0), tabular.environment = 'longtable')
 %% The column name alignment is off in the following example.\r
 %% It needs some revision before exposing it. - CR, 7/2/2012\r
 %\r
-%\p\textbf{\itshape Long tables with the header on each page}\r
-%\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
@@ -473,6 +498,8 @@ align(x.width) <- "|l|X|l|l|l|"
 print(x.width, tabular.environment = "tabularx", width = "\\textwidth")\r
 @\r
 \r
+\newpage\r
+\r
 \section{Suppressing printing}\r
 By default the \code{print} method will print the \LaTeX\ or HTML to standard\r
 output and also return the character strings invisibly.  The printing to\r