4ed3d0ecc9e2e8651c2081dae18f30c66ea34201
[librarian.git] / librarian / pdf / wlpub.cls
1 % -*- coding: utf-8 -*-
2 \NeedsTeXFormat{LaTeX2e}
3 \ProvidesClass{wlpub}[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{geometry}
16 \RequirePackage{setspace}
17 \RequirePackage{type1cm}
18 \RequirePackage{amssymb}
19 \RequirePackage{amsmath}
20 \RequirePackage{paralist}
21 \RequirePackage[normalem]{ulem}
22 %\DeclareOption{13pt}{%
23 %\AtEndOfClass{%
24 % font size definitions, similar to ones in /usr/share/texmf-texlive/tex/latex/base/
25 %% \renewcommand\normalsize{%
26 %%    \@setfontsize\normalsize{13pt}{14.5pt}%
27 %%    \abovedisplayskip 12\p@ \@plus3\p@ \@minus7\p@
28 %%    \abovedisplayshortskip \z@ \@plus3\p@
29 %%    \belowdisplayshortskip 6.5\p@ \@plus3.5\p@ \@minus3\p@
30 %%    \belowdisplayskip \abovedisplayskip
31 %%    \let\@listi\@listI}\normalsize%
32 %% \renewcommand\footnotesize{%
33 %%    \@setfontsize\footnotesize\@xpt\@xiipt
34 %%    \abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@
35 %%    \abovedisplayshortskip \z@ \@plus3\p@
36 %%    \belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@
37 %%    \def\@listi{\leftmargin\leftmargini
38 %%                \topsep 6\p@ \@plus2\p@ \@minus2\p@
39 %%                \parsep 3\p@ \@plus2\p@ \@minus\p@
40 %%                \itemsep \parsep}%
41 %%    \belowdisplayskip \abovedisplayskip
42 %}%
43 %}%
44 %}
45
46 %% \DeclareOption{14pt}{\renewcommand{\normalsize}{\AtEndOfClass{\fontsize{14}{17}\selectfont}}}
47
48 \DeclareOption{defaultleading}{}
49 \DeclareOption{doubleleading}{\AtBeginDocument{\doublespacing}}%\setlength{\leading}{1em plus 0.5ex minus 0.2ex}}
50 \DeclareOption{onehalfleading}{\AtBeginDocument{\onehalfspacing}}%\setlength{\leading}{1em plus 0.5ex minus 0.2ex}}
51
52 %% 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.
53 \DeclareOption{a5paper}{%
54       \setlength{\paperheight}{210mm}%
55       \setlength{\paperwidth}{148mm}}
56 % a5paper dropped down size
57 \newif\ifcutafivepaper \cutafivepaperfalse
58 \DeclareOption{a5paperdd}{%
59   \setlength{\paperheight}{225mm}%
60   \setlength{\paperwidth}{160mm}%
61   \cutafivepapertrue
62 }
63
64 \newif\ifshowfootnotes \showfootnotestrue
65 \DeclareOption{nofootnotes}{\showfootnotesfalse}
66
67 \newif\ifshowthemes \showthemestrue
68 \DeclareOption{nothemes}{\showthemesfalse}
69
70 \newif\ifenablewlfont \enablewlfonttrue
71 \DeclareOption{nowlfont}{\enablewlfontfalse}
72
73
74 \DeclareOption*{\PassOptionsToClass{\CurrentOption}{extbook}}
75 \ProcessOptions\relax
76 \LoadClass{extbook}
77 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
78
79 \usepackage{trace}
80 \usepackage{caption}
81 \usepackage{tabularx}
82 \usepackage[MeX]{polski}
83 \usepackage{icomma}
84 \usepackage[xetex]{graphicx}
85 \usepackage{fontspec}
86 \usepackage{xunicode}
87 \usepackage{xltxtra}
88 \usepackage{trimspaces}
89 \usepackage{color}
90 \usepackage[overload]{textcase}
91 \usepackage{scalefnt}
92 \usepackage[colorlinks=true,linkcolor=black,setpagesize=false,urlcolor=black,xetex]{hyperref}
93 \usepackage{fancyhdr}
94 \usepackage[explicit]{titlesec}
95 \usepackage{fnpos}
96 \usepackage{printlen}
97 \usepackage{calc}
98 \pagestyle{plain}
99 % bottom figure below footnotes
100 \makeFNabove
101
102
103 %%%%%%%%%%%%%%%%%%%%%%% Paper size
104 \setlength\baselineskip{7.14pt}
105 \ifcutafivepaper
106   \usepackage[%
107     paperwidth=160mm,%
108     paperheight=225mm,%
109     text={117mm,162mm},% 
110     top=30mm,% 
111     headsep=8mm,%
112     left=23mm,%
113     right=30mm]{geometry}%
114 \else
115   \usepackage[%
116     top=\dimexpr14.5mm+\baselineskip-16pt\relax, % margin will be smaller to accomodate for bigger header (16pt) 
117     headsep=3\baselineskip,
118     headheight=16pt,
119     bottom=26.3mm,%
120     inner=14.5mm,%
121     outer=22.5mm,%
122     textheight=\dimexpr7.14pt*(32*2+1)\relax,%
123     includehead]{geometry}
124 \fi
125
126 %%%%%%%%%%%%%%%%%%%%%%%% Fonts
127
128 \setmainfont[
129 ItalicFont = CrimsonText-Italic,
130 BoldFont = CrimsonText-Bold,
131 BoldItalicFont = CrimsonText-BoldItalic,
132 Ligatures={Common, Contextual},
133 SmallCapsFont = CrimsonText-Roman,
134 SmallCapsFeatures={Letters=SmallCaps},
135 Mapping=tex-text
136 ]{CrimsonText-Roman}
137 \newfontface\sb{CrimsonText-Semibold}
138 \newfontface\intro{Archivo-Black}
139
140 %% For faking small caps You burn in typographic hell.
141 \makeatletter
142 \newlength\fake@f
143 \newlength\fake@c
144 \def\fakesc#1{%
145   \begingroup%
146   \xdef\fake@name{\csname\curr@fontshape/\f@size\endcsname}%
147   \fontsize{\fontdimen8\fake@name}{\baselineskip}\selectfont%
148   \uppercase{#1}%
149   \endgroup%
150 }
151 \makeatother
152
153
154 \renewcommand{\normalsize}{\fontsize{10.4}{14.28}\addfontfeature{LetterSpace=0.3}\selectfont}
155 \setlength{\parindent}{4mm}
156 \setlength{\parskip}{0mm}
157
158 \renewcommand{\large}{\fontsize{14}{14.28}\selectfont} % srodtytul
159 \renewcommand{\small}{\fontsize{8}{14.28}\selectfont} % paginy
160 \renewcommand{\Large}{\fontsize{15}{21.42}\selectfont} % tytuł rozdziału
161 \renewcommand{\huge}{\fontsize{18}{21.6}\selectfont} % wyimek
162 \renewcommand{\Huge}{\fontsize{24}{40}\selectfont} % cover
163 \renewcommand{\footnotesize}{\fontsize{9}{10.74}\selectfont}
164
165
166
167 \definecolor{stoK}{cmyk}{0,0,0,1}
168 \definecolor{theme}{gray}{.3}
169 %\color{stoK}
170
171
172 %%%%%%%%%%%%%%%%%%%%%% Headings.
173 \pagestyle{fancy}
174 \fancyhf{}
175 \renewcommand{\headrulewidth}{0pt}
176 \renewcommand{\footrulewidth}{0pt}
177 \makeatletter
178 %%%%%%%%%% Nagłówek normalny
179 \cfoot{}
180 % this will go to \leftmark
181 \renewcommand{\chaptermark}[1]{\markboth{\MakeUppercase{#1}}{}}
182 \fancyhead[CE]{{\small\MakeUppercase{\@title}}}
183 \fancyhead[CO]{{\small\leftmark}}
184 \fancyhead[LE,RO]{{\small\intro\thepage}}
185 %%%%%%%%%% Nagłówek pierwszej strony rozdziału
186 \fancypagestyle{plain}{%
187 \fancyhf{}
188 \fancyhead[LE,RO]{{\small\intro\thepage}}
189 \renewcommand{\headrulewidth}{0pt}
190 \renewcommand{\footrulewidth}{0pt}}
191 \makeatother
192
193 %%%%%%%%%%%%%%%%%%%%%% Section title styles.
194 %% Sections
195 \titleformat{\chapter}[block]%
196 {\Large\intro\addfontfeature{LetterSpace=0.5,Kerning={Uppercase}}}%
197 {}{0pt}{\parbox{80mm}{\raggedright\MakeUppercase{#1}}}
198 \newlength{\chapterposcorrection}\newlength{\chapterspaceafter}
199 \setlength{\chapterposcorrection}{-\headsep-2\baselineskip}
200 \setlength{\chapterspaceafter}{14\baselineskip-14pt}%\f@size of large
201 \titlespacing*{\chapter}{0pt}{\chapterposcorrection}{\chapterspaceafter}
202
203 %% Subsections
204 \titleformat{\section}%
205 {\addfontfeature{LetterSpace=0.3}\large}%
206 {\thesection}{.5em}{\MakeUppercase{#1}}
207
208 \renewcommand{\thesection}{\Roman{section}}
209
210 \titleformat{\subsection}%
211 {}%
212 {\thesubsection}{0pt}{\fakesc{#1}}
213
214
215 \newcommand{\typosubsubsection}[1]{%
216 {\textsc{#1}}
217 }
218
219 %% XXX delete them
220 \newcommand{\typosubsection}[1]{%
221 {\MakeUppercase{#1}}
222 }
223
224 \newcommand{\typosection}[1]{%
225 {\addfontfeature{FakeStretch=0.96, LetterSpace=-4.0}\emph{\scalefont{2}#1}}
226 %{\addfontfeature{Scale=2.0, FakeStretch=0.98, LetterSpace=-2.0}\emph{#1}}
227 }
228 %%%%%%%%%%%%%%%%%% ^^
229
230 %%%%% Footnotes %%%%%%%%
231 \newlength{\footnoteindent}\newlength{\footnoteprespace}
232 \setlength{\footnoteindent}{6mm}%{3.5mm}
233 \setlength{\footnoteprespace}{.3em}
234 \makeatletter
235
236 \renewcommand\@makefnmark{%
237 \hspace{\footnoteprespace}\hbox{{\normalfont \@thefnmark}}%
238 }
239 \renewcommand\thefootnote{[\arabic{footnote}]}
240
241 \long\def\@makefntext#1{%
242 \setlength{\leftskip}{\footnoteindent}%
243 \setlength{\hskip}{-\footnoteindent-\footnoteprespace-.1em}%
244 \hb@xt@ \dimexpr\footnoteindent+\footnoteprespace%
245 {\@makefnmark}#1
246 %  \parindent 1em\noindent \hb@xt@ 1.8em{\hss \@makefnmark \enskip}#1
247 }
248
249 \def\trimspace#1{\trim@spaces{#1}}
250
251 \makeatother
252
253
254 \clubpenalty=100000
255 \widowpenalty=100000
256
257
258 % see http://osdir.com/ml/tex.xetex/2005-10/msg00003.html
259 \newsavebox{\ximagebox}\newlength{\ximageheight}
260 \newsavebox{\xglyphbox}\newlength{\xglyphheight}
261 \newcommand{\xbox}[1]
262 {\savebox{\ximagebox}{#1}\settoheight{\ximageheight}{\usebox {\ximagebox}}%
263 \savebox{\xglyphbox}{\char32}\settoheight{\xglyphheight}{\usebox {\xglyphbox}}%
264 \raisebox{\ximageheight}[0pt][0pt]{%\raisebox{-\xglyphheight}[0pt] [0pt]{%
265 \makebox[0pt][l]{\usebox{\xglyphbox}}}%}%
266 \usebox{\ximagebox}%
267 \raisebox{0pt}[0pt][0pt]{\makebox[0pt][r]{\usebox{\xglyphbox}}}}
268
269
270 \newcommand{\makecover}{
271
272   %\pdfpagewidth=#1
273   %\pdfpageheight=#2
274
275   \thispagestyle{empty}
276   \newlength{\PictHOffset}
277   \newlength{\PictVOffset}
278   \setlength{\PictHOffset}{1in}
279   \addtolength{\PictHOffset}{\hoffset}
280   \addtolength{\PictHOffset}{\oddsidemargin}
281
282   \setlength{\PictVOffset}{1in}
283   \addtolength{\PictVOffset}{\voffset}
284   \addtolength{\PictVOffset}{\topmargin}
285   \addtolength{\PictVOffset}{\headheight}
286   \addtolength{\PictVOffset}{\headsep}
287   \addtolength{\PictVOffset}{\topskip}
288
289   \addtolength{\PictVOffset}{-\paperheight}
290
291   \noindent\hspace*{-\PictHOffset}%
292   \raisebox{\PictVOffset}[0pt][0pt]{\makebox[0pt][l]{%
293       \includegraphics[height=\paperheight,width=\paperwidth]{cover.jpg}}}
294   \newpage
295   %\vspace{\paperheight}
296
297
298   \thispagestyle{empty}
299   \begin{center}
300   \intro
301   {
302     \begin{spacing}{1.4}
303     \Huge \noindent \thetitle
304     \end{spacing}
305   }
306   \end{center}
307
308   \vspace{2em}
309   
310   \begin{center}
311     \intro
312     {
313     \huge \noindent \theauthor
314     }
315   \end{center}
316                   %\emph{\thankyou}\\
317                   %\indent\emph{You made this book possible.}
318   \vspace{16em}
319
320   \begin{center}
321     \includegraphics[scale=.2]{logo.eps}
322   \end{center}
323
324   \newpage
325   \thispagestyle{empty}
326
327   \input{editorial}
328
329   
330   }
331
332
333
334 \renewcommand{\maketitle}{
335     {
336     \thispagestyle{empty}
337     \footnotesize
338     \color{theme}
339     \noindent \rule{\linewidth}{0.4pt}
340
341     \vspace{.6em}
342     \color{black}
343     }
344 }
345
346
347 \newcommand{\editorialsection}{
348
349 }
350
351
352
353 \newcommand{\tytul}[1]{%
354 #1%
355 \vspace{1em}%
356 }
357
358 \newcommand{\nazwapodutworu}[1]{%
359 \section*{#1}%
360 }
361
362 \newcommand{\autorutworu}[1]{%
363 #1
364 %\subsection*{\typosubsection{#1}}%
365 }
366
367 \newcommand{\dzielonadrzedne}[1]{%
368 \subsection*{#1}%
369 }
370
371 \newcommand{\nazwautworu}[1]{%
372 \section*{#1}%
373 }
374
375 \newcommand{\podtytul}[1]{%
376 \subsection*{\typosubsubsection{#1}}%
377 }
378
379 \newcommand{\podtytulpodutworu}[1]{%
380 \subsection*{\typosubsubsection{#1}}%
381 }
382
383 \newcommand{\translator}[1]{%
384 \subsection*{\typosubsubsection{tłum. #1}}%
385 }
386 \newcommand{\translatorsline}[1]{%
387 #1
388 }
389
390 \newcommand{\powiesc}[1]{#1}
391 \newcommand{\opowiadanie}[1]{#1}
392 \newcommand{\lirykal}[1]{#1}
393 \newcommand{\lirykalp}[1]{#1}
394 \newcommand{\dramatwierszowanyl}[1]{#1}
395 \newcommand{\dramatwierszowanylp}[1]{#1}
396 \newcommand{\dramatwspolczesny}[1]{#1}
397
398 \newcommand{\nota}[1]{%
399 \begin{em}%
400 \begin{flushright}%
401 #1%
402 \end{flushright}%
403 \end{em}%
404 }
405
406 \newcommand{\dedykacja}[1]{%
407 \begin{em}%
408 \begin{flushright}%
409 #1%
410 \end{flushright}%
411 \end{em}%
412 }
413
414 \newcommand{\dlugicytat}[1]{%
415 \begin{quotation}%
416 #1%
417 \end{quotation}%
418 }
419
420 \newcommand{\poezjacyt}[1]{%
421 \begin{verse}%
422 #1%
423 \end{verse}%
424 }
425 \newcommand{\motto}[1]{%
426 \begin{em}%
427 #1%
428 \end{em}%
429 }
430 \newcommand{\listaosob}[2]{%
431 \par{#1}%
432 \begin{itemize}%
433 #2%
434 \end{itemize}%
435 }
436
437 \newcommand{\nagloweklisty}[1]{%
438 \typosubsubsection{#1}%
439 }
440
441 \newcommand{\listaosoba}[1]{%
442 \item{#1}%
443 }
444
445 \newcommand{\kwestia}[1]{%
446 \par{#1}%
447 }
448
449 \newcommand{\naglowekakt}[1]{%
450 \pagebreak
451 \subsection*{\typosubsection{#1}}%
452 }
453 \newcommand{\naglowekczesc}[1]{%
454 \pagebreak
455 \part{#1}%
456 }
457 \newcommand{\srodtytul}[1]{%
458 \subsection*{\typosubsection{#1}}%
459 }
460
461 \newcommand{\naglowekscena}[1]{%
462 \subsubsection*{\typosubsubsection{#1}}%
463 }
464
465 \newcommand{\theautorrozdzialu}{}
466
467 \newcommand{\autorrozdzialu}[1]{%
468 \renewcommand{\theautorrozdzialu}{\newline\newline#1}
469 }
470
471 \newcommand{\naglowekrozdzial}[1]{%
472 \chapter{#1\theautorrozdzialu{}}\renewcommand{\theautorrozdzialu}{}%
473 }
474
475 \newcommand{\naglowekosoba}[1]{%
476 \par{\textsc{#1}}\nopagebreak%
477 }
478 \newcommand{\naglowekpodrozdzial}[1]{%
479 \section{#1}\nopagebreak%
480 }
481
482 \newcommand{\miejsceczas}[1]{%
483 \par{\emph{#1}}%
484 }
485 \newcommand{\didaskalia}[1]{%
486 \par{\emph{#1}}%
487 }
488
489 \newcommand{\akap}[1]{%
490 \par{#1}%
491 }
492 \newcommand{\akapdialog}[1]{%
493 \par{#1}%
494 }
495 \newcommand{\akapcd}[1]{%
496 \par{#1}%
497 }
498
499 \newcommand{\mottopodpis}[1]{%
500 \begin{em}%
501 \begin{flushright}%
502 #1%
503 \end{flushright}%
504 \end{em}%
505 }
506
507 \newcommand{\strofa}[1]{%
508 \par{\noindent{\ignorespaces#1\vspace{1em}}}%
509 }
510
511 \newcommand{\wers}[1]{#1}
512
513 \newcommand{\wersakap}[1]{%
514 \hspace*{1em}#1%
515 }
516 \newcommand{\werscd}[1]{%
517 \hspace*{8em}#1%
518 }
519 \newcommand{\werswciety}[2][1em]{%
520 \hspace*{#1}#2%
521 }
522
523 \ifshowfootnotes
524   \newcommand{\pa}[1]{\NoCaseChange{\footnote{#1 [przypis autorski]}}}
525   \newcommand{\pe}[1]{\NoCaseChange{\footnote{#1}}}
526   \newcommand{\pr}[1]{\NoCaseChange{\footnote{#1}}}
527   \newcommand{\pt}[1]{\NoCaseChange{\footnote{#1}}}
528 \else
529   \newcommand{\pa}[1]{}
530   \newcommand{\pe}[1]{}
531   \newcommand{\pr}[1]{}
532   \newcommand{\pt}[1]{}
533 \fi
534
535 \newcommand{\mat}[1]{$#1$}
536
537 \newcommand{\didasktekst}[1]{%
538 \emph{#1}%
539 }
540 \newcommand{\slowoobce}[1]{%
541 \emph{#1}%
542 }
543 \newcommand{\tytuldziela}[1]{%
544 \emph{#1}%
545 }
546 \newcommand{\wyroznienie}[1]{%
547 \emph{#1}%
548 }
549
550 \newcommand{\osoba}[1]{%
551 #1%
552 }
553
554 \newcommand{\sekcjaswiatlo}{%
555 \vspace{30pt}%
556 }
557
558 \newcommand{\sekcjaasterysk}{%
559 \vspace{10pt}%
560 \begin{center}%
561 \par{*}%
562 \end{center}%
563 }
564
565 \newcommand{\separatorlinia}{%
566 \vspace{10pt}%
567 \hrule{}%
568 \vspace{10pt}%
569 }
570
571 \newcommand{\ilustr}[2]{
572   \vspace{1em}%
573   \begin{center}%
574     \par{\includegraphics[width=\textwidth]{\trimspace{#1}}\\#2}%
575   \end{center}%
576   \vspace{1em}%
577 }
578
579
580 \newcommand{\motyw}[2][0]{%
581 \ifshowthemes
582 \mbox{}%
583 \marginpar{%
584 \vspace{-8pt}%
585 \vspace{-#1\baselineskip}%
586 \raggedright{\hspace{0pt}%
587 \footnotesize{\color{theme}{#2}}}%
588 \vspace{\baselineskip}%
589 }%
590 \fi
591 }
592
593 \newcommand{\lista}[1]{%
594 \begin{compactitem}
595 #1
596 \end{compactitem}
597 }
598
599 \newcommand{\punkt}[1]{%
600 \item #1
601 }
602 \newcommand{\link}[2]{\href{#1}{\uline{#2}\footnote{#1}}}
603
604 \newcommand{\www}[1]{\url{#1}}
605