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