5603a0e38dbdc868ee75a5ff19363e0edb33a3e6
[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     \publisherinfo
263
264     \description
265     \vspace{.6em}
266
267     \editors
268
269     \ifdefined\funders
270         \vspace{.6em}
271         \funders
272     \fi
273
274     \ifdefined\coverby
275         \vspace{.6em}
276         \coverby
277     \fi
278
279     \ifdefined\isbn
280         \vspace{.6em}
281         \isbn
282     \fi
283
284     \vspace{.6em}
285     \emph{Wesprzyj Wolne Lektury!}
286
287     Wolne Lektury to projekt fundacji Nowoczesna Polska – organizacji
288     pożytku publicznego działającej na rzecz wolności korzystania
289     z dóbr kultury.
290
291     Co roku do domeny publicznej przechodzi twórczość kolejnych autorów.
292     Dzięki Twojemu wsparciu będziemy je mogli udostępnić wszystkim bezpłatnie.
293
294     \vspace{.6em}
295     \emph{Jak możesz pomóc?}
296
297     Przekaż 1\% podatku na rozwój Wolnych Lektur:
298     Fundacja Nowoczesna Polska, KRS 0000070056.
299
300     Pomóż uwolnić konkretną książkę, wspierając
301     \href{http://www.wolnelektury.pl/wesprzyj/}{zbiórkę na stronie wolnelektury.pl}.
302
303     Przekaż darowiznę na konto:
304     \href{http://nowoczesnapolska.org.pl/pomoz-nam/wesprzyj-nas/}{szczegóły na stronie Fundacji}.
305
306     \color{black}
307   }
308   \end{figure}
309 }
310
311
312 \newcommand{\typosubsubsection}[1]{%
313 {\textsc{#1}}
314 }
315
316 \newcommand{\typosubsection}[1]{%
317 {\addfontfeature{
318 SizeFeatures={
319   {Size={-10}, Scale=1.2, FakeStretch=1.00, LetterSpace=8.0 },
320   {Size={10.5-12}, Scale=1.2, FakeStretch=1.00, LetterSpace=8.0 },
321   {Size={12-}, FakeStretch=1.0, LetterSpace=8.0 }
322 },
323 Letters={Uppercase}
324 }
325 \MakeUppercase{#1}}
326 }
327
328 \newcommand{\typosection}[1]{%
329 {\addfontfeature{FakeStretch=0.96, LetterSpace=-4.0}\emph{\scalefont{2}#1}}
330 %{\addfontfeature{Scale=2.0, FakeStretch=0.98, LetterSpace=-2.0}\emph{#1}}
331 }
332
333
334 \newcommand{\tytul}[1]{%
335 #1%
336 \vspace{1em}%
337 }
338
339 \newcommand{\nazwapodutworu}[1]{%
340 \section*{\typosection{#1}}%
341 }
342
343 \newcommand{\autorutworu}[1]{%
344 \subsection*{\typosubsection{#1}}%
345 }
346
347 \newcommand{\dzielonadrzedne}[1]{%
348 \subsection*{\typosubsubsection{#1}}%
349 }
350
351 \newcommand{\nazwautworu}[1]{%
352 \section*{\typosection{#1}}%
353 }
354
355 \newcommand{\podtytul}[1]{%
356 \subsection*{\typosubsubsection{#1}}%
357 }
358
359 \newcommand{\translator}[1]{%
360 \subsection*{\typosubsubsection{tłum. #1}}%
361 }
362
363
364 \newcommand{\powiesc}[1]{#1}
365 \newcommand{\opowiadanie}[1]{#1}
366 \newcommand{\lirykal}[1]{#1}
367 \newcommand{\lirykalp}[1]{#1}
368 \newcommand{\dramatwierszowanyl}[1]{#1}
369 \newcommand{\dramatwierszowanylp}[1]{#1}
370 \newcommand{\dramatwspolczesny}[1]{#1}
371
372 \newcommand{\nota}[1]{%
373 \par{#1}%
374 }
375
376 \newcommand{\dedykacja}[1]{%
377 \begin{em}%
378 \begin{flushright}%
379 #1%
380 \end{flushright}%
381 \end{em}%
382 }
383
384 \newlength{\fboxhsep}
385 \newlength{\fboxvsep}
386
387 \newlength{\fboxtoprule}
388 \newlength{\fboxbottomrule}
389 \newlength{\fboxleftrule}
390 \newlength{\fboxrightrule}
391
392 \setlength{\fboxhsep}{5\fboxsep}
393 \setlength{\fboxvsep}{20\fboxsep}
394
395 \setlength{\fboxtoprule}{\fboxrule}
396 \setlength{\fboxleftrule}{\fboxrule}
397 \setlength{\fboxrightrule}{\fboxrule}
398 \setlength{\fboxbottomrule}{\fboxrule}
399
400
401
402 \def\@frameb@xother#1{%
403   \@tempdima\fboxtoprule
404   \advance\@tempdima\fboxvsep
405   \advance\@tempdima\dp\@tempboxa
406   \hbox{%
407     \lower\@tempdima\hbox{%
408       \vbox{%
409         \hrule\@height\fboxtoprule
410         \hbox{%
411           \vrule\@width\fboxleftrule
412           #1%
413           \vbox{%
414             \vskip\fboxvsep
415             \box\@tempboxa
416             \vskip\fboxvsep}%
417           #1%
418           \vrule\@width\fboxrightrule}%
419         \hrule\@height\fboxbottomrule}%
420     }%
421   }%
422 }
423
424
425 \long\def\fboxother#1{%
426   \leavevmode
427   \setbox\@tempboxa\hbox{%
428     \color@begingroup
429     \kern\fboxhsep{#1}\kern\fboxhsep
430     \color@endgroup}%
431   \@frameb@xother\relax}
432
433 \newcommand{\myfbox}[3]{%
434   \begingroup
435   \setlength{\fboxhsep}{#1}
436   \setlength{\fboxvsep}{#2}
437   \fboxother{#3}
438
439   \endgroup
440 }
441
442 \newcommand{\ramka}[1]{%
443 \noindent\myfbox{1em}{1em}{%
444 \parbox{\textwidth}{%
445 #1%
446 }}%
447 }
448
449 \newcommand{\dlugicytat}[1]{%
450 \begin{quotation}%
451 #1%
452 \end{quotation}%
453 }
454
455 \newcommand{\poezjacyt}[1]{%
456 \begin{verse}%
457 #1%
458 \end{verse}%
459 }
460 \newcommand{\motto}[1]{%
461 \begin{em}%
462 #1%
463 \end{em}%
464 }
465 \newcommand{\listaosob}[2]{%
466 \par{#1}%
467 \begin{itemize}%
468 #2%
469 \end{itemize}%
470 }
471
472 \newcommand{\nagloweklisty}[1]{%
473 \typosubsubsection{#1}%
474 }
475
476 \newcommand{\listaosoba}[1]{%
477 \item{#1}%
478 }
479
480 \newcommand{\kwestia}[1]{%
481 \par{#1}%
482 }
483
484 \newcommand{\naglowekakt}[1]{%
485 \pagebreak
486 \subsection*{\typosubsection{#1}}%
487 }
488 \newcommand{\naglowekczesc}[1]{%
489 \pagebreak
490 \subsection*{\typosubsection{#1}}%
491 }
492 \newcommand{\srodtytul}[1]{%
493 \subsection*{\typosubsection{#1}}%
494 }
495
496 \newcommand{\naglowekscena}[1]{%
497 \subsubsection*{\typosubsubsection{#1}}%
498 }
499 \newcommand{\naglowekrozdzial}[1]{%
500 \subsubsection*{\typosubsubsection{#1}}%
501 }
502
503 \newcommand{\naglowekosoba}[1]{%
504 \par{\textsc{#1}}\nopagebreak%
505 }
506 \newcommand{\naglowekpodrozdzial}[1]{%
507 \vspace{5ex}\par{#1}\nopagebreak%
508 }
509
510 \newcommand{\miejsceczas}[1]{%
511 \par{\emph{#1}}%
512 }
513 \newcommand{\didaskalia}[1]{%
514 \par{\emph{#1}}%
515 }
516
517 \usepackage{intcalc}
518 \usepackage{color}
519 \definecolor{gray}{RGB}{200,200,200}
520 %\newcounter{parnum}
521 \newlength{\parnumwidth}
522 \setlength{\parnumwidth}{3em}
523 \newcommand{\N}{%
524   \leavevmode\refstepcounter{parnum}\reversemarginpar%
525   \marginnote{\textcolor{gray}{\small{\theparnum}}}%
526   \reversemarginpar}
527 \newcommand{\Nw}{%
528   \leavevmode\refstepcounter{parnum}\reversemarginpar%
529   \ifnum\intcalcMod{\value{parnum}}{5}=0%
530   \marginnote{\textcolor{gray}{\small{\theparnum}}}%
531   \fi\reversemarginpar}
532 \renewcommand{\N}{}
533 \renewcommand{\Nw}{}
534
535 \newcommand{\akap}[1]{%
536 \par{\N#1}%
537 }
538 \newcommand{\akapdialog}[1]{%
539 \par{\N#1}%
540 }
541 \newcommand{\akapcd}[1]{%
542 \par{\N#1}%
543 }
544
545 \newcommand{\mottopodpis}[1]{%
546 \begin{em}%
547 \begin{flushright}%
548 #1%
549 \end{flushright}%
550 \end{em}%
551 }
552
553 \newcommand{\strofa}[1]{%
554 \par{\noindent{\ignorespaces#1\vspace{1em}}}%
555 }
556
557 \newcommand{\wers}[1]{\Nw#1}
558
559 \newcommand{\wersakap}[1]{%
560 \Nw\hspace*{1em}#1%
561 }
562 \newcommand{\werscd}[1]{%
563 \Nw\hspace*{8em}#1%
564 }
565 \newcommand{\werswciety}[2][1em]{%
566 \Nw\hspace*{#1}#2%
567 }
568 \newcommand{\wersdoprawej}[1]{%
569 \Nw\hspace*{\fill}#1%
570 }
571
572 \ifshowfootnotes
573   \newcommand{\pa}[1]{\NoCaseChange{\footnote{#1 [przypis autorski]}}}
574   \newcommand{\pe}[1]{\NoCaseChange{\footnote{#1 [przypis edytorski]}}}
575   \newcommand{\pr}[1]{\NoCaseChange{\footnote{#1 [przypis redakcyjny]}}}
576   \newcommand{\pt}[1]{\NoCaseChange{\footnote{#1 [przypis tłumacza]}}}
577 \else
578   \newcommand{\pa}[1]{}
579   \newcommand{\pe}[1]{}
580   \newcommand{\pr}[1]{}
581   \newcommand{\pt}[1]{}
582 \fi
583
584 \newcommand{\mat}[1]{$#1$}
585
586 \newcommand{\didasktekst}[1]{%
587 \emph{#1}%
588 }
589 \newcommand{\slowoobce}[1]{%
590 \emph{#1}%
591 }
592 \newcommand{\tytuldziela}[1]{%
593 \emph{#1}%
594 }
595 \newcommand{\wyroznienie}[1]{%
596 \emph{#1}%
597 }
598 \newcommand{\indeksdolny}[1]{%
599 \textsubscript{#1}%
600 }
601 \newcommand{\wiekszeodstepy}[1]{%
602 \spaceskip 3\fontdimen2\font plus 3\fontdimen3\font minus 3\fontdimen4\font \relax%
603 #1%
604 \spaceskip \fontdimen2\font plus \fontdimen3\font minus \fontdimen4\font \relax%
605 }
606
607 \newcommand{\osoba}[1]{%
608 #1%
609 }
610
611 \newcommand{\sekcjaswiatlo}{%
612 \vspace{30pt}%
613 }
614
615 \newcommand{\sekcjaasterysk}{%
616 \vspace{10pt}%
617 \begin{center}%
618 \par{*}%
619 \end{center}%
620 }
621
622 \newcommand{\separatorlinia}{%
623 \vspace{10pt}%
624 \hrule{}%
625 \vspace{10pt}%
626 }
627
628 \newcommand{\motyw}[2][0]{%
629 \ifshowthemes
630 \mbox{}%
631 \marginpar{%
632 \vspace{-8pt}%
633 \vspace{-#1\baselineskip}%
634 \raggedright{\hspace{0pt}%
635 \footnotesize{\color{theme}{#2}}}%
636 \vspace{\baselineskip}%
637 }%
638 \fi
639 }
640
641 \newcommand{\ilustr}[2]{%
642 \vspace{1em}%
643 \par{\noindent\includegraphics[width=\linewidth]{#1}}%
644 \vspace{1em}
645 }