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