
%-----------------------------------------------------------------------------
% Chapter: Examples
%-----------------------------------------------------------------------------

\chapter{Examples}
\label{chap:examples}       % Label as much as you can

This file contains a number of examples and templates that you can use while you write
your thesis.

The first example is how to use a citation. \textbackslash {\tt citet} does
an in-text citation, e.g. \citet{optimal} covers a number of important points required
for this thesis. An in-text citation should be used whenever the citation is a natural
component of the sentence.

A parenthetical citation is used when a sourced isn't explicitly mentioned in the text,
but you would like to cite the ideas incorporated or presented in it, e.g. The simplest
way to define a partial ordering of inheritance for a dependent prior is to use the
operations used to generate the predictors \citep{optimal}.

\section{Equations}
Environments for equations, tables, and figures are also quite useful. Here are some templates
that you can use.

For equations, use the {\tt align} environment for multi-line equations, and the {\tt equation}
for a one-line equation. You can use labels in those equations

\begin{align}
  X      &\sim \mathcal{N}(0,\sigma^2) \label{eq:distribution} \\
  P(X<4) &= \frac{1}{\sigma\sqrt{2\pi}}\exp{\frac{-16}{2\sigma^2}}
\end{align}

You can add labels to individual lines for an {\tt align} environment, and then use \textbackslash eqref\{eq:labelname\} to
reference it. So in this place I can say that the distribution of $X$ is described in \eqref{eq:distribution}.

Equations should flow with the paper, so make sure to include proper punctuation, even if it looks a little
strange. As an example, \emph{$X$ follows the distribution}

\begin{equation}
  \mathcal{N}(0,\sigma^2)
  ,
\end{equation}

\emph{which makes it amenable to many different types of manipulations.}

As you can see, the equation was a clause of the sentence, and so was properly followed by a comma.

\section{Tables}

Tables should appear in {\tt table} environments, which have support for {\emph captions}. The table below can
be used as a template, for short tables.

\begin{table}[!ht]
  \begin{center}
  \begin{tabular}{l|ccccccccc} \toprule
    {\bf Position}  & 1     & 2       & 3     & 4       & 4     & 6       & 7     & 8       & 9 \\ \midrule
    {\bf Predictor} & $A_1$ & $A_1^2$ & $A_2$ & $A_2^2$ & $B_1$ & $B_1^2$ & $B_2$ & $B_2^2$ & $AB$ \\ \bottomrule
  \end{tabular}
  \caption{\em Example positions and variables represented by $\gamma$. }
  \label{tab:ex_gamma}
  \end{center}
\end{table}

The toprule, midrule, and bottomrule commands make horizontal rules of varying widths, that nicely format the table
for viewing.

If your table is especially long, use the {\tt longtable} environment. This environment allows you to specify a header
to repeat at the beginning of each new page the table spans. Longtables do not require the {\tt table} environment,
since they are a wrapper and will take care of that themselves. The only thing to note is that {\bf the caption and
the label must appear within the table body, not afterwards}. The {\tt endhead} directive marks the end of the header
to be repeated.

\begin{longtable}{lp{12cm}} \toprule
  {\bf Symbol}         & {\bf Description} \\ \midrule \endhead
  $\gamma$             & Vector of binary (0/1) values indicating inclusion of particular predictors in the model. \\
  $\gamma_j$           & Inclusion (0/1) value for predictor j. \\
  $\gamma_{(-j)}$      & All of gamma without the entry for j. \\
  $X, (d)$             & Set of all predictors (number of predictors). \\
  $X_m, (d_m)$         & Set of main predictors (number of main predictors). \\
  \caption{\em Symbols used in this thesis.}
  \label{tab:glossary}
\end{longtable}

\section{Figures}

Figures should reside in the figures/ directory, and are included in a {\tt figure} environment, similar in layout
to the {\tt table environment}. In the figure below, there is a tikz example.

\begin{figure}[!ht]
  \centering
  \begin{tikzpicture}
  \matrix (m) [matrix of math nodes,row sep=2em,column sep=2em,minimum width=2em]
  { A^2    & A   &    & B   & B^2  \\
    A_2^2  & A_2 & AB & B_2 & B_2^2 \\};
    \path[-stealth]
      (m-1-1) edge (m-1-2)
      (m-2-2) edge (m-1-2)
      (m-2-1) edge (m-2-2)
              edge (m-1-1)
      (m-1-5) edge (m-1-4)
      (m-2-4) edge (m-1-4)
      (m-2-5) edge (m-2-4)
              edge (m-1-5)
      (m-2-3) edge (m-1-2)
              edge (m-1-4)
              ;
  \end{tikzpicture}
  \caption{\em Example inheritance chain for 2 predictors.}
  \label{fig:dep_two_preds}
\end{figure}

For figures that you're generating from plotting programs like Matlab or R, it's best to generate the plots as
PDFs. Keep in mind that the page dimensions are 8.1 inches high, and 6 inches across. Generating your plots
to take these measurements into account will make your life easier when it comes to typeset larger figures.
