%%% Build instructions
%%% pdflatex -shell-escape ceres && bibtex ceres && pdflatex -shell-escape ceres && pdflatex -shell-escape ceres

\documentclass[11pt,letterpaper,oneside]{memoir}
\usepackage{fouriernc}
\usepackage[T1]{fontenc}
\usepackage{minted,amsmath,amssymb,amsthm,url,booktabs}
\usepackage[pdftex]{graphicx}
\usepackage[sort&compress]{natbib}
\usepackage[breaklinks=true,letterpaper=true,colorlinks,bookmarks=false]{hyperref}
\usepackage{algorithm}
\usepackage{algorithmic}

% page dimensions
\addtolength{\textwidth}{1.5in}
\addtolength{\oddsidemargin}{-0.75in}
\addtolength{\evensidemargin}{-0.75in}
\addtolength{\spinemargin}{-0.75in}
\addtolength{\foremargin}{-0.75in}
\setlength{\parindent}{0.0in}
\setlength{\parskip}{0.12in}

% Our pagestyle
\copypagestyle{ceres}{headings}
\makeevenhead{ceres}{\thepage}{}{\scshape\rightmark}
\makeoddhead{ceres}{\scshape\rightmark}{}{\thepage}

%% ceres chapter style
\makechapterstyle{ceres}{%
\renewcommand{\chapterheadstart}{}%
\renewcommand{\printchaptername}{}%
\renewcommand{\chapternamenum}{}%
\renewcommand{\printchapternum}{}%
\renewcommand{\afterchapternum}{}%
\renewcommand{\printchaptertitle}[1]{%
\raggedright\Large\scshape\MakeLowercase{##1}}%
\renewcommand{\afterchaptertitle}{%
\vskip\onelineskip \hrule\vskip\onelineskip}%
}%
\renewcommand{\cftchapterfont}{\normalfont}%
\renewcommand{\cftchapterpagefont}{\normalfont}%
\renewcommand{\cftchapterpresnum}{\bfseries}%
\renewcommand{\cftchapterleader}{}%
\renewcommand{\cftchapterafterpnum}{\cftparfillskip}%


%% Section title style
\setsecheadstyle{\raggedright\scshape\MakeLowercase}%
\setbeforesecskip{-\onelineskip}%
\setaftersecskip{\onelineskip}%

%% Subsection title style

\setsubsecheadstyle{\sethangfrom{\noindent ##1}\raggedright\itshape}%
\setbeforesubsecskip{-\onelineskip}%
\setaftersubsecskip{\onelineskip}%

\captiontitlefont{\small\sffamily}%
\let\caption\legend


\title{\Huge\scshape
\MakeLowercase{Ceres Solver:  Tutorial \& Reference}
}
\author{
\scshape\MakeLowercase{Sameer Agarwal} \\ \texttt{sameeragarwal@google.com} 
\and 
\scshape\MakeLowercase{Keir Mierle} \\  \texttt{ keir@google.com}
}
\checkandfixthelayout

\pagestyle{ceres}

\newcommand{\ceres}{{Ceres }}
\newcommand{\reals}{\mathbb{R} }
\def\eg{\emph{e.g. }}
\def\ie{\emph{i.e. }}
\newcommand{\glog}{\texttt{google-glog}}
\newcommand{\gflags}{\texttt{gflags}}
\newcommand{\eigen}{\texttt{Eigen3}}
\newcommand{\suitesparse}{\texttt{SuiteSparse}}
\newcommand{\cholmod}{\texttt{CHOLMOD}}
\newcommand{\amd}{\texttt{AMD}}
\newcommand{\colamd}{\texttt{COLAMD}}
\newcommand{\lapack}{\texttt{LAPACK}}
\newcommand{\blas}{\texttt{BLAS}}
\newcommand{\denseschur}{\texttt{DENSE\_SCHUR}}
\newcommand{\sparseschur}{\texttt{SPARSE\_SCHUR}}
\newcommand{\iterativeschur}{\texttt{ITERATIVE\_SCHUR}}
\newcommand{\cmake}{\texttt{cmake}}
\newcommand{\protobuf}{\texttt{protobuf}}
\settocdepth{chapter}

\begin{document}
\chapterstyle{ceres}
\maketitle
\thispagestyle{empty}
\newpage
\pagestyle{ceres}
\tableofcontents
\newpage

\chapter{A Note to the Reader}
Building this pdf from source requires a relatively recent installation of \texttt{LaTeX}~\footnote{\url{http://www.tug.org/texlive/}}, \texttt{minted.sty}\footnote{\url{http://code.google.com/p/minted/}} and \texttt{pygments}\footnote{\url{http://pygments.org/}}.

Despite our best efforts, this manual remains a work in progress and the source code for Ceres Solver remains the ultimate reference.

\input{changes}
\input{introduction}
\input{build}

%% Tutorial
\part{Tutorial}
\label{part:tutorial}
\input{nnlsq}
\input{helloworld}
\input{powell}
\input{curvefitting}
\input{bundleadjustment}

%% Reference
\part{Reference}
\label{part:reference}
\input{reference-overview}
\input{modeling}
\input{solving}

\input{faq}
\input{further}
\bibliographystyle{plain}
\bibliography{ceres-solver}
\end{document}