Thinko.
[ttfautohint.git] / doc / template.tex
blob969a451451164e447f1ade6bfbdcaf5021fbd4e8
1 \documentclass[$if(fontsize)$$fontsize$,$endif$%
2 $if(lang)$$lang$,$endif$%
3 DIV=13]{scrreprt}
5 \usepackage{ifxetex,ifluatex}
6 \usepackage[T1]{fontenc}
7 \usepackage[utf8]{inputenc}
8 \usepackage{fixltx2e}
9 \usepackage{libertine}
11 \setkomafont{sectioning}{\normalfont\bfseries}
12 \setkomafont{descriptionlabel}{\normalfont}
13 \setkomafont{caption}{\normalfont\small}
15 $if(highlighting-macros)$
16 $highlighting-macros$
17 $endif$
19 $if(verbatim-in-note)$
20 \usepackage{fancyvrb}
21 $endif$
23 $if(fancy-enums)$
24 % Redefine labelwidth for lists; otherwise, the enumerate package will cause
25 % markers to extend beyond the left margin.
26 \makeatletter
28 \AtBeginDocument{%
29 \renewcommand{\@listi}
30 {\setlength{\labelwidth}{4em}}%
33 \makeatother
35 \usepackage{enumerate}
36 $endif$
38 $if(tables)$
39 \usepackage{ctable}
40 \usepackage{float} % provides the H option for float placement
42 % pandoc uses \medskip between table rows which looks ugly
43 \setupctable{%
44 doinside={\let\medskip\relax}}
45 $endif$
47 $if(url)$
48 \usepackage{url}
49 $endif$
51 $if(graphics)$
52 \usepackage{graphicx}
54 % We will generate all images so they have a width 0.6\maxwidth. This means
55 % that they will get their normal width if they fit onto the page, but are
56 % scaled down if they would overflow this limit.
57 \makeatletter
59 \def\maxwidth{%
60 \ifdim\Gin@nat@width>\linewidth
61 \linewidth
62 \else
63 \Gin@nat@width
64 \fi}
66 \makeatother
68 \let\Oldincludegraphics\includegraphics
69 \renewcommand{\includegraphics}[1]{%
70 \Oldincludegraphics[width=0.6\maxwidth]{#1}}
71 $endif$
73 \ifxetex
74 \usepackage[setpagesize=false, % page size defined by xetex
75 unicode=false, % unicode breaks when used with xetex
76 xetex,
77 colorlinks=true,
78 linkcolor=blue]{hyperref}
79 \else
80 \usepackage[unicode=true,
81 colorlinks=true,
82 linkcolor=blue]{hyperref}
83 \usepackage{microtype}
84 \fi
85 \hypersetup{breaklinks=true, pdfborder={0 0 0}}
87 % We want the names `section 2', `subsection 4.1', and the like in local
88 % links, omitting the original link text. To do that, we redefine \href.
89 \makeatletter
91 \let\original@href\href
93 % Here is the new \href wrapper. We check whether the first token is \#.
94 % If yes, we call \autoref, otherwise the original \href macro. \@nil is a
95 % delimiter token which we need, because we call the arguments in
96 % \modified@href without braces so that we can split off the first token.
97 \def\href#1{%
98 \modified@href #1\@nil}
100 % Using \expandafter makes TeX finish the \if clause before one of the
101 % \almost@xxx macros picks up the arguments.
102 \def\modified@href#1#2\@nil{%
103 \ifx #1\#%
104 \expandafter\almost@autoref
105 \else
106 \expandafter\almost@original@href
108 {#1}{#2}}
110 % We normalize \_ in the reference (argument #2), which we put into
111 % parentheses after the label (argument #3). Argument #1 holds \# which we
112 % skip.
113 \def\almost@autoref#1#2#3{%
114 #3 (\hyper@normalise\autoref{#2})}
116 % For a non-local link, unify the split off first character with the
117 % remaining part of the link.
118 \def\almost@original@href#1#2{%
119 \original@href{#1#2}}
121 \makeatother
123 $if(subscript)$
124 \newcommand{\textsubscr}[1]{%
125 \ensuremath{_{\scriptsize\textrm{#1}}}}
126 $endif$
128 \setlength{\parindent}{0pt}
129 \setlength{\parskip}{6pt plus 2pt minus 1pt}
130 \setlength{\emergencystretch}{3em} % prevent overfull lines
132 % We want a break after the description label (if there is one).
133 \makeatletter
135 \let\original@item\@item
136 \def\description@item[#1]{%
137 \if@noparitem
138 \@donoparitem
139 \else
140 \if@inlabel
141 \indent \par
143 \ifhmode
144 \unskip\unskip \par
146 \if@newlist
147 \if@nobreak
148 \@nbitem
149 \else
150 \addpenalty\@beginparpenalty
151 \addvspace\@topsep
152 \addvspace{-\parskip}%
154 \else
155 \addpenalty\@itempenalty
156 \addvspace\itemsep
158 \global\@inlabeltrue
160 \everypar{%
161 \@minipagefalse
162 \global\@newlistfalse
163 \if@inlabel
164 \global\@inlabelfalse
165 {\setbox\z@\lastbox
166 \ifvoid\z@
167 \kern-\itemindent
168 \fi}%
169 \box\@labels
170 \penalty\z@
172 \if@nobreak
173 \@nobreakfalse
174 \clubpenalty \@M
175 \else
176 \clubpenalty \@clubpenalty
177 \everypar{}%
178 \fi}%
179 \if@noitemarg
180 \@noitemargfalse
181 \if@nmbrlist
182 \refstepcounter\@listctr
185 \sbox\@tempboxa{\makelabel{#1}}%
186 \global\setbox\@labels\hbox{%
187 \unhbox\@labels
188 \hskip \itemindent
189 \hskip -\labelwidth
190 \hskip -\labelsep
191 \ifdim \wd\@tempboxa >\labelwidth
192 \box\@tempboxa
193 \else
194 \hbox to\labelwidth {\unhbox\@tempboxa}%
196 \hskip \labelsep}%
197 \def\reserved@a{#1}%
198 \def\reserved@b{\@itemlabel}%
199 \ifx\reserved@a \reserved@b
200 \else
201 \leavevmode\\
203 \ignorespaces}
205 \renewenvironment{description}{%
206 \list{}{\labelwidth\z@ \itemindent-\leftmargin
207 \let\makelabel\descriptionlabel
208 \let\@item\description@item}%
210 \let\@item\original@item
211 \endlist
214 \makeatother
216 % we want block quotes formatted as italic
217 \renewenvironment{quote}{%
218 \list{}{\rightmargin\leftmargin}%
219 \item\relax
220 \itshape
222 \endlist
227 $if(numbersections)$
228 $else$
229 \setcounter{secnumdepth}{0}
230 $endif$
232 $if(verbatim-in-note)$
233 \VerbatimFootnotes % allows verbatim text in footnotes
234 $endif$
236 $if(lang)$
237 \ifxetex
238 \usepackage{polyglossia}
239 \setmainlanguage{$mainlang$}
240 \else
241 \usepackage[$lang$]{babel}
243 $endif$
245 $for(header-includes)$
246 $header-includes$
247 $endfor$
249 $if(title)$
250 \title{$title$}
251 $endif$
252 \author{$for(author)$$author$$sep$ \and $endfor$}
253 $if(version)$
254 \date{Version $version$}
255 $endif$
257 \begin{document}
258 $if(title)$
259 \maketitle
260 $endif$
262 $for(include-before)$
263 $include-before$
264 $endfor$
266 $if(toc)$
267 \tableofcontents
268 $endif$
270 $body$
272 $for(include-after)$
273 $include-after$
274 $endfor$
276 \end{document}