tests for handling "2 poł XIX w." dates + utf8 check
[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[MeX]{polski}
70
71 \usepackage[xetex]{graphicx}
72 \usepackage{fontspec}
73 \usepackage{xunicode}
74 \usepackage{xltxtra}
75
76 \usepackage[overload]{textcase}
77 \usepackage{scalefnt}
78 \usepackage[colorlinks=true,linkcolor=black,setpagesize=false,urlcolor=black,xetex]{hyperref}
79
80 \ifenablewlfont
81 \setmainfont [
82 %ExternalLocation,
83 UprightFont = JunicodeWL-Regular,
84 ItalicFont = JunicodeWL-Italic,
85 BoldFont = JunicodeWL-Regular,
86 BoldItalicFont = JunicodeWL-Italic,
87 SmallCapsFont = JunicodeWL-Regular,
88 SmallCapsFeatures = {Letters={SmallCaps,UppercaseSmallCaps}},
89 Numbers=OldStyle,
90 Scale=1.04,
91 LetterSpace=-1.0
92 ] {JunicodeWL}
93
94 \newfontfamily\alien[
95 SmallCapsFeatures = {Letters={SmallCaps,UppercaseSmallCaps}},
96 Numbers=OldStyle,
97 Scale=0.85,
98 LetterSpace=-1.0
99 ] {DejaVu Serif}
100
101
102 \defaultfontfeatures{
103 SizeFeatures={
104   {Size={-10.5}, FakeStretch=1.02, LetterSpace=2.0 },
105   {Size={10.5-12}, FakeStretch=2.00, LetterSpace=0.0 },
106   {Size={12-}, FakeStretch=0.98, LetterSpace=-2.0 }
107 }
108 }
109
110 \renewcommand{\textsc}[1]{%
111 {\addfontfeature{
112 SizeFeatures={
113   {Size={-10.5}, Scale=1.2, FakeStretch=1.02, LetterSpace=8.0 },
114   {Size={10.5-12}, Scale=1.2, FakeStretch=1.02, LetterSpace=8.0 },
115   {Size={12-}, FakeStretch=1.0, LetterSpace=8.0 }
116 },
117 Letters={SmallCaps,UppercaseSmallCaps}
118 }
119 #1}
120 }
121 \fi% enablewlfont
122
123 %{\Itshape JunicodeWL-Italic.ttf }
124 %{\bfseries Junicode-Bold.ttf }
125 %{\bfseries\itshape Junicode-BoldItalic.ttf }
126
127 \pagestyle{plain}
128 \usepackage{fancyhdr}
129
130 \makeatletter
131
132 % bottom figure below footnotes
133 \usepackage{fnpos}
134 \makeFNabove
135
136 \usepackage{color}
137 \definecolor{theme}{gray}{.3}
138
139 \setlength{\marginparsep}{2em}
140 \setlength{\marginparwidth}{8.5em}
141 \setlength{\oddsidemargin}{0pt}
142 \setlength{\voffset}{0pt}
143 \setlength{\topmargin}{0pt}
144 \setlength{\headheight}{0pt}
145 \setlength{\headsep}{0pt}
146 \setlength{\textheight}{24cm}
147
148 \pagestyle{fancy}
149 \fancyhf{}
150 \renewcommand{\headrulewidth}{0pt}
151 \renewcommand{\footrulewidth}{0pt}
152 \lfoot{{\footnotesize \textsc{\@author} \emph{\@title}}}
153 \cfoot{}
154 \rfoot{{\footnotesize \thepage}}
155
156 \clubpenalty=100000
157 \widowpenalty=100000
158
159
160 % see http://osdir.com/ml/tex.xetex/2005-10/msg00003.html
161 \newsavebox{\ximagebox}\newlength{\ximageheight}
162 \newsavebox{\xglyphbox}\newlength{\xglyphheight}
163 \newcommand{\xbox}[1]
164 {\savebox{\ximagebox}{#1}\settoheight{\ximageheight}{\usebox {\ximagebox}}%
165 \savebox{\xglyphbox}{\char32}\settoheight{\xglyphheight}{\usebox {\xglyphbox}}%
166 \raisebox{\ximageheight}[0pt][0pt]{%\raisebox{-\xglyphheight}[0pt] [0pt]{%
167 \makebox[0pt][l]{\usebox{\xglyphbox}}}%}%
168 \usebox{\ximagebox}%
169 \raisebox{0pt}[0pt][0pt]{\makebox[0pt][r]{\usebox{\xglyphbox}}}}
170
171 \newcommand{\makecover}[2]{
172         \pdfpagewidth=#1
173         \pdfpageheight=#2
174
175         \thispagestyle{empty}
176         \newlength{\PictHOffset}
177         \newlength{\PictVOffset}
178         \setlength{\PictHOffset}{1in}
179         \addtolength{\PictHOffset}{\hoffset}
180         \addtolength{\PictHOffset}{\oddsidemargin}
181
182         \setlength{\PictVOffset}{1in}
183         \addtolength{\PictVOffset}{\voffset}
184         \addtolength{\PictVOffset}{\topmargin}
185         \addtolength{\PictVOffset}{\headheight}
186         \addtolength{\PictVOffset}{\headsep}
187         \addtolength{\PictVOffset}{\topskip}
188         \addtolength{\PictVOffset}{-\pdfpageheight}
189
190         \noindent\hspace*{-\PictHOffset}%
191         \raisebox{\PictVOffset}[0pt][0pt]{\makebox[0pt][l]{%
192             \includegraphics[height=\pdfpageheight,width=\pdfpagewidth]{cover.png}}}
193         \clearpage
194
195         \setlength{\pdfpagewidth}{210mm}
196         \setlength{\pdfpageheight}{297mm}
197 }
198
199
200 \renewcommand{\maketitle}{
201     {
202     \thispagestyle{empty}
203     \footnotesize
204     \color{theme}
205
206     \noindent \begin{minipage}[t]{.35\textwidth}\vspace{0pt}
207         \href{http://www.wolnelektury.pl}{\xbox{\includegraphics[width=\textwidth]{wl-logo.png}}}
208     \end{minipage}
209     \begin{minipage}[t]{.65\textwidth}\vspace{0pt}
210
211     \ifflaglessadvertising
212     \else
213         \href{\bookurl}{Ta lektura}, podobnie jak tysiące innych, jest dostępna on-line na stronie
214         \href{http://www.wolnelektury.pl/}{wolnelektury.pl}.
215         \vspace{.5em}
216     \fi
217
218     \ifdefined\thanknote
219         \thanknote
220         \vspace{.5em}
221     \fi
222
223     Utwór opracowany został w ramach projektu \href{http://www.wolnelektury.pl/}{Wolne Lektury}
224     przez \href{http://nowoczesnapolska.org.pl}{fundację Nowoczesna Polska}.
225
226     \end{minipage}
227     \noindent \rule{\linewidth}{0.4pt}
228
229     \vspace{.6em}
230     \color{black}
231     }
232 }
233
234 \newcommand{\editorialsection}{
235   \begin{figure}[b!]
236   {
237     \footnotesize
238     \color{theme}
239     \noindent \rule{\linewidth}{0.4pt}
240
241     \rightsinfo
242     \vspace{.6em}
243
244     Źródło: \href{\bookurl}{\bookurl}
245
246     \vspace{.6em}
247     \sourceinfo
248
249     \description
250     \vspace{.6em}
251
252     \editors
253
254     \ifdefined\funders
255         \vspace{.6em}
256         \funders
257     \fi
258
259     \ifdefined\coverby
260         \vspace{.6em}
261         \coverby
262     \fi
263
264     \vspace{.6em}
265     \emph{Wesprzyj Wolne Lektury!}
266
267     Wolne Lektury to projekt fundacji Nowoczesna Polska – organizacji
268     pożytku publicznego działającej na rzecz wolności korzystania
269     z dóbr kultury.
270
271     Co roku do domeny publicznej przechodzi twórczość kolejnych autorów.
272     Dzięki Twojemu wsparciu będziemy je mogli udostępnić wszystkim bezpłatnie.
273
274     \vspace{.6em}
275     \emph{Jak możesz pomóc?}
276
277     Przekaż 1\% podatku na rozwój Wolnych Lektur:
278     Fundacja Nowoczesna Polska, KRS 0000070056.
279
280     Pomóż uwolnić konkretną książkę, wspierając
281     \href{http://www.wolnelektury.pl/wesprzyj/}{zbiórkę na stronie wolnelektury.pl}.
282
283     Przekaż darowiznę na konto:
284     \href{http://nowoczesnapolska.org.pl/pomoz-nam/wesprzyj-nas/}{szczegóły na stronie Fundacji}.
285
286     \color{black}
287   }
288   \end{figure}
289 }
290
291
292 \newcommand{\typosubsubsection}[1]{%
293 {\textsc{#1}}
294 }
295
296 \newcommand{\typosubsection}[1]{%
297 {\addfontfeature{
298 SizeFeatures={
299   {Size={-10}, Scale=1.2, FakeStretch=1.00, LetterSpace=8.0 },
300   {Size={10.5-12}, Scale=1.2, FakeStretch=1.00, LetterSpace=8.0 },
301   {Size={12-}, FakeStretch=1.0, LetterSpace=8.0 }
302 },
303 Letters={Uppercase}
304 }
305 \MakeUppercase{#1}}
306 }
307
308 \newcommand{\typosection}[1]{%
309 {\addfontfeature{FakeStretch=0.96, LetterSpace=-4.0}\emph{\scalefont{2}#1}}
310 %{\addfontfeature{Scale=2.0, FakeStretch=0.98, LetterSpace=-2.0}\emph{#1}}
311 }
312
313
314 \newcommand{\tytul}[1]{%
315 #1%
316 \vspace{1em}%
317 }
318
319 \newcommand{\nazwapodutworu}[1]{%
320 \section*{\typosection{#1}}%
321 }
322
323 \newcommand{\autorutworu}[1]{%
324 \subsection*{\typosubsection{#1}}%
325 }
326
327 \newcommand{\dzielonadrzedne}[1]{%
328 \subsection*{\typosubsubsection{#1}}%
329 }
330
331 \newcommand{\nazwautworu}[1]{%
332 \section*{\typosection{#1}}%
333 }
334
335 \newcommand{\podtytul}[1]{%
336 \subsection*{\typosubsubsection{#1}}%
337 }
338
339 \newcommand{\translator}[1]{%
340 \subsection*{\typosubsubsection{tłum. #1}}%
341 }
342
343
344 \newcommand{\powiesc}[1]{#1}
345 \newcommand{\opowiadanie}[1]{#1}
346 \newcommand{\lirykal}[1]{#1}
347 \newcommand{\lirykalp}[1]{#1}
348 \newcommand{\dramatwierszowanyl}[1]{#1}
349 \newcommand{\dramatwierszowanylp}[1]{#1}
350 \newcommand{\dramatwspolczesny}[1]{#1}
351
352 \newcommand{\nota}[1]{%
353 \par{#1}%
354 }
355
356 \newcommand{\dedykacja}[1]{%
357 \begin{em}%
358 \begin{flushright}%
359 #1%
360 \end{flushright}%
361 \end{em}%
362 }
363
364 \newcommand{\dlugicytat}[1]{%
365 \begin{quotation}%
366 #1%
367 \end{quotation}%
368 }
369
370 \newcommand{\poezjacyt}[1]{%
371 \begin{verse}%
372 #1%
373 \end{verse}%
374 }
375 \newcommand{\motto}[1]{%
376 \begin{em}%
377 #1%
378 \end{em}%
379 }
380 \newcommand{\listaosob}[2]{%
381 \par{#1}%
382 \begin{itemize}%
383 #2%
384 \end{itemize}%
385 }
386
387 \newcommand{\nagloweklisty}[1]{%
388 \typosubsubsection{#1}%
389 }
390
391 \newcommand{\listaosoba}[1]{%
392 \item{#1}%
393 }
394
395 \newcommand{\kwestia}[1]{%
396 \par{#1}%
397 }
398
399 \newcommand{\naglowekakt}[1]{%
400 \pagebreak
401 \subsection*{\typosubsection{#1}}%
402 }
403 \newcommand{\naglowekczesc}[1]{%
404 \pagebreak
405 \subsection*{\typosubsection{#1}}%
406 }
407 \newcommand{\srodtytul}[1]{%
408 \subsection*{\typosubsection{#1}}%
409 }
410
411 \newcommand{\naglowekscena}[1]{%
412 \subsubsection*{\typosubsubsection{#1}}%
413 }
414 \newcommand{\naglowekrozdzial}[1]{%
415 \subsubsection*{\typosubsubsection{#1}}%
416 }
417
418 \newcommand{\naglowekosoba}[1]{%
419 \par{\textsc{#1}}\nopagebreak%
420 }
421 \newcommand{\naglowekpodrozdzial}[1]{%
422 \par{#1}\nopagebreak%
423 }
424
425 \newcommand{\miejsceczas}[1]{%
426 \par{\emph{#1}}%
427 }
428 \newcommand{\didaskalia}[1]{%
429 \par{\emph{#1}}%
430 }
431
432 \newcommand{\akap}[1]{%
433 \par{#1}%
434 }
435 \newcommand{\akapdialog}[1]{%
436 \par{#1}%
437 }
438 \newcommand{\akapcd}[1]{%
439 \par{#1}%
440 }
441
442 \newcommand{\mottopodpis}[1]{%
443 \begin{em}%
444 \begin{flushright}%
445 #1%
446 \end{flushright}%
447 \end{em}%
448 }
449
450 \newcommand{\strofa}[1]{%
451 \par{\noindent{\ignorespaces#1\vspace{1em}}}%
452 }
453
454 \newcommand{\wers}[1]{#1}
455
456 \newcommand{\wersakap}[1]{%
457 \hspace*{1em}#1%
458 }
459 \newcommand{\werscd}[1]{%
460 \hspace*{8em}#1%
461 }
462 \newcommand{\werswciety}[2][1em]{%
463 \hspace*{#1}#2%
464 }
465
466 \ifshowfootnotes
467   \newcommand{\pa}[1]{\NoCaseChange{\footnote{#1 [przypis autorski]}}}
468   \newcommand{\pe}[1]{\NoCaseChange{\footnote{#1}}}
469   \newcommand{\pr}[1]{\NoCaseChange{\footnote{#1}}}
470   \newcommand{\pt}[1]{\NoCaseChange{\footnote{#1}}}
471 \else
472   \newcommand{\pa}[1]{}
473   \newcommand{\pe}[1]{}
474   \newcommand{\pr}[1]{}
475   \newcommand{\pt}[1]{}
476 \fi
477
478 \newcommand{\mat}[1]{$#1$}
479
480 \newcommand{\didasktekst}[1]{%
481 \emph{#1}%
482 }
483 \newcommand{\slowoobce}[1]{%
484 \emph{#1}%
485 }
486 \newcommand{\tytuldziela}[1]{%
487 \emph{#1}%
488 }
489 \newcommand{\wyroznienie}[1]{%
490 \emph{#1}%
491 }
492
493 \newcommand{\osoba}[1]{%
494 #1%
495 }
496
497 \newcommand{\sekcjaswiatlo}{%
498 \vspace{30pt}%
499 }
500
501 \newcommand{\sekcjaasterysk}{%
502 \vspace{10pt}%
503 \begin{center}%
504 \par{*}%
505 \end{center}%
506 }
507
508 \newcommand{\separatorlinia}{%
509 \vspace{10pt}%
510 \hrule{}%
511 \vspace{10pt}%
512 }
513
514 \newcommand{\motyw}[2][0]{%
515 \ifshowthemes
516 \mbox{}%
517 \marginpar{%
518 \vspace{-8pt}%
519 \vspace{-#1\baselineskip}%
520 \raggedright{\hspace{0pt}%
521 \footnotesize{\color{theme}{#2}}}%
522 \vspace{\baselineskip}%
523 }%
524 \fi
525 }
526