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