import with for py2.5
[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 % onehalfleading - leading of 1.5 (interlinia)
10 % doubleleading - double leading (interlinia)
11 % a4paper,... - paper size as required by LaTeX
12 % nowlfont - don't use customized WL font
13
14 \RequirePackage{setspace}
15 \RequirePackage{type1cm}
16 \DeclareOption{13pt}{%
17 \AtEndOfClass{%
18 % font size definitions, similar to ones in /usr/share/texmf-texlive/tex/latex/base/
19 \renewcommand\normalsize{%
20    \@setfontsize\normalsize{13pt}{14.5pt}%
21    \abovedisplayskip 12\p@ \@plus3\p@ \@minus7\p@
22    \abovedisplayshortskip \z@ \@plus3\p@
23    \belowdisplayshortskip 6.5\p@ \@plus3.5\p@ \@minus3\p@
24    \belowdisplayskip \abovedisplayskip
25    \let\@listi\@listI}\normalsize%
26 \renewcommand\footnotesize{%
27    \@setfontsize\footnotesize\@xpt\@xiipt
28    \abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@
29    \abovedisplayshortskip \z@ \@plus3\p@
30    \belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@
31    \def\@listi{\leftmargin\leftmargini
32                \topsep 6\p@ \@plus2\p@ \@minus2\p@
33                \parsep 3\p@ \@plus2\p@ \@minus\p@
34                \itemsep \parsep}%
35    \belowdisplayskip \abovedisplayskip
36 }%
37 }%
38 }
39
40 %% \DeclareOption{14pt}{\renewcommand{\normalsize}{\AtEndOfClass{\fontsize{14}{17}\selectfont}}}
41
42 \DeclareOption{doubleleading}{\AtBeginDocument{\doublespacing}}%\setlength{\leading}{1em plus 0.5ex minus 0.2ex}}
43 \DeclareOption{onehalfleading}{\AtBeginDocument{\onehalfspacing}}%\setlength{\leading}{1em plus 0.5ex minus 0.2ex}}
44
45 %% 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.
46 \DeclareOption{a5paper}{%
47       \setlength{\paperheight}{210mm}%
48       \setlength{\paperwidth}{148mm}}
49
50
51 \newif\ifshowfootnotes \showfootnotestrue
52 \DeclareOption{nofootnotes}{\showfootnotesfalse}
53
54 \newif\ifshowthemes \showthemestrue
55 \DeclareOption{nothemes}{\showthemesfalse}
56
57 \newif\ifenablewlfont \enablewlfonttrue
58 \DeclareOption{nowlfont}{\enablewlfontfalse}
59
60 \DeclareOption*{\PassOptionsToClass{\CurrentOption}{book}}
61 \ProcessOptions\relax
62 \LoadClass[a4paper,oneside]{book}
63
64
65 \usepackage{trace}
66
67 \usepackage[MeX]{polski}
68
69 \usepackage[xetex]{graphicx}
70 \usepackage{fontspec}
71 \usepackage{xunicode}
72 \usepackage{xltxtra}
73
74 \usepackage[overload]{textcase}
75 \usepackage{scalefnt}
76 \usepackage[colorlinks=true,linkcolor=black,setpagesize=false,urlcolor=black,xetex]{hyperref}
77
78 \ifenablewlfont
79 \setmainfont [
80 %ExternalLocation,
81 UprightFont = JunicodeWL-Regular,
82 ItalicFont = JunicodeWL-Italic,
83 BoldFont = JunicodeWL-Regular,
84 BoldItalicFont = JunicodeWL-Italic,
85 SmallCapsFont = JunicodeWL-Regular,
86 SmallCapsFeatures = {Letters={SmallCaps,UppercaseSmallCaps}},
87 Numbers=OldStyle,
88 Scale=1.04,
89 LetterSpace=-1.0
90 ] {JunicodeWL}
91
92 \newfontfamily\alien[
93 SmallCapsFeatures = {Letters={SmallCaps,UppercaseSmallCaps}},
94 Numbers=OldStyle,
95 Scale=0.85,
96 LetterSpace=-1.0
97 ] {DejaVu Serif}
98
99
100 \defaultfontfeatures{
101 SizeFeatures={
102   {Size={-10.5}, FakeStretch=1.02, LetterSpace=2.0 },
103   {Size={10.5-12}, FakeStretch=2.00, LetterSpace=0.0 },
104   {Size={12-}, FakeStretch=0.98, LetterSpace=-2.0 }
105 }
106 }
107
108 \renewcommand{\textsc}[1]{%
109 {\addfontfeature{
110 SizeFeatures={
111   {Size={-10.5}, Scale=1.2, FakeStretch=1.02, LetterSpace=8.0 },
112   {Size={10.5-12}, Scale=1.2, FakeStretch=1.02, LetterSpace=8.0 },
113   {Size={12-}, FakeStretch=1.0, LetterSpace=8.0 }
114 },
115 Letters={SmallCaps,UppercaseSmallCaps}
116 }
117 #1}
118 }
119 \fi% enablewlfont
120
121 %{\Itshape JunicodeWL-Italic.ttf }
122 %{\bfseries Junicode-Bold.ttf }
123 %{\bfseries\itshape Junicode-BoldItalic.ttf }
124
125 \pagestyle{plain}
126 \usepackage{fancyhdr}
127
128 \makeatletter
129
130 % bottom figure below footnotes
131 \usepackage{fnpos}
132 \makeFNabove
133
134 \usepackage{color}
135 \definecolor{theme}{gray}{.3}
136
137 \setlength{\marginparsep}{2em}
138 \setlength{\marginparwidth}{8.5em}
139 \setlength{\oddsidemargin}{0pt}
140 \setlength{\voffset}{0pt}
141 \setlength{\topmargin}{0pt}
142 \setlength{\headheight}{0pt}
143 \setlength{\headsep}{0pt}
144 \setlength{\textheight}{24cm}
145
146 \pagestyle{fancy}
147 \fancyhf{}
148 \renewcommand{\headrulewidth}{0pt}
149 \renewcommand{\footrulewidth}{0pt}
150 \lfoot{{\footnotesize \textsc{\@author} \emph{\@title}}}
151 \cfoot{}
152 \rfoot{{\footnotesize \thepage}}
153
154 \clubpenalty=100000
155 \widowpenalty=100000
156
157
158 % see http://osdir.com/ml/tex.xetex/2005-10/msg00003.html
159 \newsavebox{\ximagebox}\newlength{\ximageheight}
160 \newsavebox{\xglyphbox}\newlength{\xglyphheight}
161 \newcommand{\xbox}[1]
162 {\savebox{\ximagebox}{#1}\settoheight{\ximageheight}{\usebox {\ximagebox}}%
163 \savebox{\xglyphbox}{\char32}\settoheight{\xglyphheight}{\usebox {\xglyphbox}}%
164 \raisebox{\ximageheight}[0pt][0pt]{%\raisebox{-\xglyphheight}[0pt] [0pt]{%
165 \makebox[0pt][l]{\usebox{\xglyphbox}}}%}%
166 \usebox{\ximagebox}%
167 \raisebox{0pt}[0pt][0pt]{\makebox[0pt][r]{\usebox{\xglyphbox}}}}
168
169 \newcommand{\makecover}[2]{
170         \pdfpagewidth=#1
171         \pdfpageheight=#2
172
173         \thispagestyle{empty}
174         \newlength{\PictHOffset}
175         \newlength{\PictVOffset}
176         \setlength{\PictHOffset}{1in}
177         \addtolength{\PictHOffset}{\hoffset}
178         \addtolength{\PictHOffset}{\oddsidemargin}
179
180         \setlength{\PictVOffset}{1in}
181         \addtolength{\PictVOffset}{\voffset}
182         \addtolength{\PictVOffset}{\topmargin}
183         \addtolength{\PictVOffset}{\headheight}
184         \addtolength{\PictVOffset}{\headsep}
185         \addtolength{\PictVOffset}{\topskip}
186         \addtolength{\PictVOffset}{-\pdfpageheight}
187
188         \noindent\hspace*{-\PictHOffset}%
189         \raisebox{\PictVOffset}[0pt][0pt]{\makebox[0pt][l]{%
190             \includegraphics[height=\pdfpageheight,width=\pdfpagewidth]{cover.png}}}
191         \clearpage
192
193         \setlength{\pdfpagewidth}{210mm}
194         \setlength{\pdfpageheight}{297mm}
195 }
196
197
198 \renewcommand{\maketitle}{
199     {
200     \thispagestyle{empty}
201     \footnotesize
202     \color{theme}
203
204     \noindent \begin{minipage}[t]{.35\textwidth}\vspace{0pt}
205         \href{http://www.wolnelektury.pl}{\xbox{\includegraphics[width=\textwidth]{wl-logo.png}}}
206     \end{minipage}
207     \begin{minipage}[t]{.65\textwidth}\vspace{0pt}
208
209     \ifflaglessadvertising
210     \else
211         \href{\bookurl}{Ta lektura}, podobnie jak tysiące innych, jest dostępna on-line na stronie
212         \href{http://www.wolnelektury.pl/}{wolnelektury.pl}.
213         \vspace{.5em}
214     \fi
215
216     Utwór opracowany został w ramach projektu \href{http://www.wolnelektury.pl/}{Wolne Lektury}
217     przez \href{http://nowoczesnapolska.org.pl}{fundację Nowoczesna Polska}.
218
219     \end{minipage}
220     \noindent \rule{\linewidth}{0.4pt}
221
222     \vspace{.6em}
223     \color{black}
224     }
225 }
226
227 \newcommand{\editorialsection}{
228   \begin{figure}[b!]
229   {
230     \footnotesize
231     \color{theme}
232     \noindent \rule{\linewidth}{0.4pt}
233
234     \rightsinfo
235     \vspace{.6em}
236
237     Źródło: \href{\bookurl}{\bookurl}
238
239     \vspace{.6em}
240     \sourceinfo
241
242     \description
243     \vspace{.6em}
244
245     \editors
246
247     \color{black}
248   }
249   \end{figure}
250 }
251
252
253 \newcommand{\typosubsubsection}[1]{%
254 {\textsc{#1}}
255 }
256
257 \newcommand{\typosubsection}[1]{%
258 {\addfontfeature{
259 SizeFeatures={
260   {Size={-10}, Scale=1.2, FakeStretch=1.00, LetterSpace=8.0 },
261   {Size={10.5-12}, Scale=1.2, FakeStretch=1.00, LetterSpace=8.0 },
262   {Size={12-}, FakeStretch=1.0, LetterSpace=8.0 }
263 },
264 Letters={Uppercase}
265 }
266 \MakeUppercase{#1}}
267 }
268
269 \newcommand{\typosection}[1]{%
270 {\addfontfeature{FakeStretch=0.96, LetterSpace=-4.0}\emph{\scalefont{2}#1}}
271 %{\addfontfeature{Scale=2.0, FakeStretch=0.98, LetterSpace=-2.0}\emph{#1}}
272 }
273
274
275 \newcommand{\tytul}[1]{%
276 #1%
277 \vspace{1em}%
278 }
279
280 \newcommand{\nazwapodutworu}[1]{%
281 \section*{\typosection{#1}}%
282 }
283
284 \newcommand{\autorutworu}[1]{%
285 \subsection*{\typosubsection{#1}}%
286 }
287
288 \newcommand{\dzielonadrzedne}[1]{%
289 \subsection*{\typosubsubsection{#1}}%
290 }
291
292 \newcommand{\nazwautworu}[1]{%
293 \section*{\typosection{#1}}%
294 }
295
296 \newcommand{\podtytul}[1]{%
297 \subsection*{\typosubsubsection{#1}}%
298 }
299
300 \newcommand{\translator}[1]{%
301 \subsection*{\typosubsubsection{tłum. #1}}%
302 }
303
304
305 \newcommand{\powiesc}[1]{#1}
306 \newcommand{\opowiadanie}[1]{#1}
307 \newcommand{\lirykal}[1]{#1}
308 \newcommand{\lirykalp}[1]{#1}
309 \newcommand{\dramatwierszowanyl}[1]{#1}
310 \newcommand{\dramatwierszowanylp}[1]{#1}
311 \newcommand{\dramatwspolczesny}[1]{#1}
312
313 \newcommand{\nota}[1]{%
314 \par{#1}%
315 }
316
317 \newcommand{\dedykacja}[1]{%
318 \begin{em}%
319 \begin{flushright}%
320 #1%
321 \end{flushright}%
322 \end{em}%
323 }
324
325 \newcommand{\dlugicytat}[1]{%
326 \begin{quotation}%
327 #1%
328 \end{quotation}%
329 }
330
331 \newcommand{\poezjacyt}[1]{%
332 \begin{verse}%
333 #1%
334 \end{verse}%
335 }
336 \newcommand{\motto}[1]{%
337 \begin{em}%
338 #1%
339 \end{em}%
340 }
341 \newcommand{\listaosob}[2]{%
342 \par{#1}%
343 \begin{itemize}%
344 #2%
345 \end{itemize}%
346 }
347
348 \newcommand{\nagloweklisty}[1]{%
349 \typosubsubsection{#1}%
350 }
351
352 \newcommand{\listaosoba}[1]{%
353 \item{#1}%
354 }
355
356 \newcommand{\kwestia}[1]{%
357 \par{#1}%
358 }
359
360 \newcommand{\naglowekakt}[1]{%
361 \pagebreak
362 \subsection*{\typosubsection{#1}}%
363 }
364 \newcommand{\naglowekczesc}[1]{%
365 \pagebreak
366 \subsection*{\typosubsection{#1}}%
367 }
368 \newcommand{\srodtytul}[1]{%
369 \subsection*{\typosubsection{#1}}%
370 }
371
372 \newcommand{\naglowekscena}[1]{%
373 \subsubsection*{\typosubsubsection{#1}}%
374 }
375 \newcommand{\naglowekrozdzial}[1]{%
376 \subsubsection*{\typosubsubsection{#1}}%
377 }
378
379 \newcommand{\naglowekosoba}[1]{%
380 \par{\textsc{#1}}\nopagebreak%
381 }
382 \newcommand{\naglowekpodrozdzial}[1]{%
383 \par{#1}\nopagebreak%
384 }
385
386 \newcommand{\miejsceczas}[1]{%
387 \par{\emph{#1}}%
388 }
389 \newcommand{\didaskalia}[1]{%
390 \par{\emph{#1}}%
391 }
392
393 \newcommand{\akap}[1]{%
394 \par{#1}%
395 }
396 \newcommand{\akapdialog}[1]{%
397 \par{#1}%
398 }
399 \newcommand{\akapcd}[1]{%
400 \par{#1}%
401 }
402
403 \newcommand{\mottopodpis}[1]{%
404 \begin{em}%
405 \begin{flushright}%
406 #1%
407 \end{flushright}%
408 \end{em}%
409 }
410
411 \newcommand{\strofa}[1]{%
412 \par{\noindent{\ignorespaces#1\vspace{1em}}}%
413 }
414
415 \newcommand{\wers}[1]{#1}
416
417 \newcommand{\wersakap}[1]{%
418 \hspace*{1em}#1%
419 }
420 \newcommand{\werscd}[1]{%
421 \hspace*{8em}#1%
422 }
423 \newcommand{\werswciety}[2][1em]{%
424 \hspace*{#1}#2%
425 }
426
427 \ifshowfootnotes
428   \newcommand{\pa}[1]{\NoCaseChange{\footnote{#1 [przypis autorski]}}}
429   \newcommand{\pe}[1]{\NoCaseChange{\footnote{#1}}}
430   \newcommand{\pr}[1]{\NoCaseChange{\footnote{#1}}}
431   \newcommand{\pt}[1]{\NoCaseChange{\footnote{#1}}}
432 \else
433   \newcommand{\pa}[1]{}
434   \newcommand{\pe}[1]{}
435   \newcommand{\pr}[1]{}
436   \newcommand{\pt}[1]{}
437 \fi
438
439 \newcommand{\mat}[1]{$#1$}
440
441 \newcommand{\didasktekst}[1]{%
442 \emph{#1}%
443 }
444 \newcommand{\slowoobce}[1]{%
445 \emph{#1}%
446 }
447 \newcommand{\tytuldziela}[1]{%
448 \emph{#1}%
449 }
450 \newcommand{\wyroznienie}[1]{%
451 \emph{#1}%
452 }
453
454 \newcommand{\osoba}[1]{%
455 #1%
456 }
457
458 \newcommand{\sekcjaswiatlo}{%
459 \vspace{30pt}%
460 }
461
462 \newcommand{\sekcjaasterysk}{%
463 \vspace{10pt}%
464 \begin{center}%
465 \par{*}%
466 \end{center}%
467 }
468
469 \newcommand{\separatorlinia}{%
470 \vspace{10pt}%
471 \hrule{}%
472 \vspace{10pt}%
473 }
474
475 \newcommand{\motyw}[2][0]{%
476 \ifshowthemes
477 \mbox{}%
478 \marginpar{%
479 \vspace{-8pt}%
480 \vspace{-#1\baselineskip}%
481 \raggedright{\hspace{0pt}%
482 \footnotesize{\color{theme}{#2}}}%
483 \vspace{\baselineskip}%
484 }%
485 \fi
486 }
487