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