Fix order of header inclusion.
[ttfautohint.git] / doc / template.tex
blob0ed23f103b5316158093ed94e68a74d1f6337231
1 % This template only works with luatex or XeTeX if you use non-ASCII
2 % characters.
4 \documentclass[$if(fontsize)$$fontsize$,$endif$%
5 $if(lang)$$lang$,$endif$%
6 DIV=13]{scrreprt}
8 \usepackage{ifxetex,ifluatex}
9 \usepackage[T1]{fontenc}
10 \usepackage{fixltx2e}
11 \usepackage{libertine}
13 % Libertine Mono is too ugly; we use lmodern instead
14 \renewcommand{\ttfamily}{\fontfamily{lmtt}\selectfont}
16 \setkomafont{sectioning}{\normalfont\bfseries}
17 \setkomafont{descriptionlabel}{\normalfont}
18 \setkomafont{caption}{\normalfont\small}
20 $if(highlighting-macros)$
21 $highlighting-macros$
22 $endif$
24 $if(verbatim-in-note)$
25 \usepackage{fancyvrb}
26 $endif$
28 $if(fancy-enums)$
29 % Redefine labelwidth for lists; otherwise, the enumerate package will cause
30 % markers to extend beyond the left margin.
31 \makeatletter
33 \AtBeginDocument{%
34 \renewcommand{\@listi}
35 {\setlength{\labelwidth}{4em}}%
38 \makeatother
40 \usepackage{enumerate}
41 $endif$
43 $if(tables)$
44 % We use a patched version of longtable until a serious clash with
45 % floats get fixed.
46 \usepackage{longtable-patched}
47 \usepackage{booktabs}
49 % pandoc inserts \addlinespace after each line...
50 \defaultaddspace=1pt
52 % XXX The \addlinespace macro, as used in the LaTeX code generated by
53 % pandoc, overrides any vertical space adjustments for \toprule and friends,
54 % which is quite unfortunate. I consider this a bug in pandoc 1.12.2.1.
55 % It's not too difficult to fix this, but I had to redefine a lot of
56 % booktabs commands, which I don't want. Since the layout degradation is
57 % minor, I simply wait until it gets fixed in pandoc.
59 %\aboverulesep=0.3em
60 %\belowrulesep=0.3em
61 $endif$
63 $if(url)$
64 \usepackage{url}
65 $endif$
67 $if(graphics)$
68 \usepackage{graphicx}
70 % We will generate all images so they have a width 0.6\maxwidth. This means
71 % that they will get their normal width if they fit onto the page, but are
72 % scaled down if they would overflow this limit.
73 \makeatletter
75 \def\maxwidth{%
76 \ifdim\Gin@nat@width>\linewidth
77 \linewidth
78 \else
79 \Gin@nat@width
80 \fi}
82 \makeatother
84 \let\Oldincludegraphics\includegraphics
85 \renewcommand{\includegraphics}[1]{%
86 \Oldincludegraphics[width=0.6\maxwidth]{#1}}
87 $endif$
89 \ifxetex
90 \usepackage[setpagesize=false, % page size defined by xetex
91 unicode=false, % unicode breaks when used with xetex
92 xetex,
93 colorlinks=true,
94 linkcolor=blue]{hyperref}
95 \else
96 \usepackage[unicode=true,
97 colorlinks=true,
98 linkcolor=blue]{hyperref}
99 \usepackage{microtype}
100 % don't apply protrusion to \texttt
101 \UseMicrotypeSet[protrusion]{basicmath}
103 \hypersetup{breaklinks=true,
104 pdfauthor={$author-meta$},
105 pdftitle={$title-meta$},
106 pdfborder={0 0 0}}
108 % We want the names `section 2', `subsection 4.1', and the like in local
109 % links, omitting the original link text. To do that, we redefine
110 % \hyperref.
111 \makeatletter
113 % We transform
115 % \hyperref[foo]{bar}
117 % into
119 % bar (\autoref{foo})
121 \def\label@hyperref[#1]#2{%
122 #2 (\autoref{#1})}
124 \makeatother
126 $if(subscript)$
127 \newcommand{\textsubscr}[1]{%
128 \ensuremath{_{\scriptsize\textrm{#1}}}}
129 $endif$
131 \setlength{\parindent}{0pt}
132 \setlength{\parskip}{6pt plus 2pt minus 1pt}
133 \setlength{\emergencystretch}{4em} % prevent overfull lines
135 % We want a break after the description label (if there is one).
136 \makeatletter
138 \let\original@item\@item
139 \def\description@item[#1]{%
140 \if@noparitem
141 \@donoparitem
142 \else
143 \if@inlabel
144 \indent \par
146 \ifhmode
147 \unskip\unskip \par
149 \if@newlist
150 \if@nobreak
151 \@nbitem
152 \else
153 \addpenalty\@beginparpenalty
154 \addvspace\@topsep
155 \addvspace{-\parskip}%
157 \else
158 \addpenalty\@itempenalty
159 \addvspace\itemsep
161 \global\@inlabeltrue
163 \everypar{%
164 \@minipagefalse
165 \global\@newlistfalse
166 \if@inlabel
167 \global\@inlabelfalse
168 {\setbox\z@\lastbox
169 \ifvoid\z@
170 \kern-\itemindent
171 \fi}%
172 \box\@labels
173 \penalty\z@
175 \if@nobreak
176 \@nobreakfalse
177 \clubpenalty \@M
178 \else
179 \clubpenalty \@clubpenalty
180 \everypar{}%
181 \fi}%
182 \if@noitemarg
183 \@noitemargfalse
184 \if@nmbrlist
185 \refstepcounter\@listctr
188 \sbox\@tempboxa{\makelabel{#1}}%
189 \global\setbox\@labels\hbox{%
190 \unhbox\@labels
191 \hskip \itemindent
192 \hskip -\labelwidth
193 \hskip -\labelsep
194 \ifdim \wd\@tempboxa >\labelwidth
195 \box\@tempboxa
196 \else
197 \hbox to\labelwidth {\unhbox\@tempboxa}%
199 \hskip \labelsep}%
200 \def\reserved@a{#1}%
201 \def\reserved@b{\@itemlabel}%
202 \ifx\reserved@a \reserved@b
203 \else
204 \leavevmode\\
206 \ignorespaces}
208 \renewenvironment{description}{%
209 \list{}{\labelwidth\z@ \itemindent-\leftmargin
210 \let\makelabel\descriptionlabel
211 \let\@item\description@item}%
213 \let\@item\original@item
214 \endlist
217 \makeatother
219 % we want block quotes formatted as italic
220 \renewenvironment{quote}{%
221 \list{}{\rightmargin\leftmargin}%
222 \item\relax
223 \itshape
225 \endlist
230 $if(numbersections)$
231 \setcounter{secnumdepth}{5}
232 $else$
233 \setcounter{secnumdepth}{0}
234 $endif$
236 $if(verbatim-in-note)$
237 \VerbatimFootnotes % allows verbatim text in footnotes
238 $endif$
240 $if(lang)$
241 \ifxetex
242 \usepackage{polyglossia}
243 \setmainlanguage{$mainlang$}
244 \else
245 \usepackage[$lang$]{babel}
247 $endif$
249 $for(header-includes)$
250 $header-includes$
251 $endfor$
253 $if(title)$
254 \title{$title$}
255 $endif$
256 \author{$for(author)$$author$$sep$ \and $endfor$}
257 $if(version)$
258 \date{Version $version$}
259 $endif$
261 \begin{document}
262 $if(title)$
263 \maketitle
264 $endif$
266 $for(include-before)$
267 $include-before$
268 $endfor$
270 $if(toc)$
271 \tableofcontents
272 $endif$
274 $body$
276 $for(include-after)$
277 $include-after$
278 $endfor$
280 \end{document}