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