
% This is the preamble used to adjust the formatting of the TeX/PDF version of
% the manual. Edit as needed.

\setcounter{tocdepth}{3}

% Uncomment for A4 paper.
\usepackage{a4wide}

% Better use sloppy formatting, to avoid bad line breaks.
%\sloppy

% We use Palatino for the main text, Bera Mono for typewriter, and Helvetica
% Narrow for section titles. These should be available in most recent TeX
% installations, YMMV. So you might have to fiddle with the definitions below.

\usepackage{mathpazo}

\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage[scaled=0.86]{beramono}

\usepackage[titles]{tocloft}
% Use Helvetica-Narrow Bold for Chapter entries in the toc.
\renewcommand{\cftchapfont}{\usefont{OT1}{phv}{bc}{n}}

% Use Helvetica for the section titles.
\usepackage{sectsty}
\allsectionsfont{\usefont{OT1}{phv}{bc}{n}}

% Fancy formatting of chapter titles.
% (Just comment out these two lines if you don't want that.)
% \usepackage[Bjarne]{fncychap}
\usepackage[Lenny]{fncychap}
\usepackage{fncychap}
\ChTitleVar{\Huge\usefont{OT1}{phv}{bc}{n}}

% Get rid of the chapter numbers altogether.
% (This breaks figure numbers and the like, disabled for now.)
% \renewcommand{\DOCH}{}
% \renewcommand{\chaptername}{}
% \renewcommand{\thechapter}{}
% %\renewcommand*{\chapterformat}{}
% \makeatletter
% \renewcommand*\thesection{\@arabic\c@section}
% \makeatother

% Fancy headers.
\usepackage{fancyhdr}
\pagestyle{fancy}

\renewcommand{\chaptermark}[1]{\markboth{\thechapter{} #1}{\thechapter{} #1}}
\renewcommand{\sectionmark}[1]{\markboth{\thesection{} #1}{\thesection{} #1}}
\renewcommand{\subsectionmark}[1]{\markright{\thesubsection{} #1}{}}

% Suppress headers on blank pages before chapters etc.
% \makeatletter
% \def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
%   \hbox{}
%   \thispagestyle{empty}
%   \newpage
%   \if@twocolumn\hbox{}\newpage\fi\fi\fi}
% \makeatother

% Nicely formatted program listings.
% \usepackage{listings}
% \lstdefinelanguage{Pure}
% {morekeywords={case,when,with,end,const,def,else,extern,if,infix,infixl,infixr,let,namespace,nonfix,of,otherwise,outfix,private,public,prefix,postfix,then,using},
%  sensitive=true,
%  morecomment=[l]{//},
%  morecomment=[s]{/*}{*/},
%  morestring=[b]",
% }
% \lstset{language=pure,columns=flexible}
% \lstset{basicstyle=\ttfamily,keepspaces=true,commentstyle=,showstringspaces=false}

% Set up the hyperref package.
\usepackage[breaklinks]{hyperref}
\hypersetup{bookmarksnumbered,pdfborder=0 0 0}

% Some hacks to make the hyperlinks look nicer.

% This marks links with a little arrowhead (requires older svn snapshots).
% \usepackage{patchcmd}
% \makeatletter
% \newcommand{\before@hyperref}{}
% \newcommand{\fancyhref}{\renewcommand{\before@hyperref}{$\triangleright$}}
% \newcommand{\plainhref}{\renewcommand{\before@hyperref}{}}
% \patchcommand\href{\before@hyperref}{}
% \patchcommand\hyperref{\before@hyperref}{}
% \fancyhref
% \makeatother

% Uncomment this to make links black instead of Sphinx's defaults.
% \hypersetup{
%     linkcolor=black,  % color of internal links
%     citecolor=black,  % color of links to bibliography
%     filecolor=black,  % color of file links
%     urlcolor=black    % color of external links
% }

% Make the docutils optionlist environment look nicer.
\ifthenelse{\isundefined{\optionlistlabel}}{
% Presumably we have a new snapshot of rst2latex which already has the
% DUoptionlist environment.
\newenvironment{DUoptionlist}[1]
{\begin{list}{}{\renewcommand{\makelabel}{\DUoptionlistlabel}}}{\end{list}}
\newcommand{\DUoptionlistlabel}[1]{\texttt{\textbf{#1}} \hfill}
}{
% "Old" rst2latex. We need to override the existing optionlist environment.
\renewenvironment{optionlist}[1]
{\begin{list}{}{\renewcommand{\makelabel}{\optionlistlabel}}}{\end{list}}
\renewcommand{\optionlistlabel}[1]{\texttt{\textbf{#1}} \hfill}
}
