\documentclass[openany]{now} % creates the journal version
% \documentclass{now}  % creates the book pdf version

% the now document class sets various dimensions, so be sure to *not* set
% or alter dimensions in your latex code.
% be sure to remove all manual formatting commands such \newpage, \clearpage.

% a few definitions that are *not* needed in general:
\newcommand{\ie}{\emph{i.e.}}
\newcommand{\eg}{\emph{e.g.}}
\newcommand{\etc}{\emph{etc}}
\newcommand{\now}{\textsc{now}}

\title{Using the Foundations and Trends \LaTeX\ Macros}

\author{
Neal Parikh \\
Stanford University \\
npparikh@cs.stanford.edu
\and
Stephen Boyd \\
Stanford University \\
boyd@stanford.edu
}

\begin{document}

% the following settings can be set or left blank at first
\copyrightowner{N.~Parikh and S.~Boyd}
% \volume{1}
% \issue{3}
% \pubyear{2014}
% \copyrightyear{2013}
% \isbn{978-0521833783}
% \doi{1234567890}
% \firstpage{23}
% \lastpage{94}

\frontmatter  % title page, contents, catalog information

\maketitle

\tableofcontents

\mainmatter

\begin{abstract}
This document describes how to prepare a \LaTeX\ document written
using the standard article or book format 
in the format required for a Foundations and Trends journal.
You should view the PDF output (this document, \texttt{sample.pdf})
along with the \LaTeX\ source code (\texttt{sample.tex}) that created it
to get the full picture.
\end{abstract}

\chapter{Introduction}
\label{c-intro} % a label for the chapter, to refer to it later

\section{Obtaining the required files}
\label{s-files} % another label

You will need the following four files: 
\texttt{now.cls}, 
\texttt{frontmatter.tex},
\texttt{now\_logo.eps}, and 
\texttt{essence\_logo.eps}.
You can get the set for your journal from the \now\ website and they
should be placed into the directory with your \LaTeX\ source. The
\texttt{frontmatter.tex} file is specific to each journal; in this sample we
use the frontmatter appropriate for \emph{Foundations and Trends in
Optimization}.

\section{Preparing the \LaTeX\ source}

Once you have obtained the required files as described in \S\ref{s-files}, you
need to prepare your \LaTeX\ source.  If you have written vanilla \LaTeX\
source, it should be easy to convert to \now\ format; this process is described
in detail in Chapter~\ref{c-converting}. You can then typeset your source as
usual \citep{Lam:94} using \texttt{pdflatex} (or \texttt{latex} and \texttt{dvipdf})
and \texttt{bibtex}.

\iffalse
\section{Creating the output PDF file}
You create a PDF file by running the following commands:
\begin{verbatim}
pdflatex paper.tex
bibtex paper.tex
pdflatex paper.tex
pdflatex paper.tex
\end{verbatim}
You need to run \texttt{pdflatex} twice only to ensure that all the references are
up to date. If you are using a package that requires the use of PostScript, like
\texttt{psfrag}, then you should instead use the following:
\begin{verbatim}
latex paper.tex
bibtex paper.tex
latex paper.tex
latex paper.tex
dvipdf paper.dvi
\end{verbatim}
We recommend using \texttt{pdflatex} unless you have a good reason not to.
If you are unfamiliar with any of this, see Lamport~\citep{Lam:94} or any
other standard \LaTeX\ references.
\fi

\chapter{Converting Your \LaTeX\ Source}
\label{c-converting}

The \now\ style files follow standard \LaTeX\ constructions as much as possible
and are based on \LaTeX's \texttt{book} class,
so if you are starting with a good \LaTeX\ file, it should be very easy
to convert to \now\ format.

You can refer to a bare bones document outline in Appendix~\ref{s-bare-bones}.
To convert your article to a \now\ book, do the following:

\begin{enumerate}
\item If your paper currently uses the class \texttt{article}, 
convert all \texttt{\textbackslash section}s to \texttt{\textbackslash chapter}s, 
\texttt{\textbackslash subsection}s to
\texttt{\textbackslash section}s, and \texttt{\textbackslash subsubsection}s 
to \texttt{\textbackslash subsection}s.

\item Insert \texttt{\textbackslash frontmatter}, \texttt{\textbackslash mainmatter},
and \texttt{\textbackslash backmatter} commands at the locations shown in
Appendix~\ref{s-bare-bones}. These are from the \texttt{book} class, so
you may only need to do this if you are starting with an \texttt{article}.

\item Remove the following packages:
\texttt{amsthm},
\texttt{caption},
\texttt{emptypage},
\texttt{fancyhdr},
\texttt{fontenc},
\texttt{fullpage},
\texttt{geometry},
\texttt{graphicx},
\texttt{lastpage},
\texttt{lmodern},
\texttt{multicol}, and
\texttt{url}.
They are incompatible with the class \texttt{book}, interfere with 
or modify the output style, or are already included.

\item Remove any commands that modify anything to do with the page size,
spacing, fonts, pagination, or anything else related to the general display of
the document. For example, remove any \texttt{\textbackslash clearpage} or
\texttt{\textbackslash newpage} commands. Similarly, remove any custom
formatting or definitions for theorem, lemma, definition, and similar
environments. The \texttt{amsthm} package is already included with definitions
for environments described in \S\ref{s-theorem-envs}.

\item Ensure the paper's abstract is defined in an \texttt{abstract}
environment and placed \emph{after} the \texttt{mainmatter} command, as shown
in Appendix~\ref{s-bare-bones}.

\item Change the document class to

\texttt{\textbackslash documentclass\{now\}}

to produce the book version or 

\texttt{\textbackslash documentclass[openany]\{now\}}

to produce the journal version of the paper.

\item Optionally, include an \texttt{acknowledgements} or \texttt{acknowledgments}
environment (either spelling works) after the final main chapter but before any
appendices, as shown in Appendix~\ref{s-bare-bones}.

\item Optionally, include any of the following commands as needed:

\begin{verbatim}
\volume{1}
\issue{3}
\pubyear{2013}
\copyrightyear{2013}
\isbn{XXX}
\doi{XXX}
\firstpage{80}
\lastpage{94}
\copyrightowner{N.~Parikh and S.~Boyd}
\end{verbatim}

These can be included before \texttt{\textbackslash maketitle}. Default values
will be used for these if they are not provided. Consult \now\ for the
appropriate values for your paper; you should provide the copyright owner in
the format given above.
\end{enumerate}

\chapter{Style Guidelines}

In this chapter we outline guidelines that you should follow when preparing
your document.  This includes information on use of \TeX\
\citep{KB:86} and \LaTeX\ \citep{Lam:94} themselves, as well as style guidelines
for Foundations and Trends journals in particular.

\section{Bibliography}

Use a BiB\TeX\ file as usual and set the bibliography style to
\texttt{plain} or \texttt{plainnat} as needed for the particular
journal you are writing for.

\section{Referring to your paper}

Your paper is being published in multiple formats (such as a book and a journal
article), so you should avoid terms such as ``book'', ``article'', and ``paper''
when referring to the work itself. Instead, please use terms such as ``monograph'',
``tutorial'', ``review'', or ``survey''.`` 

\section{Titles}

Capitalize the first letter of all words of chapter titles 
(except for filler words like `the' and `and', of course). 
You should capitalize words appearing in hyphenated constructions, as in
Interior-Point Methods.
For all other titles (sections, subsections, subsubsections, paragraphs),
capitalize only the first letter and any proper nouns, as in this document.

You may prefer a different capitalization scheme, for example, 
capitalizing all words in section titles as well. This is fine, but be sure that
you are absolutely consistent in your scheme.

\section{References}

When referring to sections (chapters, appendices)
using \texttt{\textbackslash ref}, refer to chapters
as Chapter~5 but sections as \S5.1. To produce the section symbol, use
\texttt{\textbackslash S}.  When referring to tables or figures, write
Table~7.1 or Figure~5.3. When referring to equations, write simply (3.4) or
Equation~3.4. The former can be more easily obtained using
\texttt{\textbackslash eqref\{\}} from the \texttt{amsmath} package (not
included by the \now\ class itself).

\section{Preface and other special chapters}

If you want to include a preface, it should be defined as follows:
\begin{quote}
\begin{verbatim}
\chapter*{Preface}
\addcontentsline{toc}{chapter}{Preface}
\markboth{\sffamily\slshape Preface}
  {\sffamily\slshape Preface}
\end{verbatim}
\end{quote}
This ensures that the preface appears correctly in the table of contents
and the running headings.

You can follow a similar procedure if you want to include additional
unnumbered chapters (\eg, a chapter on notation used in the paper),
though all such chapters should precede Chapter 1.

Unnumbered chapters should not include numbered sections. If you want
to break your preface into sections, use the starred versions of
\texttt{section}, \texttt{subsection}, \etc.

\section{Figures and plots}

Don't use the optional positioning commands in figures, tables, etc.
Make caption text consistent in syntax and style.

\section{Mathematics}
Be consistent in formatting equations and make sure they are consistent 
with the surrounding English syntax.
As an example: 
\begin{quote}
When $\theta >0$, we have
\[
\theta + \theta^2 > \theta.
\]
\end{quote}
Note the comma after the fragment `$\theta>0$' and the period after the displayed
inequality. The sentence starts with the English word `When' and ends with 
the displayed equation.
(By the way, many authors have adopted the convention that a 
sentence should always start in English, and not with a mathematical 
formula or equation.)

Be sure to distinguish mathematics from English, even in sub- and super-scripts.
For example, do not write $sin(\theta)$, which typesets `sin' as
three mathematical symbols next to each other; the correct version is $\sin(\theta)$.
As a more subtle example, consider 
\[
\theta_i \leq \theta^\mathrm{max}, \quad i=1, \ldots, K.
\]
Here the superscript `max' is correctly rendered in roman font, since it refers
to the English word `max' or `maximum'.  The wrong way is to write $\theta_i
\leq \theta^{max}$. 

In general, mathematics should be typeset using built-in mathematical commands like
\texttt{\textbackslash sin}, variables should be typeset in math mode, and
English in math mode should be typeset in standard roman font.  Combining
these, we get, for example, $\sin(x^n + x^\mathrm{max})$.

\section{Source code}
\label{s-formatting-source}

We recommend that you hard wrap your \LaTeX\ source to, say, 72 characters or
equivalent, and that you put display mathematical equations in a paragraph on their
own line. See the source code of this document itself for an example.
This is to make the source code both easier to read and easier to debug. 
If you have entire paragraphs on a single line, it can become difficult
to track down \LaTeX\ compilation errors when it complains about a given line.

\section{Making the output look good}
\label{s-never-do-this}

You may be tempted to fine-tune the \LaTeX\ source to attempt to make the 
output look good
by, say, forcing a line break or a page break at a good place, or by adding 
or subtracting vertical or horizontal space in the document.
Our advice on this is simple:

\begin{center}
\textbf{Never do this.}
\end{center}

Never adjust the \LaTeX\ source to make the output look better.
Keep your \LaTeX\ source completely free of commands that adjust the 
particular output using custom spacing or positioning commands.
Leave this task to \TeX\ and \LaTeX.

Of course, tables and figures that are clearly too large to fit in
the margins should be appropriately shrunk, either by reducing the font size or
by breaking up the table to use fewer columns. Another example is a long URL
which wreaks havoc on the typesetting; you can put these on a line by
themselves.

The \emph{only exception} to this important rule is on the very last pass, 
right before your article goes into production; see Appendix~\ref{c-fine-tuning}.

% end of main matter

\begin{acknowledgements}
\addcontentsline{toc}{chapter}{Acknowledgements}
We would like to thank Donald Knuth and Leslie Lamport for their work
on \TeX\ and \LaTeX, respectively, as well as the many others who
have developed the \LaTeX\ packages we rely on for our own work.
\end{acknowledgements}

\appendix

\chapter{Bare Bones File Outline}
\label{s-bare-bones}

\begin{verbatim}
\documentclass{now}

\title{Article Title}

\author{
Neal Parikh \\
Stanford University \\
npparikh@cs.stanford.edu
\and
Stephen Boyd \\
Stanford University \\
boyd@stanford.edu
}

\begin{document}

% \firstpage, \doi, etc. as needed

\frontmatter

\maketitle

\tableofcontents

\mainmatter

\begin{abstract}
The abstract goes here.
\end{abstract}

\chapter{Introduction}
This is the text for the first chapter.

\chapter{Conclusion}
The text for the last chapter goes here.

\begin{acknowledgements}
Don't forget to thank your mom, without whom your article
would not have been possible.
\end{acknowledgements}

\appendix

\chapter{First Appendix}
This is an appendix with many technical details, or
a summary of other needed material.

\backmatter

\bibliographystyle{plain} % or plainnat
\bibliography{mybibfile}
\end{verbatim}

\chapter{Sample Formatting}

In this chapter, we illustrate various environments that are available to the
author. See the source code of this document itself to see how to produce this
display. You can define your own additional environments using the
usual \texttt{amsthm} procedure, but you should not customize the theorem style;
the theorem style will automatically use the \now\ one.

\section{Theorem environments}
\label{s-theorem-envs}

\begin{definition}[contraction mapping]
    Let $(X,d)$ be a metric space. Then a map $T : X \to X$ is called a
    \emph{contraction mapping} on $X$ if there exists $q \in [0,1)$ such
    that
    \[
        d(T(x),T(y)) \leq q d(x,y)
    \]
    for all $x,~y$ in $X$.
\end{definition}

\begin{theorem}[Banach fixed point theorem]
Let $(X, d)$ be a non-empty complete metric space with a contraction mapping 
$T : X \to X$. Then $T$ admits a unique fixed-point $x^*$ in $X$ (\ie, $T(x^*) = x^*$).
Furthermore, $x^*$ can be found as follows: start with an arbitrary element $x_0$ in
X and define a sequence $x_n$ by $x_n = T(x_{n-1})$, then $x_n \to x^*$.
\end{theorem}

\begin{proof}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris non metus et
lorem euismod ullamcorper vel at justo. Curabitur dignissim dui eget suscipit
facilisis. Sed odio dolor, laoreet at tempus auctor, rhoncus ac lorem. Etiam ac
nibh lobortis, vehicula urna lacinia, aliquam quam.
\end{proof}

\begin{lemma}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris non metus et
lorem euismod ullamcorper vel at justo. Curabitur dignissim dui eget suscipit
facilisis. Etiam ac nibh lobortis, vehicula urna lacinia, aliquam quam.
\end{lemma}

\begin{corollary}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris non metus et
lorem euismod ullamcorper vel at justo. Curabitur dignissim dui eget suscipit
facilisis. Etiam ac nibh lobortis, vehicula urna lacinia, aliquam quam.
\end{corollary}

\begin{remark}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris non metus et
lorem euismod ullamcorper vel at justo. Curabitur dignissim dui eget suscipit
facilisis. Etiam ac nibh lobortis, vehicula urna lacinia, aliquam quam.
\end{remark}

\begin{proposition}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris non metus et
lorem euismod ullamcorper vel at justo. Curabitur dignissim dui eget suscipit
facilisis. Etiam ac nibh lobortis, vehicula urna lacinia, aliquam quam.
\end{proposition}

\begin{example}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris non metus et
lorem euismod ullamcorper vel at justo. Curabitur dignissim dui eget suscipit
facilisis. Etiam ac nibh lobortis, vehicula urna lacinia, aliquam quam.
\end{example}

\section{Internet addresses}

The \now\ class file includes the \texttt{url} package, so you should wrap
email and web addresses with \texttt{\textbackslash url\{\}}. This will
also make these links clickable in the PDF.

\chapter{Fine-Tuning}
\label{c-fine-tuning}

Remember that you should generally never fine-tune your \LaTeX\ source to make
the output look good; see \S\ref{s-never-do-this} on
page~\pageref{s-never-do-this}.  This appendix describes the \emph{only time}
when you can and should fine-tune your source.  Before proceeding, be
sure that these are the very last adjustments to be made to your \LaTeX\
source before the article appears.

\section{Positioning floats}

You may need to alter the positioning information for floating
environments such as tables and figures. In general, tables and figures with
captions should appear at the top of the page. Unless a figure is large enough
to take up most of a page, it should not appear on a page by itself. If you
want to force, say, two figures to appear one on top of each other on
their own page, you can use the following code or equivalent:
\begin{quote}
\begin{verbatim}
\begin{figure}[p]
\begin{center}
\includegraphics{figure_one}
\end{center}
\label{f-one}
\caption{Figure One.}
\begin{center}
\includegraphics{figure_two}
\end{center}
\label{f-two}
\caption{Figure Two.}
\end{figure}
\end{verbatim}
\end{quote}
An alternative is to use the \texttt{subfigure} package.

Again, you should generally \emph{not} modify the placement of
figures and tables. This should be done only when really necessary 
and then only in the last pass over a document, right before it goes
into production.

\section{Pagination}

By and large, pagination is very well-handled by default by
\TeX's typesetting algorithms. In some cases, however, the typesetting
engine requires some help to do the right thing. This can even involve
rewriting specific parts of the text of the article. 

Bringhurst~\citep[\S2.4]{Bri:12} suggests\footnote{We have slightly
edited the raw text for brevity.} the following guidelines:
\begin{quote}
    \emph{Avoid leaving the end of a hyphenated word, or any
    word shorter than four letters, as the last line of a paragraph.}

    \emph{Never begin a page with the last line of a paragraph.}

    The typographic terminology is telling. The stub-ends left when paragraphs
    \emph{end} on the \emph{first} line of a page are called \emph{widows}.
    They have a past but not a future, and they look foreshortened and
    forelorn.  It is the custom to give them one additional line for company.
    This rule is applied in close conjunction with the next.  
\end{quote}
Fixing such issues often involves rewriting some sentences in the relevant
paragraph or preceding paragraphs. They should typically not be addressed
with manual page breaks or other forced typesetting.

\section{Long chapter and section names}

If you have a very long chapter or section name, it may not appear nicely
in the table of contents, running heading, document body, or some subset of these.
It is possible to have different text appear in all three places if needed
using the following code:
\begin{quote}
\begin{verbatim}
\chapter[Table of Contents Name]{Body Text Name}
\chaptermark{Running Heading Name}
\end{verbatim}
\end{quote}
Sections can be handled similarly using the \texttt{sectionmark} command
instead of \texttt{chaptermark}.

For example, the full name should always appear in the table of contents, but
may need a manual line break to look good. For the running heading,
an abbreviated version of the title should be provided. The appearance of the long
title in the body may look fine with \LaTeX's default line breaking method
or may need a manual line break somewhere, possibly in a different place from
the contents listing.

Long titles for the article itself should be left as is, with no manual line
breaks introduced. The article title is used automatically in a
number of different places by the class file, and manual line breaks will
interfere with the output. If you have questions about how the title appears
in the front matter, please contact \now.

\backmatter  % references

\bibliographystyle{plainnat}
\bibliography{sample}

\end{document}
