65ec4fc0694fcec201c2a6f4aa7a400d4f3fb254
[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{tabularx}
71 \usepackage[MeX]{polski}
72
73 \usepackage[xetex]{graphicx}
74 \usepackage{fontspec}
75 \usepackage{xunicode}
76 \usepackage{xltxtra}
77
78 \usepackage[overload]{textcase}
79 \usepackage{scalefnt}
80 \usepackage[hyphens]{url}
81 %\usepackage[colorlinks=true,linkcolor=black,setpagesize=false,urlcolor=black,xetex,unicode]{hyperref}
82 \usepackage[colorlinks=true,linkcolor=black,setpagesize=false,urlcolor=blue,xetex,unicode]{hyperref}
83
84 \ifenablewlfont
85 \setmainfont [
86 %ExternalLocation,
87 UprightFont = JunicodeWL-Regular,
88 ItalicFont = JunicodeWL-Italic,
89 BoldFont = JunicodeWL-Regular,
90 BoldItalicFont = JunicodeWL-Italic,
91 SmallCapsFont = JunicodeWL-Regular,
92 SmallCapsFeatures = {Letters={SmallCaps,UppercaseSmallCaps}},
93 Numbers=OldStyle,
94 Scale=1.04,
95 LetterSpace=-1.0
96 ] {JunicodeWL}
97
98 \newfontfamily\alien[
99 SmallCapsFeatures = {Letters={SmallCaps,UppercaseSmallCaps}},
100 Numbers=OldStyle,
101 Scale=0.85,
102 LetterSpace=-1.0
103 ] {DejaVu Serif}
104
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
134 \makeatletter
135
136 % bottom figure below footnotes
137 \usepackage{fnpos}
138 \makeFNabove
139
140 \usepackage{color}
141 \definecolor{theme}{gray}{.3}
142
143 \setlength{\marginparsep}{2em}
144 \setlength{\marginparwidth}{8.5em}
145 \setlength{\oddsidemargin}{0pt}
146 \setlength{\voffset}{0pt}
147 \setlength{\topmargin}{0pt}
148 \setlength{\headheight}{0pt}
149 \setlength{\headsep}{0pt}
150 \setlength{\textheight}{24cm}
151
152 \pagestyle{fancy}
153 \fancyhf{}
154 \renewcommand{\headrulewidth}{0pt}
155 \renewcommand{\footrulewidth}{0pt}
156 % CAUTION! Manually entered text.
157 %\lfoot{{\footnotesize \textsc{\@author} \emph{\@title}}}
158 \rfoot[{\footnotesize \thepage}]{{\footnotesize \textsc{\@author} \emph{Dlaczego nie warto blokować użycia komercyjnego\ldots}}}
159 \cfoot{}
160 %\rfoot{{\footnotesize \thepage}}
161 \lfoot[{\footnotesize \textsc{\@author} \emph{Dlaczego nie warto blokować użycia komercyjnego\ldots}}]{{\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]{.65\textwidth}\vspace{0pt}
214         %\href{http://prawokultury.pl}{\xbox{\includegraphics[width=1in]{prawokultury-logo.png}}}
215         \href{http://koed.org.pl}{\xbox{\includegraphics[height=.55in]{koedlogo.png}}}
216     \end{minipage}
217     \noindent \begin{minipage}[t]{.35\textwidth}\vspace{0pt}
218         \raggedright
219         %\xbox{\includegraphics[width=1.6in]{trust-logo.eps}}
220         \href{http://nowoczesnapolska.org.pl}{\xbox{\includegraphics[height=.55in]{nowoczesnapolska.org.pl.png}}}
221         \vspace{.5em}
222     \end{minipage}
223
224 %    \begin{minipage}[t]{.45\textwidth}\vspace{0pt}
225
226     \ifflaglessadvertising
227     \else
228         %\noindent Ten rozdział pochodzi z książki \emph{\@title}, która zostanie opublikowana w portalu
229         %\href{http://prawokultury.pl/}{prawokultury.pl}.
230         \vspace{.5em}
231     \fi
232
233  %   Utwór opracowany został w ramach projektu \href{http://www.wolnelektury.pl/}{Wolne Lektury}
234   %  przez \href{http://nowoczesnapolska.org.pl}{fundację Nowoczesna Polska}.
235
236  %   \end{minipage}
237     \noindent \rule{\linewidth}{0.4pt}
238
239     \vspace{.6em}
240     \color{black}
241     }
242 }
243
244 \newcommand{\editorialsection}{
245   \begin{figure}[b!]
246   {
247     \footnotesize
248     \color{theme}
249     \noindent \rule{\linewidth}{0.4pt}
250
251     \rightsinfo
252     \vspace{.6em}
253
254     %Źródło: \href{\bookurl}{\bookurl}
255
256     %\vspace{.6em}
257     \sourceinfo
258
259     \description
260     \vspace{.6em}
261
262     \editors
263
264     \vspace{.6em}
265     \coverby
266
267     \color{black}
268   }
269   \end{figure}
270 }
271
272
273 \newcommand{\typosubsubsection}[1]{%
274 {\textsc{#1}}
275 }
276
277 \newcommand{\typosubsection}[1]{%
278 {\addfontfeature{
279 SizeFeatures={
280   {Size={-10}, Scale=1.2, FakeStretch=1.00, LetterSpace=8.0 },
281   {Size={10.5-12}, Scale=1.2, FakeStretch=1.00, LetterSpace=8.0 },
282   {Size={12-}, FakeStretch=1.0, LetterSpace=8.0 }
283 },
284 Letters={Uppercase}
285 }
286 \MakeUppercase{#1}}
287 }
288
289 \newcommand{\typosection}[1]{%
290 %{\addfontfeature{FakeStretch=0.96, LetterSpace=-4.0}\emph{\scalefont{2}#1}}
291 {\addfontfeature{FakeStretch=0.96, LetterSpace=-4.0}\emph{\scalefont{1.7}#1}}
292 %{\addfontfeature{Scale=2.0, FakeStretch=0.98, LetterSpace=-2.0}\emph{#1}}
293 }
294
295
296 \newcommand{\tytul}[1]{%
297 #1%
298 \vspace{1em}%
299 }
300
301 \newcommand{\nazwapodutworu}[1]{%
302 \section*{\typosection{#1}}%
303 }
304
305 \newcommand{\autorutworu}[1]{%
306 \subsection*{\typosubsection{#1}}%
307 }
308
309 \newcommand{\dzielonadrzedne}[1]{%
310 \subsection*{\typosubsubsection{#1}}%
311 }
312
313 \newcommand{\nazwautworu}[1]{%
314 \section*{\raggedright{\typosection{#1}}}%
315 }
316
317 \newcommand{\podtytul}[1]{%
318 \subsection*{\typosubsubsection{#1}}%
319 }
320
321 \newcommand{\translator}[1]{%
322 \subsection*{\typosubsubsection{tłum. #1}}%
323 }
324
325
326 \newcommand{\powiesc}[1]{#1}
327 \newcommand{\opowiadanie}[1]{#1}
328 \newcommand{\lirykal}[1]{#1}
329 \newcommand{\lirykalp}[1]{#1}
330 \newcommand{\dramatwierszowanyl}[1]{#1}
331 \newcommand{\dramatwierszowanylp}[1]{#1}
332 \newcommand{\dramatwspolczesny}[1]{#1}
333
334 \newcommand{\nota}[1]{%
335 \par{#1}%
336 }
337
338 \newcommand{\dedykacja}[1]{%
339 \begin{em}%
340 \begin{flushright}%
341 #1%
342 \end{flushright}%
343 \end{em}%
344 }
345
346 \newcommand{\dlugicytat}[1]{%
347 \begin{quotation}%
348 \raggedright%
349 #1%
350 \end{quotation}%
351 }
352
353 \newcommand{\poezjacyt}[1]{%
354 \begin{verse}%
355 #1%
356 \end{verse}%
357 }
358 \newcommand{\motto}[1]{%
359 \begin{em}%
360 #1%
361 \end{em}%
362 }
363 \newcommand{\listaosob}[2]{%
364 \par{#1}%
365 \begin{itemize}%
366 #2%
367 \end{itemize}%
368 }
369
370 \newcommand{\nagloweklisty}[1]{%
371 \typosubsubsection{#1}%
372 }
373
374 \newcommand{\listaosoba}[1]{%
375 \item{#1}%
376 }
377
378 \newcommand{\kwestia}[1]{%
379 \par{#1}%
380 }
381
382 \newcommand{\naglowekakt}[1]{%
383 \pagebreak
384 \subsection*{\typosubsection{#1}}%
385 }
386 \newcommand{\naglowekczesc}[1]{%
387 \pagebreak
388 \subsection*{\typosubsection{#1}}%
389 }
390 \newcommand{\srodtytul}[1]{%
391 \par{\typosubsubsection{#1}}%
392 %\subsection*{\typosubsection{#1}}%
393 }
394
395 \newcommand{\naglowekscena}[1]{%
396 \subsubsection*{\typosubsubsection{#1}}%
397 }
398 \newcommand{\naglowekrozdzial}[1]{%
399 \subsection*{\raggedright \typosubsection{#1}}%
400 %\subsubsection*{\typosubsubsection{#1}}%
401 }
402
403 \newcommand{\naglowekosoba}[1]{%
404 \par{\textsc{#1}}\nopagebreak%
405 }
406 \newcommand{\naglowekpodrozdzial}[1]{%
407 \subsubsection*{\typosubsubsection{#1}}%
408 %\par{#1}\nopagebreak%
409 }
410
411 \newcommand{\miejsceczas}[1]{%
412 \par{\emph{#1}}%
413 }
414 \newcommand{\didaskalia}[1]{%
415 \par{\emph{#1}}%
416 }
417
418 \newcommand{\akap}[1]{%
419 \par{#1}%
420 }
421 \newcommand{\akapdialog}[1]{%
422 \par{#1}%
423 }
424 \newcommand{\akapcd}[1]{%
425 \par{#1}%
426 }
427
428 \newcommand{\mottopodpis}[1]{%
429 \begin{em}%
430 \begin{flushright}%
431 #1%
432 \end{flushright}%
433 \end{em}%
434 }
435
436 \newcommand{\strofa}[1]{%
437 \par{\noindent{\ignorespaces#1\vspace{1em}}}%
438 }
439
440 \newcommand{\wers}[1]{#1}
441
442 \newcommand{\wersakap}[1]{%
443 \hspace*{1em}#1%
444 }
445 \newcommand{\werscd}[1]{%
446 \hspace*{8em}#1%
447 }
448 \newcommand{\werswciety}[2][1em]{%
449 \hspace*{#1}#2%
450 }
451
452 \ifshowfootnotes
453   \newcommand{\pa}[1]{\NoCaseChange{\footnote{#1 [przypis autorski]}}}
454   \newcommand{\pe}[1]{\NoCaseChange{\footnote{#1}}}
455   \newcommand{\pr}[1]{\NoCaseChange{\footnote{#1}}}
456   \newcommand{\pt}[1]{\NoCaseChange{\footnote{#1}}}
457 \else
458   \newcommand{\pa}[1]{}
459   \newcommand{\pe}[1]{}
460   \newcommand{\pr}[1]{}
461   \newcommand{\pt}[1]{}
462 \fi
463
464 \newcommand{\mat}[1]{$#1$}
465
466 \newcommand{\didasktekst}[1]{%
467 \emph{#1}%
468 }
469 \newcommand{\slowoobce}[1]{%
470 \emph{#1}%
471 }
472 \newcommand{\tytuldziela}[1]{%
473 \emph{#1}%
474 }
475 \newcommand{\wyroznienie}[1]{%
476 \emph{#1}%
477 }
478
479 \newcommand{\osoba}[1]{%
480 #1%
481 }
482
483 \newcommand{\sekcjaswiatlo}{%
484 \vspace{30pt}%
485 }
486
487 \newcommand{\sekcjaasterysk}{%
488 \vspace{10pt}%
489 \begin{center}%
490 \par{*}%
491 \end{center}%
492 }
493
494 \newcommand{\separatorlinia}{%
495 \vspace{10pt}%
496 \hrule{}%
497 \vspace{10pt}%
498 }
499
500 \newcommand{\motyw}[2][0]{%
501 \ifshowthemes
502 \mbox{}%
503 \marginpar{%
504 \vspace{-8pt}%
505 \vspace{-#1\baselineskip}%
506 \raggedright{\hspace{0pt}%
507 \footnotesize{\color{theme}{#2}}}%
508 \vspace{\baselineskip}%
509 }%
510 \fi
511 }
512
513
514 \newcommand{\www}[1]{%
515 %\href{#1}{#1}%
516 \url{#1}%
517 }
518 \newcommand{\listanum}[1]{%
519 \begin{enumerate}%
520 #1%
521 \end{enumerate}%
522 }
523 \newcommand{\listapunkt}[1]{%
524 \begin{itemize}%
525 #1%
526 \end{itemize}%
527 }
528 \newcommand{\punkt}[1]{%
529 \item #1%
530 }
531 \newcommand{\ilustr}[2]{%
532 \vspace{1em}%
533 \par{\noindent\includegraphics[width=\textwidth]{#1}}%
534 \vspace{1em}%
535 }