update to new format of cwiczenie wybor
[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 \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
75 \usepackage[overload]{textcase}
76 \usepackage{scalefnt}
77 % TODO: link color is a style thing
78 \usepackage[hyphens]{url}
79 \usepackage[colorlinks=true,linkcolor=black,setpagesize=false,urlcolor=blue,xetex]{hyperref}
80
81 \ifenablewlfont
82 \setmainfont [
83 %ExternalLocation,
84 UprightFont = Dosis-Regular,
85 ItalicFont = Dosis-SemiBold,
86 BoldFont = Dosis-Bold,
87 BoldItalicFont = Dosis-Bold,
88 SmallCapsFont = Dosis-Regular,
89 SmallCapsFeatures = {Letters={SmallCaps,UppercaseSmallCaps}},
90 Numbers=OldStyle,
91 Scale=1.04,
92 LetterSpace=-1.0
93 ] {Dosis}
94
95 \newfontfamily\alien[
96 SmallCapsFeatures = {Letters={SmallCaps,UppercaseSmallCaps}},
97 Numbers=OldStyle,
98 Scale=0.85,
99 LetterSpace=-1.0
100 ] {DejaVu Serif}
101
102
103 \defaultfontfeatures{
104 SizeFeatures={
105   {Size={-10.5}, FakeStretch=1.02, LetterSpace=2.0 },
106   {Size={10.5-12}, FakeStretch=2.00, LetterSpace=0.0 },
107   {Size={12-}, FakeStretch=0.98, LetterSpace=-2.0 }
108 }
109 }
110
111 \renewcommand{\textsc}[1]{%
112 {\addfontfeature{
113 SizeFeatures={
114   {Size={-10.5}, Scale=1.2, FakeStretch=1.02, LetterSpace=8.0 },
115   {Size={10.5-12}, Scale=1.2, FakeStretch=1.02, LetterSpace=8.0 },
116   {Size={12-}, FakeStretch=1.0, LetterSpace=8.0 }
117 },
118 Letters={SmallCaps,UppercaseSmallCaps}
119 }
120 #1}
121 }
122 \fi% enablewlfont
123
124 %{\Itshape JunicodeWL-Italic.ttf }
125 %{\bfseries Junicode-Bold.ttf }
126 %{\bfseries\itshape Junicode-BoldItalic.ttf }
127
128 \pagestyle{plain}
129 \usepackage{fancyhdr}
130
131 \makeatletter
132
133 % bottom figure below footnotes
134 \usepackage{fnpos}
135 \makeFNabove
136
137 \usepackage{color}
138 \definecolor{theme}{gray}{.3}
139
140 \setlength{\marginparsep}{2em}
141 \setlength{\marginparwidth}{8.5em}
142 \setlength{\oddsidemargin}{0pt}
143 \setlength{\voffset}{0pt}
144 \setlength{\topmargin}{0pt}
145 \setlength{\headheight}{0pt}
146 \setlength{\headsep}{0pt}
147 \setlength{\textheight}{24cm}
148
149 \pagestyle{fancy}
150 \fancyhf{}
151 \renewcommand{\headrulewidth}{0pt}
152 \renewcommand{\footrulewidth}{0pt}
153 \lfoot{{\footnotesize \@author{} \emph{\@title}}}
154 \cfoot{}
155 \rfoot{{\footnotesize \thepage}}
156
157 \clubpenalty=100000
158 \widowpenalty=100000
159
160
161 % see http://osdir.com/ml/tex.xetex/2005-10/msg00003.html
162 \newsavebox{\ximagebox}\newlength{\ximageheight}
163 \newsavebox{\xglyphbox}\newlength{\xglyphheight}
164 \newcommand{\xbox}[1]
165 {\savebox{\ximagebox}{#1}\settoheight{\ximageheight}{\usebox {\ximagebox}}%
166 \savebox{\xglyphbox}{\char32}\settoheight{\xglyphheight}{\usebox {\xglyphbox}}%
167 \raisebox{\ximageheight}[0pt][0pt]{%\raisebox{-\xglyphheight}[0pt] [0pt]{%
168 \makebox[0pt][l]{\usebox{\xglyphbox}}}%}%
169 \usebox{\ximagebox}%
170 \raisebox{0pt}[0pt][0pt]{\makebox[0pt][r]{\usebox{\xglyphbox}}}}
171
172
173
174 \newcommand{\typosubsubsection}[1]{%
175 {#1}
176 }
177
178 \newcommand{\typosubsection}[1]{%
179 {\addfontfeature{
180 SizeFeatures={
181   {Size={-10}, Scale=1.2, FakeStretch=1.00, LetterSpace=8.0 },
182   {Size={10.5-12}, Scale=1.2, FakeStretch=1.00, LetterSpace=8.0 },
183   {Size={12-}, FakeStretch=1.0, LetterSpace=8.0 }
184 },
185 Letters={Uppercase}
186 }
187 \MakeUppercase{#1}}
188 }
189
190 \newcommand{\typosection}[1]{%
191 {\addfontfeature{FakeStretch=0.96, LetterSpace=-4.0}\emph{\scalefont{2}#1}}
192 %{\addfontfeature{Scale=2.0, FakeStretch=0.98, LetterSpace=-2.0}\emph{#1}}
193 }
194
195
196 \newcommand{\tytul}[1]{%
197 #1%
198 \vspace{1em}%
199 }
200
201 \newcommand{\nazwapodutworu}[1]{%
202 \section*{\typosection{#1}}%
203 }
204
205 \newcommand{\autorutworu}[1]{%
206 \subsection*{\typosubsection{#1}}%
207 }
208
209 \newcommand{\dzielonadrzedne}[1]{%
210 \subsection*{\typosubsubsection{#1}}%
211 }
212
213 \newcommand{\nazwautworu}[1]{%
214 \section*{\raggedright{\typosection{#1}}}%
215 }
216
217 \newcommand{\podtytul}[1]{%
218 \subsection*{\typosubsubsection{#1}}%
219 }
220
221 \newcommand{\translator}[1]{%
222 % TODO: l10n is a style thing
223 \subsection*{\typosubsubsection{tłum. #1}}%
224 }
225
226
227 \newcommand{\powiesc}[1]{#1}
228 \newcommand{\opowiadanie}[1]{#1}
229 \newcommand{\lirykal}[1]{#1}
230 \newcommand{\lirykalp}[1]{#1}
231 \newcommand{\dramatwierszowanyl}[1]{#1}
232 \newcommand{\dramatwierszowanylp}[1]{#1}
233 \newcommand{\dramatwspolczesny}[1]{#1}
234
235 \newcommand{\nota}[1]{%
236 \par{#1}%
237 }
238
239 \newcommand{\dedykacja}[1]{%
240 \begin{em}%
241 \begin{flushright}%
242 #1%
243 \end{flushright}%
244 \end{em}%
245 }
246
247 \newcommand{\dlugicytat}[1]{%
248 \begin{quotation}%
249 #1%
250 \end{quotation}%
251 }
252
253 \newcommand{\poezjacyt}[1]{%
254 \begin{verse}%
255 #1%
256 \end{verse}%
257 }
258 \newcommand{\motto}[1]{%
259 \begin{em}%
260 #1%
261 \end{em}%
262 }
263 \newcommand{\listaosob}[2]{%
264 \par{#1}%
265 \begin{itemize}%
266 #2%
267 \end{itemize}%
268 }
269
270 \newcommand{\nagloweklisty}[1]{%
271 \typosubsubsection{#1}%
272 }
273
274 \newcommand{\listaosoba}[1]{%
275 \item{#1}%
276 }
277
278 \newcommand{\kwestia}[1]{%
279 \par{#1}%
280 }
281
282 \newcommand{\naglowekakt}[1]{%
283 \pagebreak
284 \subsection*{\typosubsection{#1}}%
285 }
286 \newcommand{\naglowekczesc}[1]{%
287 \pagebreak
288 \subsection*{\typosubsection{#1}}%
289 }
290 \newcommand{\srodtytul}[1]{%
291 \subsection*{\typosubsection{#1}}%
292 }
293
294 \newcommand{\naglowekscena}[1]{%
295 \subsubsection*{\typosubsubsection{#1}}%
296 }
297 \newcommand{\naglowekrozdzial}[1]{%
298 {\subsubsection*{\raggedright{\typosubsubsection{#1}}}}%
299 }
300
301 \newcommand{\naglowekosoba}[1]{%
302 \par{\textsc{#1}}\nopagebreak%
303 }
304 \newcommand{\naglowekpodrozdzial}[1]{%
305 \par{#1}\nopagebreak%
306 }
307
308 \newcommand{\miejsceczas}[1]{%
309 \par{\emph{#1}}%
310 }
311 \newcommand{\didaskalia}[1]{%
312 \par{\emph{#1}}%
313 }
314
315 \newcommand{\akap}[1]{%
316 \par{#1}%
317 }
318 \newcommand{\akapdialog}[1]{%
319 \par{#1}%
320 }
321 \newcommand{\akapcd}[1]{%
322 \par{#1}%
323 }
324
325 \newcommand{\mottopodpis}[1]{%
326 \begin{em}%
327 \begin{flushright}%
328 #1%
329 \end{flushright}%
330 \end{em}%
331 }
332
333 \newcommand{\strofa}[1]{%
334 \par{\noindent{\ignorespaces#1\vspace{1em}}}%
335 }
336
337 \newcommand{\wers}[1]{#1}
338
339 \newcommand{\wersakap}[1]{%
340 \hspace*{1em}#1%
341 }
342 \newcommand{\werscd}[1]{%
343 \hspace*{8em}#1%
344 }
345 \newcommand{\werswciety}[2][1em]{%
346 \hspace*{#1}#2%
347 }
348
349 \ifshowfootnotes
350   \newcommand{\pa}[1]{\NoCaseChange{\footnote{#1}}}
351   \newcommand{\pe}[1]{\NoCaseChange{\footnote{#1}}}
352   \newcommand{\pr}[1]{\NoCaseChange{\footnote{#1}}}
353   \newcommand{\pt}[1]{\NoCaseChange{\footnote{#1}}}
354 \else
355   \newcommand{\pa}[1]{}
356   \newcommand{\pe}[1]{}
357   \newcommand{\pr}[1]{}
358   \newcommand{\pt}[1]{}
359 \fi
360
361 \newcommand{\mat}[1]{$#1$}
362
363 \newcommand{\didasktekst}[1]{%
364 \emph{#1}%
365 }
366 \newcommand{\slowoobce}[1]{%
367 \emph{#1}%
368 }
369 \newcommand{\tytuldziela}[1]{%
370 \emph{#1}%
371 }
372 \newcommand{\wyroznienie}[1]{%
373 \emph{#1}%
374 }
375
376 \newcommand{\osoba}[1]{%
377 #1%
378 }
379
380 \newcommand{\sekcjaswiatlo}{%
381 \vspace{30pt}%
382 }
383
384 \newcommand{\sekcjaasterysk}{%
385 \vspace{10pt}%
386 \begin{center}%
387 \par{*}%
388 \end{center}%
389 }
390
391 \newcommand{\separatorlinia}{%
392 \vspace{10pt}%
393 \hrule{}%
394 \vspace{10pt}%
395 }
396
397 \newcommand{\motyw}[2][0]{%
398 \ifshowthemes
399 \mbox{}%
400 \marginpar{%
401 \vspace{-8pt}%
402 \vspace{-#1\baselineskip}%
403 \raggedright{\hspace{0pt}%
404 \footnotesize{\color{theme}{#2}}}%
405 \vspace{\baselineskip}%
406 }%
407 \fi
408 }