% The Online BRT Planning Guide
%
% DO NOT EDIT THIS FILE MANUALLY!
%
% This file has been automatically generated from its sources
% using the OBRT tool:
%  tool version: 364c3e5
%  haxe version: 3.4.0
%  runtime: JS
%  platform: Linux

% included from `guide/preamble.tex`
% @ guide/the-guide.src: lines 1-1: code points 1-27
\documentclass[8pt]{extreport}

% monkey-patching tools
\usepackage{etoolbox}

% checks for xetex, luatex or either
\usepackage{ifxetex,ifluatex}
\newif\ifxelua
\ifxetex
	\xeluatrue
\else\ifluatex
	\xeluatrue
\else
	\xeluafalse
\fi\fi

% fonts, languages and encoding
% TODO make paths relative to the preamble, not the generated book
\ifxelua
	\usepackage{fontspec}
	\defaultfontfeatures{
		Ligatures = {TeX}
	}
	% assume that .fonts/ has been exported
	\setmainfont{PTF}[  % PT Serif Regular
		Path = ./fonts/PTSerif/,
		UprightFont = *55F,
		BoldFont = *75F,
		ItalicFont = *56F,
		BoldItalicFont = *76F
	]
	\setsansfont{PTS}[  % PT Sans Regular
		Path = ./fonts/PTSans/,
		UprightFont = *55F,
		BoldFont = *75F,
		ItalicFont = *56F,
		BoldItalicFont = *76F
	]
	\setmonofont{PTM}[  % PT Mono Regular
		Path = ./fonts/PTMono/,
		UprightFont = *55F,
		BoldFont = *75F,
	]
	\newfontfamily\familycaprm{PTZ}[  % PT Serif Caption Regular
		Path = ./fonts/PTSerif/,
		UprightFont = *55F,
		ItalicFont = *56F,
	]
	\newfontfamily\familycapsf{PTC}[  % PT Sans Caption Regular
		Path = ./fonts/PTSans/,
		UprightFont = *55F,
		BoldFont = *75F,
	]
	\newfontfamily\familynsf{PTN}[  % PT Sans Narrow Regular
		Path = ./fonts/PTSans/,
		UprightFont = *57F,
		BoldFont = *77F,
	]
	\usepackage{polyglossia}
	\setdefaultlanguage{english}
\else
	% compatibility with regular pdftex is desired, even if only for tests
	\usepackage{ucs}
	\usepackage[utf8x]{inputenc}
	\usepackage[T1]{fontenc}
	\let\familycaprm\rmfamily
	\let\familycapsf\sffamily
	\let\familycapnsf\sffamily
	\usepackage{paratype}
	\usepackage[main=english]{babel}
	% hacks for unavailable chars
	\DeclareTextCommandDefault{\textalpha}{\,\texttt{alpha}\,}
	\DeclareTextCommandDefault{\textbeta}{\,\texttt{beta}\,}
	\DeclareTextCommandDefault{\textlambda}{\,\texttt{lambda}\,}
	\DeclareTextCommandDefault{\textDelta}{\,\texttt{DELTA}\,}
	\DeclareUnicodeCharacter{9608}{\kern -0.1em\rule[-0.2em]{.8em}{1.2em}}
\fi

% font style
\let\emphasis\textit
\let\highlight\textbf

%pagesize
\usepackage{geometry}
\geometry{a4paper,total={105mm,243mm},left=35mm,top=18mm,marginparsep=7mm,marginparwidth=49mm,headsep=5.5mm,footskip=9mm}

%header & footer
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE]{\nouppercase\footnotesize\textsf{\color{gray25}BRT Planning Guide}}
\fancyhead[RO]{\nouppercase\footnotesize\textsf{\color{gray25}\leftmark}}
\fancyfoot[LE,RO]{\color{gray25}\thepage}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\fancypagestyle{plain}{\fancyhf{}}

%colors
\usepackage{xcolor}
\definecolor{gray75}{gray}{0.25}
\definecolor{gray50}{gray}{0.5}
\definecolor{gray25}{gray}{0.75}
\definecolor{greenbrt}{cmyk}{0.75,0,0.75,0.25}
%volumecolors
\definecolor{volumeI}{cmyk}{0.2,1,0.4,0}
\definecolor{volumeII}{cmyk}{0.8,1,0.3,0.2}
\definecolor{volumeIII}{cmyk}{1,0.7,0.25,0.1}
\definecolor{volumeIV}{cmyk}{0.85,0.45,0.2,0}
\definecolor{volumeV}{cmyk}{0.65,0.2,1,0.05}
\definecolor{volumeVI}{cmyk}{0.25,0.6,1,0.1}
\definecolor{volumeVII}{cmyk}{0.25,1,1.4,0.15}
\definecolor{volumeVIII}{gray}{0.25}

%headings
\usepackage{titlesec}
\titleformat{\part}[display]{\bfseries\huge\color{volume\thepart}\familycapsf}{{\fontsize{10mm}{10mm}\selectfont VOLUME \thepart}}{0pt}{\vskip 5mm \rule{105mm}{1.5mm} \\ \vskip 2.25mm}[]
\titleformat{\chapter}[display]{\bfseries\LARGE\color{volume\thepart}\familycapsf}{}{0pt}{\thechapter.\ }[]
\titleformat*{\section}{\bfseries\Large\color{volume\thepart}\familycapsf}
\titleformat*{\subsection}{\bfseries\large\color{volume\thepart}\sffamily}
\titleformat*{\subsubsection}{\bfseries\sffamily}
\titlespacing*{\chapter}{0mm}{0mm}{2.25mm plus 2.25mm}[0pt]
\titlespacing*{\section}{0mm}{4.5mm plus 4.5mm}{2.25mm plus 2.25mm}[0pt]
\titlespacing*{\subsection}{0mm}{2.25mm plus 2.25mm}{0mm plus 2.25mm}[0pt]
\titlespacing*{\subsubsection}{0mm}{2.25mm plus 2.25mm}{0mm plus 2.25mm}[0pt]
\newcommand\setnextcounter[2]{\setcounter{#1}{#2}\addtocounter{#1}{-1}}
\newcommand\volume[2]{\setnextcounter{part}{#1}\part{#2}}
\let\uchapter=\chapter\renewcommand\chapter[2]{\setnextcounter{chapter}{#1}\uchapter{#2}}
\let\usection=\section\renewcommand\section[2]{\setnextcounter{section}{#1}\usection{#2}}
\let\usubsection=\subsection\renewcommand\subsection[2]{\setnextcounter{subsection}{#1}\usubsection{#2}}
\let\usubsubsection=\subsubsection\renewcommand\subsubsection[2]{\setnextcounter{subsubsection}{#1}\usubsubsection{#2}}

%workaround for titlesec 2.10.1 issue with missing labels
%http://tex.stackexchange.com/a/300259/46436
\makeatletter
\patchcmd{\ttlh@hang}{\parindent\z@}{\parindent\z@\leavevmode}{}{}
\patchcmd{\ttlh@hang}{\noindent}{}{}{}
\makeatother

%box
\usepackage{framed}

\renewenvironment{leftbar}[1][\hsize]
{%
    \def\FrameCommand
    {%
        {\hspace{-6.5mm} \color{volume\thepart}\vrule width 1mm}
        \hspace{3.0mm}
        \fboxsep=0mm
    }%
    \MakeFramed{\hsize#1}%
}
{\endMakeFramed}

\newcommand{\boxtitle}[2]{{\noindent\bfseries\color{volume\thepart}\familycapsf Box \thechapter.#1. #2} \\ }
\def\beginbox#1#2{ 
	\begin{leftbar} 
	\vskip 3.5mm
	\boxtitle{#1}{#2} 
}
\def\endbox{ \vskip 3.5mm \end{leftbar} }

% code
\let\code\texttt
\def\begincode{
	\begingroup
	\vskip 3.5mm
	\parindent=0mm
	\parskip=0mm
	\baselineskip=0mm
	\color{gray50}
	\small
	\ttfamily  % FIXME
}
\def\endcode{
	\vskip 3.5mm
	\endgroup
}

%list
\usepackage{enumitem}
\setlist{nolistsep,leftmargin=7mm,rightmargin=7mm}
\labelindent=7mm

% images - img {width}{filename} - fignote{figure number}{text}{credits}
% requires a group ({})
\usepackage{graphicx}
\newcommand{\img}[2]{\noindent\includegraphics[width=#1]{#2} \\}
\newcommand{\fignote}[3]{\noindent\raggedright\footnotesize\sffamily\color{gray50}{\bfseries Figure \thechapter.#1.} #2 {\itshape #3} \par}

%quotation {quote}{name, about, 1900 - 2000}
\renewcommand{\quotation}[2]{\begingroup\leftskip=14mm\rightskip=14mm {\small\color{gray50} \noindent\textit{``#1''} \\\hbox{}\hfill --- #2} \par\endgroup \smallskip }

%tables
%note: \tablemodule*46 must match \textwidth+\marginparsep+\marginparwidth
\usepackage{ifoddpage}
\newdimen\tablemodule \tablemodule=\textwidth \divide\tablemodule by 30
\newcommand{\tabletitle}[2]{{\noindent\bfseries\color{volume\thepart}\sffamily Table \thechapter.#1. #2} \par }
\newcommand{\tablesource}[1]{\noindent\raggedright\footnotesize\sffamily\color{gray50}{\bfseries Source:} #1 \par \smallskip}

\AtBeginDocument{
	\parskip=0mm plus 4.5mm
	\baselineskip=4.5mm
	\parindent=7mm
	\color{gray75}
}

%tmp
\usepackage{lipsum}

\usepackage[
    bookmarks,
    colorlinks,
    draft=false,
    linkcolor=black,
    citecolor=black,
    pdftitle={The BRT Planning Guide},  % TODO fetch from somewhere
    pdfauthor={Institute for Transportation and Development Policy},
    unicode
]{hyperref}  % FIXME needs some styling

\usepackage{amsmath}

\begin{document}

This should be a landing page for the Guide.\par
% @ guide/the-guide.src: lines 4-4: code points 1-44

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ac bibendum dui. Aliquam neque ligula, aliquet vitae felis at, auctor condimentum libero. Aliquam id diam nibh. Donec condimentum sodales felis vel viverra. Phasellus semper metus sit amet dui congue, a dignissim nibh accumsan. Suspendisse pellentesque sem quis tortor consectetur, vel imperdiet leo cursus. Fusce bibendum, nibh in viverra suscipit, erat lorem ornare ipsum, a lobortis elit nulla ac ante. Mauris id consequat sapien. Nunc laoreet augue eget finibus interdum. Suspendisse eu metus fermentum, vestibulum turpis ut, venenatis urna. Nulla vitae metus sit amet ligula imperdiet euismod. Vivamus vitae nisi tellus. Cras varius tortor quis nunc pretium luctus. Cras justo erat, posuere quis ante sed, fermentum fermentum libero. Duis consequat, magna eu consectetur iaculis, felis dolor convallis dui, id dignissim turpis tortor id risus. Vivamus feugiat efficitur pellentesque.\par
% @ guide/the-guide.src: lines 6-6: code points 1-948

\highlight{Table of contents}\par
% @ guide/the-guide.src: lines 8-8: code points 1-29

Aliquam in bibendum elit, at accumsan odio. Maecenas a lorem interdum, aliquet diam a, iaculis odio. Sed congue molestie nulla sed varius. In id congue ipsum. Aliquam elit sapien, lacinia id dictum gravida, porttitor a massa. Donec pulvinar iaculis ex, id consequat nulla ultricies id. Fusce sed sem sit amet sem mollis gravida non eget quam. Vivamus consequat lectus enim, eu posuere augue vulputate eget. In ac cursus nulla. Nam convallis mollis erat suscipit blandit. Nam ligula arcu, laoreet in enim non, tristique varius lorem. Integer condimentum tortor sit amet malesuada pellentesque. Maecenas at massa sit amet felis cursus blandit eget ut nisi. Pellentesque ut suscipit augue. Fusce eget ante quis ex varius vulputate. Aliquam eget sodales enim, id pellentesque purus.\par
% @ guide/the-guide.src: lines 10-10: code points 1-778

\highlight{Introduction}\par
% @ guide/the-guide.src: lines 12-12: code points 1-24

Nam urna purus, pharetra et ornare ac, semper id lectus. Vestibulum efficitur urna eget aliquam congue. Vivamus mi mauris, feugiat et ex ut, iaculis rutrum leo. Praesent viverra tortor in erat condimentum vulputate. Nullam faucibus purus nisl, sed feugiat nibh cursus vel. Nunc at justo eu eros interdum maximus. Fusce varius sodales risus, quis facilisis turpis consectetur quis. Donec aliquam neque quis massa mattis consectetur. Donec at placerat dui, ac ultricies sem. Mauris accumsan quis dui nec vehicula. Sed sed ligula vitae urna dictum volutpat eu et ante. Maecenas eget ullamcorper metus. Suspendisse rutrum blandit leo, vitae finibus erat interdum vitae.\par
% @ guide/the-guide.src: lines 14-14: code points 1-665

Aliquam erat volutpat. Nullam non ex nec ligula tempor rhoncus. Nullam non nulla eget quam convallis faucibus vitae et mi. Cras tincidunt lectus vitae sem auctor cursus. Aliquam volutpat in sapien in dictum. Phasellus sed nulla facilisis, volutpat massa laoreet, viverra nulla. Aenean sit amet elit eu neque finibus vulputate ut luctus enim. Integer sagittis, arcu non euismod hendrerit, elit lacus blandit tortor, id fermentum neque libero non nisi. Vestibulum lobortis consectetur turpis a vulputate. Sed malesuada mollis sagittis. Donec sagittis convallis sem, eu aliquet diam gravida a. Vivamus quis aliquam lacus.\par
% @ guide/the-guide.src: lines 16-16: code points 1-618

Phasellus sed lacus ac erat luctus pretium a at massa. Ut quis massa nec dui rutrum faucibus sit amet vitae magna. Nulla ex erat, rhoncus a imperdiet quis, vehicula vitae nulla. Pellentesque sodales ultricies elit, et eleifend dui dignissim ut. Vestibulum feugiat enim et urna blandit, sit amet commodo enim finibus. Aliquam erat volutpat. Sed facilisis congue dolor sit amet pretium. Ut sit amet lorem imperdiet, hendrerit nisl eget, hendrerit turpis. Proin ac velit id dui imperdiet molestie. Vestibulum eget volutpat risus. Nullam vestibulum, nunc a molestie ultrices, nibh magna ullamcorper risus, id finibus risus est sit amet orci. Nulla aliquam lorem nec fringilla gravida. Sed eget vulputate lectus. Fusce magna felis, congue et fermentum nec, efficitur et augue. In tristique auctor neque, vel blandit diam tempus et. Nulla pellentesque placerat ipsum in venenatis.\par
% @ guide/the-guide.src: lines 18-18: code points 1-874

\input{project-preparation.tex}

\input{operations.tex}

\input{communications-and-marketing.tex}

\input{business-plan.tex}

\input{technology.tex}

\input{infrastructure.tex}

\input{integration.tex}

\input{meta.tex}

\end{document}
