 % Define \jmlrprehyperref to load packages before hyperref is
 % loaded
\def\jmlrprehyperref{%
  % Packages used by imported articles:
  \usepackage{lipsum}
  \usepackage{booktabs}
  \usepackage{siunitx}
}
\documentclass[wcp,7x10]{jmlrbook}% on-line color version, 7inx10in
 %\documentclass[wcp,gray,7x10]{jmlrbook}% print version, 7inx10in


 % bookmark package shouldn't be used for print version
 % (load last)
%\ifprint{}{\usepackage{bookmark}}


 % Title is added to the PDF properties. Optional argument
 % is used instead, if present.
 %\title[Short Title]{Big Long Title}
\title{A Sample Book}

\author[Anne Editor et al.]{Anne Editor, Anne Other Editor and Nicola Talbot}

 % change the arguments, as appropriate, in the following:
\volume{1}
\subtitle{Making a Book from JMLR Articles}
\logo{\includegraphics{bookLogo}}
\team{The Sample Book Team}

\productioneditor{Nicola Talbot}

\begin{document}
\maketitle

\frontmatter

\chapter{Foreword}

This is an example book that combines multiple articles. Each
article uses the \textsf{jmlr} class file. \emph{The articles
should not need to be edited in order to combine them using this
class file.}\footnote{Unless the authors have done something
weird or have used problematic packages.} In particular, you
don't need to delete \verb|\documentclass|,
\verb|\begin{document}| and \verb|\end{document}|. The articles
should be able to compile on their own or as part of this book.

In the preamble of the book, you need to include the packages
that the articles include, but you don't need to include
any packages that are automatically loaded by the \textsf{jmlr}
class (\textsf{amsmath}, \textsf{amssymb}, \textsf{natbib},
\textsf{graphicx}, \textsf{url}, \textsf{xcolor} and
\textsf{algorithm2e}). You also don't need to include the
\textsf{hyperref} and \textsf{combnat} packages as they are
automatically loaded by \textsf{jmlrbook}. For example, some of the
articles imported in this book use the \textsf{lipsum} package,
so that package needs to be included in the preamble of the
book.

Commands defined in the imported articles will be local to that
article unless \verb|\gdef| or \verb|\global| has been used. This
means that if more than one article has defined the same command,
there shouldn't be a conflict unless the command has been defined
globally. For example, \texttt{paper1/paper1.tex} and
\texttt{paper2/paper2.tex} both define \verb|\samplecommand|, but
since \verb|\newcommand| has been used, rather than \verb|\gdef|,
there's no conflict. However, a problem will occur if the same
command is also defined in this document before either of those
files are imported.

Many packages must be loaded before \textsf{hyperref}. If these
packages haven't been loaded by \textsf{jmlr}, you will need
to specify them using \textsf{jmlrbook}'s \verb|\jmlrprehyperref|
hook. For example, to load the packages ``foo'' and ``bar'':
\begin{verbatim}
\def\jmlrprehyperref{\usepackage{foo}\usepackage{bar}}
\documentclass{jmlrbook}
\end{verbatim}
or:
\begin{verbatim}
\def\jmlrprehyperref{\usepackage{foo,bar}}
\documentclass{jmlrbook}
\end{verbatim}


The imported papers need to be placed inside the 
\texttt{jmlrpapers} environment. Papers that have already
been published should be included using \verb|\importpubpaper|
and papers that haven't been published elsewhere should be
imported using \verb|\importarticle|. Both commands have an
optional argument that specifies the prefix to use in the labels
within the imported article. If omitted, the article's file
name is used.

Both articles and the book may have appendices and parts created.
Parts are created using \verb|\part|\{\emph{title}\}. Switch
to appendices using \verb|\appendix| and then use \verb|\chapter|
(for the book) or \verb|\section| (in imported articles).

Cross-referencing other parts of the book is done using the
usual \verb|\label| and \verb|\ref| mechanism. The \textsf{jmlr}
class additional provides convenience commands such as
\verb|\sectionref| and \verb|\figureref|. Unlike \verb|\ref|,
these commands may take a comma-separated list of labels as the
argument.

The \textsf{jmlrbook} additionally provides \verb|\chapterref|
(which can take a comma-separated list of labels) and commands
to reference imported articles (which take a single label
as the argument): \verb|\articlepageref| (the starting page of
the article), \verb|\articlepagesref| (the page range for the
article), \verb|\articletitleref| (the short title for the
article) and \verb|\articleauthorref| (the article's author).

You may also cross-reference parts of the imported articles,
but you need to prefix the label with the label supplied
in the optional argument of \verb|\importpubpaper| or
\verb|\importarticle|. (If omitted, this is given by 
directory/file name.)

For example, the first appendix in this book is
\appendixref{apd:first}, but the first appendix in
``\articletitleref{paper1/paper1}'' by
\articleauthorref{paper1/paper1}
(pp.~\articlepagesref{paper1/paper1}) is
\appendixref{paper1/paper1apd:first}.
Here's a reference to a couple of tables in 
\articletitleref{paper1/paper1}:
\tableref{paper1/paper1tab:sample,paper1/paper1tab:sample2}.

The author of a foreword (or other chapter) can sign off using
the \texttt{authorsignoff} environment. Each author should be
specified using \verb|\Author|.

\begin{authorsignoff}
\Author{Nicola Talbot\\
University of East Anglia}
\end{authorsignoff}

\begin{preface}
The preface environment should be used for the preface if you want
makejmlrbook to extract the preface and turn it into a standalone
document.

The editorial team can sign off at the end of the preface using
the \texttt{signoff} environment. This has two arguments: the
optional argument is a name for the editorial team (defaults to
``The Editorial Team'') and the mandatory argument is the date.
Within the environment, use \verb|\Editor| for each editor.

\begin{signoff}{March 2010}
% First editor:
\Editor{Nicola Talbot\\
University of East Anglia\\
\mailto{N.Talbot@uea.ac.uk}}
% Second editor:
\Editor{Anne Editor\\
University of Nowhere\\
\mailto{ae@sample.com}}
\end{signoff}

\end{preface}

\tableofcontents

\mainmatter

\part{First Part of the Book}

\chapter{Introduction}

This is an introduction to the book.

\section{Sample Section}

This is a section in the introduction.

\subsection{Sample Sub-Section}

This is a sub-section.

\subsubsection{Sample Sub-Sub-Section}

This is a sub-sub-section.

\paragraph{Sample Sub-Sub-Sub-Section}

This is a sub-sub-sub-section.

\subparagraph{Sample Sub-Sub-Sub-Sub-Section}

This is a sub-sub-sub-sub-section.

% Add a part to the TOC but don't print anything
\addtocpart{Papers Published in JMLR W\&CP}

\begin{jmlrpapers}
  % Prepublished papers are imported using:
  % \importpubpaper[label]{dir}{file}{pages}
  % pages refers to the page range in the original publication
  % which doesn't necessarily correspond to the page numbers in
  % this book.
  \importpubpaper{paper1}{paper1}{23--45}

  \importpubpaper{paper2}{paper2}{63--70}

\end{jmlrpapers}

% Add a part to the TOC but don't print anything
\addtocpart{Unpublished Papers}

\begin{jmlrpapers}
  % Unpublished papers are imported using:
  % \importarticle[label]{dir}{file}
  \importarticle{paper3}{paper3}

  \importarticle{paper4}{paper4}
\end{jmlrpapers}

\appendix

\part{First Part of Appendices}\label{pt:apd1}

\chapter*{Introduction}

This is an introduction to \partref{pt:apd1}.

\chapter{First Appendix}
\label{apd:first}

This is an appendix.

\chapter{Second Appendix}
\label{apd:second}

This is another appendix.

\lipsum

\part{Second Part of Appendices}

\chapter{An Appendix}
\label{apd:third}

This is an appendix in another part.

\lipsum

\end{document}
