\documentclass{amsbook}
\usepackage[frame, a4, center]{crop}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{natbib}
\usepackage[utf8]{inputenc}

% PACKAGES FOR TYPESETTING THIS DOCUMENT, RATHER SPECIAL ONES
\usepackage{multicol}
\usepackage{fancyvrb}
\usepackage{fvrb-ex-sidebyside}
\usepackage{subfigure} 
\usepackage{graphicx}

% SEE AMS FAQ 
% http://www.ams.org/authors/author-faq.html#amsltheorem 
% FOR EXPLANATION
\newtheorem{theorem}{Theorem}[chapter] 
\newtheorem{lemma}[theorem]{Lemma}

\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{example}[theorem]{Example}
\newtheorem{xca}[theorem]{Exercise}

\theoremstyle{remark}
\newtheorem{remark}[theorem]{Remark}

\numberwithin{section}{chapter}
\numberwithin{equation}{chapter}

% SET PAPER WIDTH AND HEIGHT TO b5 PAPER DIMENSIONS
\setlength{\paperwidth}{176mm} 
\setlength{\paperheight}{250mm}
\calclayout

% YOUR OWN MACROS
% IF YOU WANT TO DEFINE A LARGE NUMBER OF MACROS,
% YOU CAN PLACE THEM INTO A SEPARATE FILE AND
% INCLUDE THE FILE USING \input{your_file_name_without_tex_suffix}
% DIRECTIVE (EXAMPLE \include{macros} WILL INCLUDE
% mactos.tex FILE) 

\DeclareMathOperator{\divergenceOperator}{div}
\renewcommand{\vec}[1]{\ensuremath{\mathbf{#1}}}


\begin{document}

\frontmatter
% COVER

\title{Hints for preparing documents in \LaTeX}

% REMOVE ANY UNUSED AUTHOR TAGS
% AUTHOR ONE INFORMATION
\author{V\'{\i}t Pr\r{u}\v{s}a}
\address{Mathematical Institute, Faculty of Mathematics and Physics, Charles University, Sokolovsk\'a 83, Prague 8, 186 75, Czech Republic}
\curraddr{Jind\v{r}ich Ne\v{c}as Center for Mathematical Modeling, Th\'amova~7, Prague 8, 186 75, Czech Republic}
\email{prusv@karlin.mff.cuni.cz}
\thanks{The author was supported by the Jind\v{r}ich Ne\v{c}as Center for Mathematical Modeling, LC06052.}

% SEE http://www.ams.org/msc/ FOR AMS SUBJECT CLASSIFICATION
\subjclass[2000]{Primary 76-00}
\keywords{fluid mechanics, partial differential equations}

\date{\today}

\begin{abstract}
Some useful hints for typesetting mathematics and an example how to use \texttt{amsbook} document class with \texttt{b5} paper.
\end{abstract}

\maketitle
\tableofcontents


\mainmatter
% INCLUDE MAIN CHAPTERS HERE

\chapter{Useful constructions in \LaTeX\ and AMS classes}
\label{ch:constructions}
Hereby I want to summarize a couple of usefull \LaTeX\ commands and constructs that can ``make life easier''. The text is infomal, has character of personal notes, and it si surely not comprehensive (there are many usefull \LaTeX commands and here I present only a small part of them), nevertheless I hope that you will find it worth of reading. The text is sill in development, and probably will be never finished because there will always exist possibility to improve it and make it more comprehensive.
\section{Displayed equations}
\label{sec:displayedEqs}
AMS classes provide extensive support for typesetting equations. It is worth to read documentation for \Verb|amsmath| package, because it can prevent you from reinventing wheel (thus form painfully defining own macros that were in fact prepared by professionals). One should at least notice \Verb|multline| environment that is used for typesetting long equations that spread over several lines.

\begin{SideBySideExample}
  \begin{multline*}
    \pi b_k
    \int_{-\pi}^{\pi}f(x) \sin kx {dx}
    \\
    =
    -\int_{-\pi}^{0} \cos x \sin kx {dx}
    +
    \int_{0}^{\pi} \cos x \sin kx {dx}
    \\
    =
    2 \int_{0}^{\pi} \cos x \sin kx {dx}
    \\
    =
    2 \int_{0}^{\pi} 
    \frac{1}{2} 
    \left(
      \sin ((k+1)x) - \sin((1-k)x)
    \right){dx}
  \end{multline*}
\end{SideBySideExample}

A good practise is to use \Verb|align| environment instead of \Verb|eqnarray| environment. The reason is that the former provides you better spacing (\Verb|eqnarray| is somehow inconsistent in spacing the left and right hand side -- you can find details on the Internet).

\begin{SideBySideExample}
  \begin{align*}
    \frac{1}{\sqrt{\pi}}\|f\|_{L^2} 
    &= 
    \frac{1}{\sqrt{\pi}} 
    \sqrt{\int_{-\pi}^{\pi} |f(x)|^2 dx},
    \\
    \| b_k\|_{\ell^2} 
    &= 
    \sqrt{\sum_{l=1}^{+\infty} 
      \left( \frac{8}{\pi}  \frac{l}{4l^2-1} \right)^2}.
  \end{align*}
\end{SideBySideExample}

Another interesting interesting environment is \Verb|cases| that provides a simple interface for typesetting definitions of piecewise defined functions and other similiar things.

\begin{SideBySideExample}
  \begin{multline*}
    \frac{(-1)^k}{k+1} + \frac{1}{k+1}
    +
    \frac{(-1)^k}{k-1} + \frac{1}{k-1}
    \\
    =
    \begin{cases}
      0, & k=2l-1, l \in \mathbb{N},\\
      \frac{4k}{k^2-1}, & k=2l, l \in \mathbb{N}.  
    \end{cases}
  \end{multline*}
\end{SideBySideExample}

\section{Equation labeling}
\label{sec:labeling}
If you want to label your equations with an abbreviation like NSE for the Navier--Stokes equations you can use the \Verb|\tag| commnand (see the example below). Furthermore, you can see that the \Verb|aligned| environment enables to denote a group of equations by a single label.

\begin{SideBySideExample}
  The problem of stability of fluid flows 
  (first introduced by \cite{Reynolds83}) 
  is a very old and difficult to solve problem. 
  The so-called Navier--Stokes equations 
  (in the dimensional form)
  \begin{equation}
  \tag{NSE}\label{eq:NSE}
  \begin{aligned}
    \frac{\partial \vec{u}}{\partial t} 
    + 
    \left[ \nabla \vec{u} \right] \vec{u}
    &=
    -\frac{1}{\rho}\nabla p + \nu \Delta \vec{u}, \\
    \divergenceOperator \vec{u} 
    &=
    0,\\
    \vec{u}(0,x)
    &=
    \vec{u}_0(x),\\
    \left. \vec{u} \right|_{\partial \Omega} 
    &= 0,
  \end{aligned}
  \end{equation}
  that describe motion of a fluid\dots
\end{SideBySideExample}

\section{Subequations}
\label{sec:subequations}

Sometimes one wants to number equations in a group with some subordinate numbering. This can be done using \Verb|subequations| environment. Furthermore, you can also reffer to the group as whole. See the example below.
\begin{SideBySideExample}
  The problem of stability of fluid flows 
  (first introduced by \cite{Reynolds83}) 
  is a very old and difficult to solve problem. 
  The so-called Navier--Stokes equations 
  (in the dimensional form)
  \begin{subequations}
    \label{eq:NSEparent}
    \begin{align}
      \frac{\partial \vec{u}}{\partial t} 
      + 
      \left[ \nabla \vec{u} \right] \vec{u}
      &=
      -\frac{1}{\rho}\nabla p + \nu \Delta \vec{u}, \\
      \label{eq:divergenceEquation}
      \divergenceOperator \vec{u} 
      &=
      0,\\
      \vec{u}(0,x)
      &=
      \vec{u}_0(x),\\
      \left. \vec{u} \right|_{\partial \Omega} 
      &= 0,
    \end{align}
  \end{subequations}
  that describe motion of a fluid\dots Let us first
  discuss equation \eqref{eq:divergenceEquation} that
  can be seen as a constraint in \eqref{eq:NSEparent}.
\end{SideBySideExample}

\section{Subfigures}
\label{sec:subfigures}

Not only equations can by grouped together, sometimes one also wants to group figures. This can be done using \Verb|subfigure| package. Figure \ref{subfig:cubeSectionA} (thta contains two subfigures \ref{subfig:cubeSectionA} and \ref{subfig:cubeSectionB}) was produced by the following commands
\begin{center}
\begin{Verbatim}[fontsize=\tiny]
  \begin{figure}
    \centering
    \subfigure[Cube section -- surface.]
    {\label{subfig:cubeSectionA}\includegraphics[width=0.45\textwidth]{rezKrychli}}
    \subfigure[Cube section -- curve and its orientation.]
    {\label{subfig:cubeSectionB}\includegraphics[width=0.45\textwidth]{rezKrychliOrientace}}
    \caption{Stokes theorem -- the surface is given as intersection of the plane and cube.}
    \label{fig:cubeSection}
  \end{figure}
\end{Verbatim}
\end{center}
as usual one can reffer to the Figure using \Verb|\ref{subfig:cubeSectionA}| and to the subrigures using \Verb|\ref{subfig:cubeSectionA}|.

  \begin{figure}
    \centering
    \subfigure[Cube section -- surface.]
    {\label{subfig:cubeSectionA}\includegraphics[width=0.45\textwidth]{rezKrychli}
}
    \subfigure[Cube section -- curve and its orientation.]
    {\label{subfig:cubeSectionB}\includegraphics[width=0.45\textwidth]{rezKrychliOrientace}}
    \caption{Stokes theorem -- the surface is given as intersection of the plane $x+y+z=\frac{3}{2}a$ and the cube $[0,a]^3$.}
    \label{fig:cubeSection}
  \end{figure}

\section{Referring to equations}
\label{sec:equations}
If you want to give refference to an equation, you should use \Verb|\eqref| command instead of \Verb|\ref| command -- \Verb|\eqref| automatically adds brackets.
\begin{SideBySideExample}
  The famous Euler identity
  \begin{equation}
    \label{eq:eulerIdentity}
    e^{ix} = \cos x + i \sin x,
  \end{equation}
  is well-know to almost everybody.
  Substituting $x=\pi$ to \eqref{eq:eulerIdentity} 
  gives identity $e^{i\pi}=-1$ that is\dots 
\end{SideBySideExample}


\section{Referring to sections}
\label{sec:referring}
You can refer not only to equations, but also to sections, chapters, figures and so on. See the example below.
 
\begin{SideBySideExample}
  In section \ref{sec:labeling} we formulated the 
  Navier--Stokes equations \eqref{eq:NSE}. The 
  statement of the main theorem is the following.
  \begin{theorem}[Main theorem]
    Let $\vec{u}$, $p$ is a solution to the 
    system \eqref{eq:NSE}, then\dots
  \end{theorem}
\end{SideBySideExample}

You should avoid using hard coded references -- you never know how will be the theorems, sections, items and other things like this numbered in the final document. Furthermore if you insert a new theorem between some old ones, the theorem numbering changes, and under these circumstances it is almost impossible to keep the hardcoded references valid.


\section{\texttt{DeclareMathOperator} command}
\label{sec:DeclareMathOperator}
If you want to define a new operator (you will typically need it for signum and divergence operators that are not defined in the basic set of operators) you should do this using \texttt{DeclareMathOperator} command. The command provides you \emph{the} standard approach for defining new operators and other ways how to define new operators should be avoided -- the advantage of this approach is that the operator defined by \Verb|DeclareMathOperator| has the same properties as usual operators such $\lim$, $\sup$, $\det$ and others.

Therefore if \Verb|\DeclareMathOperator{\divergenceOperator}{div}| is placed in preamble of the document, one can use the following construction to typeset the divergence operator

\begin{SideBySideExample}
  Divergence of the velocity field 
  $\divergenceOperator \vec{u}$ 
  is equal to\dots
\end{SideBySideExample}


\chapter{Tools for document preparation}
\label{ch:tools}

\section{Text editor}
\label{sec:textEditor}
Probably the best text editor is (in my opinion) \Verb|GNU Emacs| combined with \Verb|AUCTeX| tools. For cross-referencing you can use Emacs's \Verb|reftex-mode| mode.

\section{Figures}
\label{sec:figures}
\Verb|XFig| and \Verb|fig2eps| script is the best combination to plot figures. \Verb|gnuplot| is very usefull tool fpr plotting graphs (both 2D and 3D).


\section{Bibliography}
\label{sec:bibliography}
A useful tool for managing bibliography is \Verb|biblist| package -- you can print all items (thus not only the items referenced in a particular text) in your bibliography using the following construction.


\begin{Verbatim}[fontsize=\tiny]
  \documentclass{article}
  \usepackage{biblist}
  \begin{document}
  \bibliographystyle{plain}
  \bibliography{}
  \end{document}
\end{Verbatim}



\backmatter
% ANY BIBLIOGRAPHY STYLE IS ACCEPTABLE. 
% WE WILL STRONGLY APPRECIATE IF YOU CAN 
% SEND US YOUR BibTeX DATABASE FILE 
% (IF YOU USE BibTeX).

\bibliographystyle{plainnat}
\bibliography{mybibliography}

\end{document}
