not-wl support in pdf
[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     \ifflagnotwl
201     \else
202         \thispagestyle{empty}
203         \footnotesize
204         \color{theme}
205         \noindent \begin{minipage}[t]{.35\textwidth}\vspace{0pt}
206             \href{http://www.wolnelektury.pl}{\xbox{\includegraphics[width=\textwidth]{wl-logo.png}}}
207         \end{minipage}
208         \begin{minipage}[t]{.65\textwidth}\vspace{0pt}
209
210         \ifflaglessadvertising
211         \else
212             \href{\bookurl}{Ta lektura}, podobnie jak tysiące innych, jest dostępna on-line na stronie
213             \href{http://www.wolnelektury.pl/}{wolnelektury.pl}.
214             \vspace{.5em}
215         \fi
216
217         Utwór opracowany został w ramach projektu \href{http://www.wolnelektury.pl/}{Wolne Lektury}
218         przez \href{http://nowoczesnapolska.org.pl}{fundację Nowoczesna Polska}.
219
220         \end{minipage}
221         \noindent \rule{\linewidth}{0.4pt}
222
223         \vspace{.6em}
224         \color{black}
225     \fi
226     }
227 }
228
229 \newcommand{\editorialsection}{
230   \begin{figure}[b!]
231   {
232     \footnotesize
233     \color{theme}
234     \noindent \rule{\linewidth}{0.4pt}
235
236     \rightsinfo
237     \vspace{.6em}
238
239     \ifflagnotwl
240     \else
241         Źródło: \href{\bookurl}{\bookurl}
242     \fi
243
244     \vspace{.6em}
245     \sourceinfo
246
247     \description
248     \vspace{.6em}
249
250     \editors
251
252     \vspace{.6em}
253     \coverby
254
255     \color{black}
256   }
257   \end{figure}
258 }
259
260
261 \newcommand{\typosubsubsection}[1]{%
262 %{\textsc{#1}}
263 #1
264 }
265
266 \newcommand{\typosubsection}[1]{%
267 {\addfontfeature{
268 SizeFeatures={
269   {Size={-10}, Scale=1.2, FakeStretch=1.00, LetterSpace=8.0 },
270   {Size={10.5-12}, Scale=1.2, FakeStretch=1.00, LetterSpace=8.0 },
271   {Size={12-}, FakeStretch=1.0, LetterSpace=8.0 }
272 },
273 Letters={Uppercase}
274 }
275 \MakeUppercase{#1}}
276 }
277
278 \newcommand{\typosection}[1]{%
279 {\addfontfeature{FakeStretch=0.96, LetterSpace=-4.0}\emph{\scalefont{2}#1}}
280 %{\addfontfeature{Scale=2.0, FakeStretch=0.98, LetterSpace=-2.0}\emph{#1}}
281 }
282
283
284 \newcommand{\tytul}[1]{%
285 #1%
286 \vspace{1em}%
287 }
288
289 \newcommand{\nazwapodutworu}[1]{%
290 \section*{\typosection{#1}}%
291 }
292
293 \newcommand{\autorutworu}[1]{%
294 \subsection*{\typosubsection{#1}}%
295 }
296
297 \newcommand{\dzielonadrzedne}[1]{%
298 \subsection*{\typosubsubsection{#1}}%
299 }
300
301 \newcommand{\nazwautworu}[1]{%
302 \section*{\typosection{#1}}%
303 }
304
305 \newcommand{\podtytul}[1]{%
306 \subsection*{\typosubsubsection{#1}}%
307 }
308
309 \newcommand{\translator}[1]{%
310 \subsection*{\typosubsubsection{tłum. #1}}%
311 }
312
313
314 \newcommand{\powiesc}[1]{#1}
315 \newcommand{\opowiadanie}[1]{#1}
316 \newcommand{\lirykal}[1]{#1}
317 \newcommand{\lirykalp}[1]{#1}
318 \newcommand{\dramatwierszowanyl}[1]{#1}
319 \newcommand{\dramatwierszowanylp}[1]{#1}
320 \newcommand{\dramatwspolczesny}[1]{#1}
321
322 \newcommand{\nota}[1]{%
323 \par{#1}%
324 }
325
326 \newcommand{\dedykacja}[1]{%
327 \begin{em}%
328 \begin{flushright}%
329 #1%
330 \end{flushright}%
331 \end{em}%
332 }
333
334 \newcommand{\dlugicytat}[1]{%
335 \begin{quotation}%
336 #1%
337 \end{quotation}%
338 }
339
340 \newcommand{\poezjacyt}[1]{%
341 \begin{verse}%
342 #1%
343 \end{verse}%
344 }
345 \newcommand{\motto}[1]{%
346 \begin{em}%
347 #1%
348 \end{em}%
349 }
350 \newcommand{\listaosob}[2]{%
351 \par{#1}%
352 \begin{itemize}%
353 #2%
354 \end{itemize}%
355 }
356
357 \newcommand{\nagloweklisty}[1]{%
358 \typosubsubsection{#1}%
359 }
360
361 \newcommand{\listaosoba}[1]{%
362 \item{#1}%
363 }
364
365 \newcommand{\kwestia}[1]{%
366 \par{#1}%
367 }
368
369 \newcommand{\naglowekakt}[1]{%
370 \pagebreak
371 \subsection*{\typosubsection{#1}}%
372 }
373 \newcommand{\naglowekczesc}[1]{%
374 \pagebreak
375 \subsection*{\typosubsection{#1}}%
376 }
377 \newcommand{\srodtytul}[1]{%
378 \subsection*{\typosubsection{#1}}%
379 }
380
381 \newcommand{\naglowekscena}[1]{%
382 \subsubsection*{\typosubsubsection{#1}}%
383 }
384 \newcommand{\naglowekrozdzial}[1]{%
385 \subsubsection*{\typosubsubsection{#1}}%
386 }
387
388 \newcommand{\naglowekosoba}[1]{%
389 \par{\textsc{#1}}\nopagebreak%
390 }
391 \newcommand{\naglowekpodrozdzial}[1]{%
392 \par{#1}\nopagebreak%
393 }
394
395 \newcommand{\miejsceczas}[1]{%
396 \par{\emph{#1}}%
397 }
398 \newcommand{\didaskalia}[1]{%
399 \par{\emph{#1}}%
400 }
401
402 \newcommand{\akap}[1]{%
403 \par{#1}%
404 }
405 \newcommand{\akapdialog}[1]{%
406 \par{#1}%
407 }
408 \newcommand{\akapcd}[1]{%
409 \par{#1}%
410 }
411
412 \newcommand{\mottopodpis}[1]{%
413 \begin{em}%
414 \begin{flushright}%
415 #1%
416 \end{flushright}%
417 \end{em}%
418 }
419
420 \newcommand{\strofa}[1]{%
421 \par{\noindent{\ignorespaces#1\vspace{1em}}}%
422 }
423
424 \newcommand{\wers}[1]{#1}
425
426 \newcommand{\wersakap}[1]{%
427 \hspace*{1em}#1%
428 }
429 \newcommand{\werscd}[1]{%
430 \hspace*{8em}#1%
431 }
432 \newcommand{\werswciety}[2][1em]{%
433 \hspace*{#1}#2%
434 }
435
436 \ifshowfootnotes
437   \newcommand{\pa}[1]{\NoCaseChange{\footnote{#1 [przypis autorski]}}}
438   \newcommand{\pe}[1]{\NoCaseChange{\footnote{#1}}}
439   \newcommand{\pr}[1]{\NoCaseChange{\footnote{#1}}}
440   \newcommand{\pt}[1]{\NoCaseChange{\footnote{#1}}}
441 \else
442   \newcommand{\pa}[1]{}
443   \newcommand{\pe}[1]{}
444   \newcommand{\pr}[1]{}
445   \newcommand{\pt}[1]{}
446 \fi
447
448 \newcommand{\mat}[1]{$#1$}
449
450 \newcommand{\didasktekst}[1]{%
451 \emph{#1}%
452 }
453 \newcommand{\slowoobce}[1]{%
454 \emph{#1}%
455 }
456 \newcommand{\tytuldziela}[1]{%
457 \emph{#1}%
458 }
459 \newcommand{\wyroznienie}[1]{%
460 \emph{#1}%
461 }
462
463 \newcommand{\osoba}[1]{%
464 #1%
465 }
466
467 \newcommand{\sekcjaswiatlo}{%
468 \vspace{30pt}%
469 }
470
471 \newcommand{\sekcjaasterysk}{%
472 \vspace{10pt}%
473 \begin{center}%
474 \par{*}%
475 \end{center}%
476 }
477
478 \newcommand{\separatorlinia}{%
479 \vspace{10pt}%
480 \hrule{}%
481 \vspace{10pt}%
482 }
483
484 \newcommand{\motyw}[2][0]{%
485 \ifshowthemes
486 \mbox{}%
487 \marginpar{%
488 \vspace{-8pt}%
489 \vspace{-#1\baselineskip}%
490 \raggedright{\hspace{0pt}%
491 \footnotesize{\color{theme}{#2}}}%
492 \vspace{\baselineskip}%
493 }%
494 \fi
495 }
496