fix pdf rendering on production
[librarian.git] / librarian / formats / pdf / res / wl.cls
1 % -*- coding: utf-8 -*-
2 \NeedsTeXFormat{LaTeX2e}
3 \ProvidesClass{wl}[2011/11/28 wolnelektury.pl book style]
4
5 % PDF customizations
6 %
7 % nofootnotes - disable generation of footnotes
8 % nothemes - disable generation of themes
9 % defaultleading - default leading
10 % onehalfleading - leading of 1.5 (interlinia)
11 % doubleleading - double leading (interlinia)
12 % a4paper,... - paper size as required by LaTeX
13 % nowlfont - don't use customized WL font
14
15 \RequirePackage{setspace}
16 \RequirePackage{type1cm}
17 %\RequirePackage{wasysym}
18 \DeclareOption{13pt}{%
19 \AtEndOfClass{%
20 % font size definitions, similar to ones in /usr/share/texmf-texlive/tex/latex/base/
21 \renewcommand\normalsize{%
22    \@setfontsize\normalsize{13pt}{14.5pt}%
23    \abovedisplayskip 12\p@ \@plus3\p@ \@minus7\p@
24    \abovedisplayshortskip \z@ \@plus3\p@
25    \belowdisplayshortskip 6.5\p@ \@plus3.5\p@ \@minus3\p@
26    \belowdisplayskip \abovedisplayskip
27    \let\@listi\@listI}\normalsize%
28 \renewcommand\footnotesize{%
29    \@setfontsize\footnotesize\@xpt\@xiipt
30    \abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@
31    \abovedisplayshortskip \z@ \@plus3\p@
32    \belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@
33    \def\@listi{\leftmargin\leftmargini
34                \topsep 6\p@ \@plus2\p@ \@minus2\p@
35                \parsep 3\p@ \@plus2\p@ \@minus\p@
36                \itemsep \parsep}%
37    \belowdisplayskip \abovedisplayskip
38 }%
39 }%
40 }
41
42 %% \DeclareOption{14pt}{\renewcommand{\normalsize}{\AtEndOfClass{\fontsize{14}{17}\selectfont}}}
43
44 \DeclareOption{defaultleading}{}
45 \DeclareOption{doubleleading}{\AtBeginDocument{\doublespacing}}%\setlength{\leading}{1em plus 0.5ex minus 0.2ex}}
46 \DeclareOption{onehalfleading}{\AtBeginDocument{\onehalfspacing}}%\setlength{\leading}{1em plus 0.5ex minus 0.2ex}}
47
48 %% This does not really work, since dvipdfm(x) will use it's configuration in /etc/texmf/dvipdfm(x) and force a global paper size setting.
49 \DeclareOption{a5paper}{%
50       \setlength{\paperheight}{210mm}%
51       \setlength{\paperwidth}{148mm}}
52
53
54 \newif\ifshowfootnotes \showfootnotestrue
55 \DeclareOption{nofootnotes}{\showfootnotesfalse}
56
57 \newif\ifshowthemes \showthemestrue
58 \DeclareOption{nothemes}{\showthemesfalse}
59
60 \newif\ifenablewlfont \enablewlfonttrue
61 \DeclareOption{nowlfont}{\enablewlfontfalse}
62
63 \DeclareOption*{\PassOptionsToClass{\CurrentOption}{book}}
64 \ProcessOptions\relax
65 \LoadClass[a4paper,oneside]{book}
66
67
68 \usepackage{trace}
69
70 \usepackage[xetex]{graphicx}
71 \usepackage{fontspec}
72 \usepackage{xunicode}
73 \usepackage{xltxtra}
74 \usepackage[Latin,Greek]{ucharclasses}
75
76 \usepackage[overload]{textcase}
77 \usepackage{scalefnt}
78 % TODO: link color is a style thing
79 \usepackage[hyphens]{url}
80 \usepackage[colorlinks=true,linkcolor=black,setpagesize=false,urlcolor=blue,xetex]{hyperref}
81
82 \newfontfamily\substitutefont{GFS Neohellenic}
83 \setTransitionsForGreek{\begingroup\substitutefont}{\endgroup}
84
85 \ifenablewlfont
86 \setmainfont [
87 UprightFont = Dosis-Regular,
88 ItalicFont = Dosis-SemiBold,
89 BoldFont = Dosis-Bold,
90 BoldItalicFont = Dosis-Bold,
91 SmallCapsFont = Dosis-Regular,
92 %UprightFont = JunicodeWL-Regular,
93 %ItalicFont = JunicodeWL-Italic,
94 %BoldFont = Junicode-Bold,
95 %BoldItalicFont = Junicode-BoldItalic,
96 %SmallCapsFont = JunicodeWL-Regular,
97 SmallCapsFeatures = {Letters={SmallCaps,UppercaseSmallCaps}},
98 Numbers=OldStyle,
99 Scale=1.04,
100 LetterSpace=-1.0
101 ] {Dosis}
102
103 %\newfontfamily\alien[
104 %\setmainfont[
105 %SmallCapsFeatures = {Letters={SmallCaps,UppercaseSmallCaps}},
106 %Numbers=OldStyle,
107 %Scale=0.85,
108 %LetterSpace=-1.0
109 %] {FreeSans}
110 %\setmainfont{FreeSans}
111
112
113 \defaultfontfeatures{
114 SizeFeatures={
115   {Size={-10.5}, FakeStretch=1.02, LetterSpace=2.0 },
116   {Size={10.5-12}, FakeStretch=2.00, LetterSpace=0.0 },
117   {Size={12-}, FakeStretch=0.98, LetterSpace=-2.0 }
118 }
119 }
120
121 \renewcommand{\textsc}[1]{%
122 {\addfontfeature{
123 SizeFeatures={
124   {Size={-10.5}, Scale=1.2, FakeStretch=1.02, LetterSpace=8.0 },
125   {Size={10.5-12}, Scale=1.2, FakeStretch=1.02, LetterSpace=8.0 },
126   {Size={12-}, FakeStretch=1.0, LetterSpace=8.0 }
127 },
128 Letters={SmallCaps,UppercaseSmallCaps}
129 }
130 #1}
131 }
132 \fi% enablewlfont
133
134 %{\Itshape JunicodeWL-Italic.ttf }
135 %{\bfseries Junicode-Bold.ttf }
136 %{\bfseries\itshape Junicode-BoldItalic.ttf }
137
138 \pagestyle{plain}
139 \usepackage{fancyhdr}
140
141 \makeatletter
142
143 % bottom figure below footnotes
144 \usepackage{fnpos}
145 \makeFNabove
146
147 \usepackage{color}
148 \definecolor{theme}{gray}{.3}
149
150
151 \setlength{\marginparsep}{2em}
152 %\setlength{\marginparwidth}{8.5em}
153 \setlength{\marginparwidth}{2.5cm}
154 \setlength{\oddsidemargin}{0pt}
155 \setlength{\voffset}{0pt}
156 \setlength{\topmargin}{0pt}
157 \setlength{\headheight}{0pt}
158 \setlength{\headsep}{0pt}
159 \setlength{\textheight}{24cm}
160 \setlength{\textwidth}{16cm}
161 \setlength{\parindent}{0pt}
162 \setlength{\parskip}{1em plus0.4em minus0.3em}
163
164
165 \pagestyle{fancy}
166 \fancyhf{}
167 \renewcommand{\headrulewidth}{0pt}
168 \renewcommand{\footrulewidth}{0pt}
169 \lfoot{{\footnotesize \@organization}} %\@author{} \emph{\@title}}}
170 \cfoot{}
171 \rfoot{{\footnotesize \thepage}}
172
173 \clubpenalty=100000
174 \widowpenalty=100000
175
176
177 % see http://osdir.com/ml/tex.xetex/2005-10/msg00003.html
178 \newsavebox{\ximagebox}\newlength{\ximageheight}
179 \newsavebox{\xglyphbox}\newlength{\xglyphheight}
180 \newcommand{\xbox}[1]
181 {\savebox{\ximagebox}{#1}\settoheight{\ximageheight}{\usebox {\ximagebox}}%
182 \savebox{\xglyphbox}{\char32}\settoheight{\xglyphheight}{\usebox {\xglyphbox}}%
183 \raisebox{\ximageheight}[0pt][0pt]{%\raisebox{-\xglyphheight}[0pt] [0pt]{%
184 \makebox[0pt][l]{\usebox{\xglyphbox}}}%}%
185 \usebox{\ximagebox}%
186 \raisebox{0pt}[0pt][0pt]{\makebox[0pt][r]{\usebox{\xglyphbox}}}}
187
188
189
190 \newcommand{\typosubsubsection}[1]{%
191 {#1}
192 }
193
194 \newcommand{\typosubsection}[1]{%
195 {\addfontfeature{
196 SizeFeatures={
197   {Size={-10}, Scale=1.2, FakeStretch=1.00, LetterSpace=8.0 },
198   {Size={10.5-12}, Scale=1.2, FakeStretch=1.00, LetterSpace=8.0 },
199   {Size={12-}, FakeStretch=1.0, LetterSpace=8.0 }
200 },
201 Letters={Uppercase}
202 }
203 \MakeUppercase{#1}}
204 }
205
206 \newcommand{\typosection}[1]{%
207 {\addfontfeature{FakeStretch=0.96, LetterSpace=-4.0}\emph{\scalefont{2}#1}}
208 %{\addfontfeature{Scale=2.0, FakeStretch=0.98, LetterSpace=-2.0}\emph{#1}}
209 }
210
211
212 \newcommand{\tytul}[1]{%
213 #1%
214 \vspace{1em}%
215 }
216
217 \newcommand{\nazwapodutworu}[1]{%
218 \section*{\typosection{#1}}%
219 }
220
221 \newcommand{\autorutworu}[1]{%
222 \subsection*{\typosubsection{#1}}%
223 }
224
225 \newcommand{\dzielonadrzedne}[1]{%
226 \subsection*{\typosubsubsection{#1}}%
227 }
228
229 \newcommand{\nazwautworu}[1]{%
230 \section*{\raggedright{\typosection{#1}}}%
231 }
232
233 \newcommand{\podtytul}[1]{%
234 \subsection*{\typosubsubsection{#1}}%
235 }
236
237 \newcommand{\translator}[1]{%
238 % TODO: l10n is a style thing
239 \subsection*{\typosubsubsection{tłum. #1}}%
240 }
241
242
243 \newcommand{\powiesc}[1]{#1}
244 \newcommand{\opowiadanie}[1]{#1}
245 \newcommand{\lirykal}[1]{#1}
246 \newcommand{\lirykalp}[1]{#1}
247 \newcommand{\dramatwierszowanyl}[1]{#1}
248 \newcommand{\dramatwierszowanylp}[1]{#1}
249 \newcommand{\dramatwspolczesny}[1]{#1}
250
251 \newcommand{\nota}[1]{%
252 \par{#1}%
253 }
254
255 \newcommand{\dedykacja}[1]{%
256 \begin{em}%
257 \begin{flushright}%
258 #1%
259 \end{flushright}%
260 \end{em}%
261 }
262
263 \newcommand{\dlugicytat}[1]{%
264 \begin{quotation}%
265 #1%
266 \end{quotation}%
267 }
268
269 \newcommand{\poezjacyt}[1]{%
270 \begin{verse}%
271 #1%
272 \end{verse}%
273 }
274 \newcommand{\motto}[1]{%
275 \begin{em}%
276 #1%
277 \end{em}%
278 }
279 \newcommand{\listaosob}[2]{%
280 \par{#1}%
281 \begin{itemize}%
282 #2%
283 \end{itemize}%
284 }
285
286 \newcommand{\nagloweklisty}[1]{%
287 \typosubsubsection{#1}%
288 }
289
290 \newcommand{\listaosoba}[1]{%
291 \item{#1}%
292 }
293
294 \newcommand{\kwestia}[1]{%
295 \par{#1}%
296 }
297
298 \newcommand{\naglowekakt}[1]{%
299 \pagebreak
300 \subsection*{\typosubsection{#1}}%
301 }
302 \newcommand{\naglowekczesc}[1]{%
303 \pagebreak
304 \subsection*{\typosubsection{#1}}%
305 }
306 \newcommand{\srodtytul}[1]{%
307 \subsection*{\typosubsection{#1}}%
308 }
309
310 \newcommand{\naglowekscena}[1]{%
311 \subsubsection*{\typosubsubsection{#1}}%
312 }
313 \newcommand{\naglowekrozdzial}[1]{%
314 {\subsubsection*{\raggedright{\typosubsubsection{#1}}}}%
315 }
316
317 \newcommand{\naglowekosoba}[1]{%
318 \par{\textsc{#1}}\nopagebreak%
319 }
320 \newcommand{\naglowekpodrozdzial}[1]{%
321 \par{#1}\nopagebreak%
322 }
323
324 \newcommand{\miejsceczas}[1]{%
325 \par{\emph{#1}}%
326 }
327 \newcommand{\didaskalia}[1]{%
328 \par{\emph{#1}}%
329 }
330
331 \newcommand{\akap}[1]{%
332 \par{#1}%
333 }
334 \newcommand{\akapdialog}[1]{%
335 \par{#1}%
336 }
337 \newcommand{\akapcd}[1]{%
338 \par{#1}%
339 }
340
341 \newcommand{\mottopodpis}[1]{%
342 \begin{em}%
343 \begin{flushright}%
344 #1%
345 \end{flushright}%
346 \end{em}%
347 }
348
349 \newcommand{\strofa}[1]{%
350 \par{\noindent{\ignorespaces#1\vspace{1em}}}%
351 }
352
353 \newcommand{\wers}[1]{#1}
354
355 \newcommand{\wersakap}[1]{%
356 \hspace*{1em}#1%
357 }
358 \newcommand{\werscd}[1]{%
359 \hspace*{8em}#1%
360 }
361 \newcommand{\werswciety}[2][1em]{%
362 \hspace*{#1}#2%
363 }
364
365 \ifshowfootnotes
366   \newcommand{\pa}[1]{\NoCaseChange{\footnote{#1}}}
367   \newcommand{\pe}[1]{\NoCaseChange{\footnote{#1}}}
368   \newcommand{\pr}[1]{\NoCaseChange{\footnote{#1}}}
369   \newcommand{\pt}[1]{\NoCaseChange{\footnote{#1}}}
370 \else
371   \newcommand{\pa}[1]{}
372   \newcommand{\pe}[1]{}
373   \newcommand{\pr}[1]{}
374   \newcommand{\pt}[1]{}
375 \fi
376
377 \newcommand{\mat}[1]{$#1$}
378
379 \newcommand{\didasktekst}[1]{%
380 \emph{#1}%
381 }
382 \newcommand{\slowoobce}[1]{%
383 \emph{#1}%
384 }
385 \newcommand{\tytuldziela}[1]{%
386 \emph{#1}%
387 }
388 \newcommand{\wyroznienie}[1]{%
389 \emph{#1}%
390 }
391
392 \newcommand{\osoba}[1]{%
393 #1%
394 }
395
396 \newcommand{\sekcjaswiatlo}{%
397 \vspace{30pt}%
398 }
399
400 \newcommand{\sekcjaasterysk}{%
401 \vspace{10pt}%
402 \begin{center}%
403 \par{*}%
404 \end{center}%
405 }
406
407 \newcommand{\separatorlinia}{%
408 \vspace{10pt}%
409 \hrule{}%
410 \vspace{10pt}%
411 }
412
413 \newcommand{\motyw}[2][0]{%
414 \ifshowthemes
415 \mbox{}%
416 \marginpar{%
417 \vspace{-8pt}%
418 \vspace{-#1\baselineskip}%
419 \raggedright{\hspace{0pt}%
420 \footnotesize{\color{theme}{#2}}}%
421 \vspace{\baselineskip}%
422 }%
423 \fi
424 }
425
426
427 \newcommand{\editorialpage}[1]{%
428 #1%
429 \pagebreak%
430 }
431
432 \newcommand{\titlefield}[1]{%
433 \noindent%
434 \begin{minipage}[t]{.7\textwidth}%
435 \vspace{0pt}%
436 #1%
437 \end{minipage}%
438 }
439
440 \newcommand{\toplogo}[3]{%
441 \begin{minipage}[t]{.3\textwidth}%
442 \raggedleft%
443 \vspace{0pt}{\includegraphics[width=#3]{#1}}%
444 \end{minipage}%
445 }