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