% \VignetteEngine{knitr::knitr}\r
%**************************************************************************\r
\documentclass{article}\r
-\usepackage[a4paper,height=24cm]{geometry}\r
-\usepackage{parskip}\r
-\usepackage{titlesec}\r
-\titleformat\subsubsection{\bfseries\itshape}{}{0pt}{}\r
+\usepackage[a4paper,height=24cm]{geometry} % geometry first\r
+\usepackage{array}\r
\usepackage{booktabs}\r
\usepackage{longtable}\r
+\usepackage{parskip}\r
\usepackage{rotating}\r
-\usepackage{array}\r
\usepackage{tabularx}\r
+\usepackage{titlesec}\r
+\usepackage{hyperref} % hyperref last\r
+\titleformat\subsubsection{\bfseries\itshape}{}{0pt}{}\r
\newcommand\p{\vspace{2ex}}\r
-\setcounter{tocdepth}{2}\r
-%% Define \code \proglang and \pkg commands\r
\newcommand\code[1]{\texttt{#1}}\r
\newcommand\pkg[1]{\textbf{#1}}\r
-\newcommand\R{\textsf{R}}\r
-%% url and hyperref\r
-\usepackage[hyphens]{url}\r
-\usepackage{hyperref}\r
+\setcounter{tocdepth}{2}\r
\begin{document}\r
\r
\title{The \pkg{xtable} Gallery}\r
\newpage\r
\r
\section{Introduction}\r
-\label{sec:introduction}\r
-\r
This document gives a gallery of tables which can be made using the\r
\pkg{xtable} package to create \LaTeX\ output. It doubles as a\r
regression check for the package.\r
# xtable(pr2)\r
@\r
\r
+\newpage\r
+\r
\subsection{Time series}\r
<<results='asis'>>=\r
temp.ts <- ts(cumsum(1 + round(rnorm(100), 0)),\r
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
print(mat, sanitize.text.function = function(x) {x})\r
@\r
\r
-\newpage\r
% By David Dahl to demonstrate contribution from David Whitting, 2007-10-09.\r
-\r
+\p\r
You can also have sanitize functions that are specific to column or\r
row names. In the table below, the row name is not sanitized but\r
column names and table elements are.\r
print(x.rescale, scalebox = 0.7)\r
@\r
\r
-\newpage\r
-\r
\subsection{Aligning fixed width columns}\r
Note that using specifications such as \verb|p{2cm}| always\r
produces a \textbf{left aligned} column. What if some other alignment\r
floating = FALSE, include.rownames = FALSE)\r
@\r
\r
+\newpage\r
+\r
\subsection{Table width}\r
The \code{tabularx} environment is for typesetting tables whose overall width is\r
fixed. The column alignment code \code{X} denotes columns that will be stretched\r
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
x.ltx\r
@\r
\r
+\newpage\r
+\r
\section{Acknowledgements}\r
Most of the examples in this gallery are taken from the \pkg{xtable}\r
documentation. Two examples (\code{add.to.row} and `Aligning fixed width\r
columns') are from Stack Exchange.\r
\r
-\section{\R\ session information}\r
+\section{Session information}\r
<<results='asis'>>=\r
toLatex(sessionInfo())\r
@\r