latex dir for debugging
[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 \LoadClass[a4paper]{book}
66
67
68 \usepackage{trace}
69
70 \usepackage{longtable}
71 \usepackage{tabu}
72 \usepackage[MeX]{polski}
73
74 \usepackage[xetex]{graphicx}
75 \usepackage{fontspec}
76 \usepackage{xunicode}
77 \usepackage{xltxtra}
78
79 \usepackage[overload]{textcase}
80 \usepackage{scalefnt}
81 \usepackage[hyphens]{url}
82 %\usepackage[colorlinks=true,linkcolor=black,setpagesize=false,urlcolor=black,xetex,unicode]{hyperref}
83 \usepackage[colorlinks=true,linkcolor=black,setpagesize=false,urlcolor=blue,xetex,unicode]{hyperref}
84
85 \ifenablewlfont
86 \setmainfont [
87 %ExternalLocation,
88 UprightFont = JunicodeWL-Regular,
89 ItalicFont = JunicodeWL-Italic,
90 BoldFont = JunicodeWL-Regular,
91 BoldItalicFont = JunicodeWL-Italic,
92 SmallCapsFont = JunicodeWL-Regular,
93 SmallCapsFeatures = {Letters={SmallCaps,UppercaseSmallCaps}},
94 %Numbers=OldStyle,
95 Scale=1.04,
96 LetterSpace=-1.0
97 ] {JunicodeWL}
98
99 \newfontfamily\alien[
100 SmallCapsFeatures = {Letters={SmallCaps,UppercaseSmallCaps}},
101 Numbers=OldStyle,
102 Scale=0.85,
103 LetterSpace=-1.0
104 ] {DejaVu Serif}
105
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
135 \makeatletter
136
137 % bottom figure below footnotes
138 \usepackage{fnpos}
139 \makeFNabove
140
141 \usepackage{color}
142 \definecolor{theme}{gray}{.3}
143
144 \setlength{\marginparsep}{2em}
145 \setlength{\marginparwidth}{8.5em}
146 %\setlength{\oddsidemargin}{0pt}
147 \setlength{\oddsidemargin}{\evensidemargin}
148 \setlength{\evensidemargin}{18pt}
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 %\rfoot[{\footnotesize \thepage}]{{\footnotesize \textsc{\@author} \emph{\@title}}}
161 \lfoot[{\footnotesize \thepage}]{}
162 \cfoot{}
163 %\rfoot{{\footnotesize \thepage}}
164 %\lfoot[{\footnotesize \textsc{\@author} \emph{\@title}}]{{\footnotesize \thepage}}
165 \rfoot[]{{\footnotesize \thepage}}
166
167
168 \clubpenalty=100000
169 \widowpenalty=100000
170
171
172 % see http://osdir.com/ml/tex.xetex/2005-10/msg00003.html
173 \newsavebox{\ximagebox}\newlength{\ximageheight}
174 \newsavebox{\xglyphbox}\newlength{\xglyphheight}
175 \newcommand{\xbox}[1]
176 {\savebox{\ximagebox}{#1}\settoheight{\ximageheight}{\usebox {\ximagebox}}%
177 \savebox{\xglyphbox}{\char32}\settoheight{\xglyphheight}{\usebox {\xglyphbox}}%
178 \raisebox{\ximageheight}[0pt][0pt]{%\raisebox{-\xglyphheight}[0pt] [0pt]{%
179 \makebox[0pt][l]{\usebox{\xglyphbox}}}%}%
180 \usebox{\ximagebox}%
181 \raisebox{0pt}[0pt][0pt]{\makebox[0pt][r]{\usebox{\xglyphbox}}}}
182
183 \newcommand{\makecover}[2]{
184         \pdfpagewidth=#1
185         \pdfpageheight=#2
186
187         \thispagestyle{empty}
188         \newlength{\PictHOffset}
189         \newlength{\PictVOffset}
190         \setlength{\PictHOffset}{1in}
191         \addtolength{\PictHOffset}{\hoffset}
192         \addtolength{\PictHOffset}{\oddsidemargin}
193
194         \setlength{\PictVOffset}{1in}
195         \addtolength{\PictVOffset}{\voffset}
196         \addtolength{\PictVOffset}{\topmargin}
197         \addtolength{\PictVOffset}{\headheight}
198         \addtolength{\PictVOffset}{\headsep}
199         \addtolength{\PictVOffset}{\topskip}
200         \addtolength{\PictVOffset}{-\pdfpageheight}
201
202         \noindent\hspace*{-\PictHOffset}%
203         \raisebox{\PictVOffset}[0pt][0pt]{\makebox[0pt][l]{%
204             \includegraphics[height=\pdfpageheight,width=\pdfpagewidth]{cover.png}}}
205         \clearpage
206
207         \setlength{\pdfpagewidth}{210mm}
208         \setlength{\pdfpageheight}{297mm}
209 }
210
211
212 \renewcommand{\maketitle}{
213     {
214     % \thispagestyle{empty}
215     \setcounter{page}{1}
216
217     \footnotesize
218     \color{theme}
219
220     \noindent \begin{minipage}[t]{.65\textwidth}\vspace{0pt}
221         \href{http://prawokultury.pl}{\xbox{\includegraphics[width=1in]{prawokultury-logo.png}}}
222         %\href{http://koed.org.pl}{\xbox{\includegraphics[height=.55in]{koed-logo.eps}}}
223     \end{minipage}
224     \noindent \begin{minipage}[t]{.35\textwidth}\vspace{0pt}
225         \raggedright
226         %\xbox{\includegraphics[width=1.6in]{trust-logo.eps}}
227         \href{http://nowoczesnapolska.org.pl}{\xbox{\includegraphics[height=.55in]{fnp-logo.eps}}}
228         \vspace{.5em}
229     \end{minipage}
230
231 %    \begin{minipage}[t]{.45\textwidth}\vspace{0pt}
232
233     \ifflaglessadvertising
234     \else
235         %\noindent Ten rozdział pochodzi z książki \emph{\@title}, która zostanie opublikowana w portalu
236         %\href{http://prawokultury.pl/}{prawokultury.pl}.
237         \vspace{.5em}
238     \fi
239
240  %   Utwór opracowany został w ramach projektu \href{http://www.wolnelektury.pl/}{Wolne Lektury}
241   %  przez \href{http://nowoczesnapolska.org.pl}{fundację Nowoczesna Polska}.
242
243  %   \end{minipage}
244     \noindent \rule{\linewidth}{0.4pt}
245
246     \vspace{.6em}
247     \color{black}
248     }
249 }
250
251 \newcommand{\editorialsection}{
252   \begin{figure}[b!]
253   {
254     \footnotesize
255     \color{theme}
256     \noindent \rule{\linewidth}{0.4pt}
257
258     \rightsinfo
259     \vspace{.6em}
260
261     %Źródło: \href{\bookurl}{\bookurl}
262
263     %\vspace{.6em}
264     \sourceinfo
265
266     \description
267     \vspace{.6em}
268
269     \editors
270
271     \vspace{.6em}
272     \coverby
273
274     \color{black}
275   }
276   \end{figure}
277 }
278
279
280 \newcommand{\typosubsubsection}[1]{%
281 {\textsc{#1}}
282 }
283
284 \newcommand{\typosubsection}[1]{%
285 {\addfontfeature{
286 SizeFeatures={
287   {Size={-10}, Scale=1.2, FakeStretch=1.00, LetterSpace=8.0 },
288   {Size={10.5-12}, Scale=1.2, FakeStretch=1.00, LetterSpace=8.0 },
289   {Size={12-}, FakeStretch=1.0, LetterSpace=8.0 }
290 },
291 Letters={Uppercase}
292 }
293 \MakeUppercase{#1}}
294 }
295
296 \newcommand{\typosection}[1]{%
297 %{\addfontfeature{FakeStretch=0.96, LetterSpace=-4.0}\emph{\scalefont{2}#1}}
298 {\addfontfeature{FakeStretch=0.96, LetterSpace=-4.0}\emph{\scalefont{1.7}#1}}
299 %{\addfontfeature{Scale=2.0, FakeStretch=0.98, LetterSpace=-2.0}\emph{#1}}
300 }
301
302
303 \newcommand{\tytul}[1]{%
304 #1%
305 \vspace{1em}%
306 }
307
308 \newcommand{\nazwapodutworu}[1]{%
309 \section*{\typosection{#1}}%
310 }
311
312 \newcommand{\autorutworu}[1]{%
313 \subsection*{\typosubsection{#1}}%
314 }
315
316 \newcommand{\dzielonadrzedne}[1]{%
317 \subsection*{\typosubsubsection{#1}}%
318 }
319
320 \newcommand{\nazwautworu}[1]{%
321 \section*{\raggedright{\typosection{#1}}}%
322 }
323
324 \newcommand{\podtytul}[1]{%
325 \subsection*{\typosubsubsection{#1}}%
326 }
327
328 \newcommand{\translator}[1]{%
329 \subsection*{\typosubsubsection{tłum. #1}}%
330 }
331
332
333 \newcommand{\powiesc}[1]{#1}
334 \newcommand{\opowiadanie}[1]{#1}
335 \newcommand{\lirykal}[1]{#1}
336 \newcommand{\lirykalp}[1]{#1}
337 \newcommand{\dramatwierszowanyl}[1]{#1}
338 \newcommand{\dramatwierszowanylp}[1]{#1}
339 \newcommand{\dramatwspolczesny}[1]{#1}
340
341 \newcommand{\nota}[1]{%
342 \par{#1}%
343 }
344
345 \newcommand{\dedykacja}[1]{%
346 \begin{em}%
347 \begin{flushright}%
348 #1%
349 \end{flushright}%
350 \end{em}%
351 }
352
353 \newlength{\fboxhsep}
354 \newlength{\fboxvsep}
355
356 \newlength{\fboxtoprule}
357 \newlength{\fboxbottomrule}
358 \newlength{\fboxleftrule}
359 \newlength{\fboxrightrule}
360
361 \setlength{\fboxhsep}{5\fboxsep}
362 \setlength{\fboxvsep}{20\fboxsep}
363
364 \setlength{\fboxtoprule}{\fboxrule}
365 \setlength{\fboxleftrule}{\fboxrule}
366 \setlength{\fboxrightrule}{\fboxrule}
367 \setlength{\fboxbottomrule}{\fboxrule}
368
369
370
371 \def\@frameb@xother#1{%
372   \@tempdima\fboxtoprule
373   \advance\@tempdima\fboxvsep
374   \advance\@tempdima\dp\@tempboxa
375   \hbox{%
376     \lower\@tempdima\hbox{%
377       \vbox{%
378         \hrule\@height\fboxtoprule
379         \hbox{%
380           \vrule\@width\fboxleftrule
381           #1%
382           \vbox{%
383             \vskip\fboxvsep
384             \box\@tempboxa
385             \vskip\fboxvsep}%
386           #1%
387           \vrule\@width\fboxrightrule}%
388         \hrule\@height\fboxbottomrule}%
389     }%
390   }%
391 }
392
393
394 \long\def\fboxother#1{%
395   \leavevmode
396   \setbox\@tempboxa\hbox{%
397     \color@begingroup
398     \kern\fboxhsep{#1}\kern\fboxhsep
399     \color@endgroup}%
400   \@frameb@xother\relax}
401
402 \newcommand{\myfbox}[3]{%
403   \begingroup
404   \setlength{\fboxhsep}{#1}
405   \setlength{\fboxvsep}{#2}
406   \fboxother{#3}
407
408   \endgroup
409 }
410
411 \newcommand{\ramka}[1]{%
412 \par\vspace{1em}%
413 \edef\myindent{\the\parindent}%
414 \noindent\myfbox{1em}{1em}{%
415 \parbox{\dimexpr \textwidth - 2\fboxhsep - 2\fboxrule\relax}{%
416 \setlength{\parindent}{\myindent}%
417 #1%
418 }}%
419 \vspace{1em}%
420 }
421
422 \newcommand{\dlugicytat}[1]{%
423 \begin{quotation}%
424 %\raggedright%
425 #1%
426 \end{quotation}%
427 }
428
429 \newcommand{\poezjacyt}[1]{%
430 \begin{verse}%
431 #1%
432 \end{verse}%
433 }
434 \newcommand{\motto}[1]{%
435 \begin{em}%
436 #1%
437 \end{em}%
438 }
439 \newcommand{\listaosob}[2]{%
440 \par{#1}%
441 \begin{itemize}%
442 #2%
443 \end{itemize}
444
445 }
446
447 \newcommand{\nagloweklisty}[1]{%
448 \typosubsubsection{#1}%
449 }
450
451 \newcommand{\listaosoba}[1]{%
452 \item{#1}%
453 }
454
455 \newcommand{\kwestia}[1]{%
456 \par{#1}%
457 }
458
459 \newcommand{\naglowekakt}[1]{%
460 \newpage
461 \subsection*{\typosubsection{#1}}%
462 }
463 \newcommand{\naglowekczesc}[1]{%
464 \newpage
465 \subsection*{\typosubsection{#1}}%
466 }
467 \newcommand{\srodtytul}[1]{%
468 \par{\typosubsubsection{#1}}%
469 %\subsection*{\typosubsection{#1}}%
470 }
471
472 \newcommand{\naglowekscena}[1]{%
473 \subsubsection*{\typosubsubsection{#1}}%
474 }
475 \newcommand{\naglowekrozdzial}[1]{%
476 \subsection*{\raggedright \typosubsection{#1}}%
477 %\subsubsection*{\typosubsubsection{#1}}%
478 }
479
480 \newcommand{\naglowekosoba}[1]{%
481 \par{\textsc{#1}}\nopagebreak%
482 }
483 \newcommand{\naglowekpodrozdzial}[1]{%
484 \subsubsection*{\typosubsubsection{#1}}%
485 %\par{#1}\nopagebreak%
486 }
487
488 \newcommand{\miejsceczas}[1]{%
489 \par{\emph{#1}}%
490 }
491 \newcommand{\didaskalia}[1]{%
492 \par{\emph{#1}}%
493 }
494
495 \newcommand{\akap}[1]{%
496 \par{#1}%
497 }
498 \newcommand{\akapdialog}[1]{%
499 \par{#1}%
500 }
501 \newcommand{\akapcd}[1]{%
502 \par{#1}%
503 }
504
505 \newcommand{\mottopodpis}[1]{%
506 \begin{em}%
507 \begin{flushright}%
508 #1%
509 \end{flushright}%
510 \end{em}%
511 }
512
513 \newcommand{\strofa}[1]{%
514 \par{\noindent{\ignorespaces#1\vspace{1em}}}%
515 }
516
517 \newcommand{\wers}[1]{#1}
518
519 \newcommand{\wersakap}[1]{%
520 \hspace*{1em}#1%
521 }
522 \newcommand{\werscd}[1]{%
523 \hspace*{8em}#1%
524 }
525 \newcommand{\werswciety}[2][1em]{%
526 \hspace*{#1}#2%
527 }
528
529 \ifshowfootnotes
530   %\newcommand{\pa}[1]{\NoCaseChange{\footnote{#1 [przypis autorski]}}}
531   \newcommand{\pa}[1]{\NoCaseChange{\footnote{#1}}}
532   \newcommand{\pe}[1]{\NoCaseChange{\footnote{#1}}}
533   \newcommand{\pr}[1]{\NoCaseChange{\footnote{#1}}}
534   \newcommand{\pt}[1]{\NoCaseChange{\footnote{#1}}}
535 \else
536   \newcommand{\pa}[1]{}
537   \newcommand{\pe}[1]{}
538   \newcommand{\pr}[1]{}
539   \newcommand{\pt}[1]{}
540 \fi
541
542 \newcommand{\mat}[1]{$#1$}
543
544 \newcommand{\didasktekst}[1]{%
545 \emph{#1}%
546 }
547 \newcommand{\slowoobce}[1]{%
548 \emph{#1}%
549 }
550 \newcommand{\tytuldziela}[1]{%
551 \emph{#1}%
552 }
553 \newcommand{\wyroznienie}[1]{%
554 \emph{#1}%
555 }
556
557 \newcommand{\osoba}[1]{%
558 #1%
559 }
560
561 \newcommand{\sekcjaswiatlo}{%
562 \vspace{30pt}%
563 }
564
565 \newcommand{\sekcjaasterysk}{%
566 \vspace{10pt}%
567 \begin{center}%
568 \par{*}%
569 \end{center}%
570 }
571
572 \newcommand{\separatorlinia}{%
573 \vspace{10pt}%
574 \hrule{}%
575 \vspace{10pt}%
576 }
577
578 \newcommand{\motyw}[2][0]{%
579 \ifshowthemes
580 \mbox{}%
581 \marginpar{%
582 \vspace{-8pt}%
583 \vspace{-#1\baselineskip}%
584 \raggedright{\hspace{0pt}%
585 \footnotesize{\color{theme}{#2}}}%
586 \vspace{\baselineskip}%
587 }%
588 \fi
589 }
590
591
592 \newcommand{\www}[1]{%
593 %\href{#1}{#1}%
594 \url{#1}%
595 }
596 \newcommand{\listanum}[1]{%
597 \begin{enumerate}%
598 #1%
599 \end{enumerate}%
600 }
601 \newcommand{\listapunkt}[1]{%
602 \begin{itemize}%
603 #1%
604 \end{itemize}%
605 }
606 \newcommand{\punkt}[1]{%
607 \item #1%
608 }
609 \newcommand{\ilustr}[2]{%
610 \vspace{1em}%
611 \par{\noindent\includegraphics[width=\linewidth]{#1}}%
612 \vspace{1em}
613 }