mobile publication
[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 \RequirePackage{xifthen}
23 %\DeclareOption{13pt}{%
24 %\AtEndOfClass{%
25 % font size definitions, similar to ones in /usr/share/texmf-texlive/tex/latex/base/
26 %% \renewcommand\normalsize{%
27 %%    \@setfontsize\normalsize{13pt}{14.5pt}%
28 %%    \abovedisplayskip 12\p@ \@plus3\p@ \@minus7\p@
29 %%    \abovedisplayshortskip \z@ \@plus3\p@
30 %%    \belowdisplayshortskip 6.5\p@ \@plus3.5\p@ \@minus3\p@
31 %%    \belowdisplayskip \abovedisplayskip
32 %%    \let\@listi\@listI}\normalsize%
33 %% \renewcommand\footnotesize{%
34 %%    \@setfontsize\footnotesize\@xpt\@xiipt
35 %%    \abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@
36 %%    \abovedisplayshortskip \z@ \@plus3\p@
37 %%    \belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@
38 %%    \def\@listi{\leftmargin\leftmargini
39 %%                \topsep 6\p@ \@plus2\p@ \@minus2\p@
40 %%                \parsep 3\p@ \@plus2\p@ \@minus\p@
41 %%                \itemsep \parsep}%
42 %%    \belowdisplayskip \abovedisplayskip
43 %}%
44 %}%
45 %}
46
47 %% \DeclareOption{14pt}{\renewcommand{\normalsize}{\AtEndOfClass{\fontsize{14}{17}\selectfont}}}
48
49 \DeclareOption{defaultleading}{}
50 \DeclareOption{doubleleading}{\AtBeginDocument{\doublespacing}}%\setlength{\leading}{1em plus 0.5ex minus 0.2ex}}
51 \DeclareOption{onehalfleading}{\AtBeginDocument{\onehalfspacing}}%\setlength{\leading}{1em plus 0.5ex minus 0.2ex}}
52
53 %% 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.
54 \DeclareOption{a5paper}{%
55       \setlength{\paperheight}{210mm}%
56       \setlength{\paperwidth}{148mm}}
57 % a5paper dropped down size
58 \newif\ifcutafivepaper \cutafivepaperfalse
59 \DeclareOption{a5paperdd}{%
60   \setlength{\paperheight}{225mm}%
61   \setlength{\paperwidth}{160mm}%
62   \cutafivepapertrue
63 }
64
65 \newif\ifshowfootnotes \showfootnotestrue
66 \DeclareOption{nofootnotes}{\showfootnotesfalse}
67
68 \newif\ifshowthemes \showthemestrue
69 \DeclareOption{nothemes}{\showthemesfalse}
70
71 \newif\ifenablewlfont \enablewlfonttrue
72 \DeclareOption{nowlfont}{\enablewlfontfalse}
73
74
75 \DeclareOption*{\PassOptionsToClass{\CurrentOption}{extbook}}
76 \ProcessOptions\relax
77 \LoadClass{extbook}
78 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
79
80 \usepackage{trace}
81 \usepackage{caption}
82 \usepackage{tabularx}
83 \usepackage[MeX]{polski}
84 \usepackage{icomma}
85 \usepackage[xetex]{graphicx}
86 \usepackage{fontspec}
87 \usepackage{xunicode}
88 \usepackage{xltxtra}
89 \usepackage{trimspaces}
90 \usepackage{color}
91 \usepackage[overload]{textcase}
92 \usepackage{scalefnt}
93 \usepackage[colorlinks=true,linkcolor=black,setpagesize=false,urlcolor=black,xetex]{hyperref}
94 \usepackage{fancyhdr}
95 \usepackage[explicit]{titlesec}
96 \usepackage{fnpos}
97 \usepackage{printlen}
98 \usepackage{calc}
99 \pagestyle{plain}
100 % bottom figure below footnotes
101 \makeFNabove
102
103
104 %%%%%%%%%%%%%%%%%%%%%%% Paper size
105 \setlength\baselineskip{7.14pt}
106 \ifcutafivepaper
107   \usepackage[%
108     paperwidth=160mm,%
109     paperheight=225mm,%
110     text={117mm,162mm},% 
111     top=30mm,% 
112     headsep=8mm,%
113     left=23mm,%
114     right=30mm]{geometry}%
115 \else
116   \usepackage[%
117     top=\dimexpr14.5mm+\baselineskip-16pt\relax, % margin will be smaller to accomodate for bigger header (16pt) 
118     headsep=3\baselineskip,
119     headheight=16pt,
120     bottom=26.3mm,%
121     inner=14.5mm,%
122     outer=22.5mm,%
123     textheight=\dimexpr7.14pt*(32*2+1)\relax,%
124     includehead]{geometry}
125 \fi
126
127 %%%%%%%%%%%%%%%%%%%%%%%% Fonts
128
129 \setmainfont[
130 ItalicFont = CrimsonText-Italic,
131 BoldFont = CrimsonText-Bold,
132 BoldItalicFont = CrimsonText-BoldItalic,
133 Ligatures={Common, Contextual},
134 SmallCapsFont = CrimsonText-Roman,
135 SmallCapsFeatures={Letters=SmallCaps},
136 Mapping=tex-text
137 ]{CrimsonText-Roman}
138 \newfontface\sb{CrimsonText-Semibold}
139 \newfontface\intro{Archivo-Black}
140
141 %% For faking small caps You burn in typographic hell.
142 \makeatletter
143 \newlength\fake@f
144 \newlength\fake@c
145 \def\fakesc#1{%
146   \begingroup%
147   \xdef\fake@name{\csname\curr@fontshape/\f@size\endcsname}%
148   \fontsize{\fontdimen8\fake@name}{\baselineskip}\selectfont%
149   \uppercase{#1}%
150   \endgroup%
151 }
152 \makeatother
153
154 \setlength{\parindent}{4mm}
155 \setlength{\parskip}{0mm}
156
157 \renewcommand{\normalsize}{\fontsize{10.4}{14.28}\addfontfeature{LetterSpace=0.3}\selectfont}
158 \renewcommand{\large}{\fontsize{14}{14.28}\addfontfeature{LetterSpace=0.3}\selectfont} % srodtytul
159 \renewcommand{\small}{\fontsize{8}{14.28}\addfontfeature{LetterSpace=0.5}\selectfont} % paginy
160 \renewcommand{\Large}{\fontsize{15}{21.42}\addfontfeature{LetterSpace=0.1}\selectfont} % tytuł rozdziału
161 \renewcommand{\huge}{\fontsize{18}{21.6}\addfontfeature{LetterSpace=0.1}\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 %% Chapters
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 %% Sections
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}[2]{
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
295   
296   }
297
298
299
300 \renewcommand{\maketitle}{
301   \newpage
302   %\vspace{\paperheight}
303
304   \thispagestyle{empty}
305   \begin{center}
306   \intro
307   {
308     \begin{spacing}{1.4}
309     \Huge \noindent \thetitle
310     \end{spacing}
311   }
312   \end{center}
313
314   \vspace{2em}
315   
316   \begin{center}
317     \intro
318     {
319     \huge \noindent \theauthor
320     }
321   \end{center}
322                   %\emph{\thankyou}\\
323                   %\indent\emph{You made this book possible.}
324   \vspace{16em}
325
326   \begin{center}
327     \includegraphics[scale=.2]{logo.eps}
328   \end{center}
329
330 }
331
332
333 \newcommand{\editorialsection}{
334   \newpage
335   \thispagestyle{empty}
336 }
337
338 \renewcommand*\contentsname{Table of Contents}
339 \newcommand{\spistresci}{
340 {
341   \intro
342   \setcounter{tocdepth}{0}
343   \tableofcontents
344   \newpage
345 }
346 }
347
348
349
350
351 \newcommand{\tytul}[1]{%
352 #1%
353 \vspace{1em}%
354 }
355
356 \newcommand{\nazwapodutworu}[1]{%
357 \section*{#1}%
358 }
359
360 \newcommand{\autorutworu}[1]{%
361 #1
362 %\subsection*{\typosubsection{#1}}%
363 }
364
365 \newcommand{\dzielonadrzedne}[1]{%
366 \subsection*{#1}%
367 }
368
369 \newcommand{\nazwautworu}[1]{%
370 \section*{#1}%
371 }
372
373 \newcommand{\podtytul}[1]{%
374 \subsection*{\typosubsubsection{#1}}%
375 }
376
377 \newcommand{\podtytulpodutworu}[1]{%
378 \subsection*{\typosubsubsection{#1}}%
379 }
380
381 \newcommand{\translator}[1]{%
382 \subsection*{\typosubsubsection{tłum. #1}}%
383 }
384 \newcommand{\translatorsline}[1]{%
385 #1
386 }
387
388 \newcommand{\powiesc}[1]{#1}
389 \newcommand{\opowiadanie}[1]{#1}
390 \newcommand{\lirykal}[1]{#1}
391 \newcommand{\lirykalp}[1]{#1}
392 \newcommand{\dramatwierszowanyl}[1]{#1}
393 \newcommand{\dramatwierszowanylp}[1]{#1}
394 \newcommand{\dramatwspolczesny}[1]{#1}
395
396 \newcommand{\nota}[1]{%
397 \begin{em}%
398 \begin{flushright}%
399 #1%
400 \end{flushright}%
401 \end{em}%
402 }
403
404 \newcommand{\dedykacja}[1]{%
405 \begin{em}%
406 \begin{flushright}%
407 #1%
408 \end{flushright}%
409 \end{em}%
410 }
411
412 \newcommand{\dlugicytat}[1]{%
413 \begin{quotation}%
414 #1%
415 \end{quotation}%
416 }
417
418 \newcommand{\poezjacyt}[1]{%
419 \begin{verse}%
420 #1%
421 \end{verse}%
422 }
423 \newcommand{\motto}[1]{%
424 \begin{em}%
425 #1%
426 \end{em}%
427 }
428 \newcommand{\listaosob}[2]{%
429 \par{#1}%
430 \begin{itemize}%
431 #2%
432 \end{itemize}%
433 }
434
435 \newcommand{\nagloweklisty}[1]{%
436 \typosubsubsection{#1}%
437 }
438
439 \newcommand{\listaosoba}[1]{%
440 \item{#1}%
441 }
442
443 \newcommand{\kwestia}[1]{%
444 \par{#1}%
445 }
446
447 \newcommand{\naglowekakt}[1]{%
448 \pagebreak
449 \subsection*{\typosubsection{#1}}%
450 }
451 \newcommand{\naglowekczesc}[1]{%
452 \pagebreak
453 \part{#1}%
454 }
455 \newcommand{\srodtytul}[1]{%
456 \subsection*{\typosubsection{#1}}%
457 }
458
459 \newcommand{\naglowekscena}[1]{%
460 \subsubsection*{\typosubsubsection{#1}}%
461 }
462
463 \newcommand{\theautorrozdzialu}{}
464
465 \newcommand{\autorrozdzialu}[1]{%
466 \renewcommand{\theautorrozdzialu}{\newline\newline#1}
467 }
468
469 \newcommand{\naglowekrozdzial}[1]{%
470 \chapter[#1]{#1\theautorrozdzialu{}}\renewcommand{\theautorrozdzialu}{}%
471 }
472
473 \newcommand{\naglowekosoba}[1]{%
474 \par{\textsc{#1}}\nopagebreak%
475 }
476 \newcommand{\naglowekpodrozdzial}[1]{%
477 \section{#1}\nopagebreak%
478 }
479
480 \newcommand{\miejsceczas}[1]{%
481 \par{\emph{#1}}%
482 }
483 \newcommand{\didaskalia}[1]{%
484 \par{\emph{#1}}%
485 }
486
487 \newcommand{\akap}[1]{%
488 \par{#1}%
489 }
490 \newcommand{\akapdialog}[1]{%
491 \par{#1}%
492 }
493 \newcommand{\akapcd}[1]{%
494 \par{#1}%
495 }
496
497 \newcommand{\mottopodpis}[1]{%
498 \begin{em}%
499 \begin{flushright}%
500 #1%
501 \end{flushright}%
502 \end{em}%
503 }
504
505 \newcommand{\strofa}[1]{%
506 \par{\noindent{\ignorespaces#1\vspace{1em}}}%
507 }
508
509 \newcommand{\wers}[1]{#1}
510
511 \newcommand{\wersakap}[1]{%
512 \hspace*{1em}#1%
513 }
514 \newcommand{\werscd}[1]{%
515 \hspace*{8em}#1%
516 }
517 \newcommand{\werswciety}[2][1em]{%
518 \hspace*{#1}#2%
519 }
520
521 \ifshowfootnotes
522   \newcommand{\pa}[1]{\NoCaseChange{\footnote{#1 [przypis autorski]}}}
523   \newcommand{\pe}[1]{\NoCaseChange{\footnote{#1}}}
524   \newcommand{\pr}[1]{\NoCaseChange{\footnote{#1}}}
525   \newcommand{\pt}[1]{\NoCaseChange{\footnote{#1}}}
526 \else
527   \newcommand{\pa}[1]{}
528   \newcommand{\pe}[1]{}
529   \newcommand{\pr}[1]{}
530   \newcommand{\pt}[1]{}
531 \fi
532
533 \newcommand{\mat}[1]{$#1$}
534
535 \newcommand{\didasktekst}[1]{%
536 \emph{#1}%
537 }
538 \newcommand{\slowoobce}[1]{%
539 \emph{#1}%
540 }
541 \newcommand{\tytuldziela}[1]{%
542 \emph{#1}%
543 }
544 \newcommand{\wyroznienie}[1]{%
545 \emph{#1}%
546 }
547
548 \newcommand{\osoba}[1]{%
549 #1%
550 }
551
552 \newcommand{\sekcjaswiatlo}{%
553 \vspace{30pt}%
554 }
555
556 \newcommand{\sekcjaasterysk}{%
557 \vspace{10pt}%
558 \begin{center}%
559 \par{*}%
560 \end{center}%
561 }
562
563 \newcommand{\separatorlinia}{%
564 \vspace{10pt}%
565 \hrule{}%
566 \vspace{10pt}%
567 }
568
569 \newcommand{\ilustrscale}[0]{1}
570 \newcommand{\setilustrscale}[1]{\renewcomand{\ilustrscale}{#1}}
571
572 \newcommand{\ilustr}[3][]{
573   \vspace{2\baselineskip}%
574   \begin{center}%
575     \ifthenelse{\isempty{#1}}%
576     {\par{\includegraphics{\trimspace{#2}}\\#3}}%
577     {\par{\includegraphics[#1]{\trimspace{#2}}\\#3}}%
578   \end{center}%
579   \vspace{2\baselineskip}%
580 }
581
582
583 \newcommand{\motyw}[2][0]{%
584 \ifshowthemes
585 \mbox{}%
586 \marginpar{%
587 \vspace{-8pt}%
588 \vspace{-#1\baselineskip}%
589 \raggedright{\hspace{0pt}%
590 \footnotesize{\color{theme}{#2}}}%
591 \vspace{\baselineskip}%
592 }%
593 \fi
594 }
595
596 \newcommand{\lista}[1]{%
597 \begin{compactitem}
598 #1
599 \end{compactitem}
600 }
601
602 \newcommand{\punkt}[1]{%
603 \item #1
604 }
605 \newcommand{\link}[2]{\href{#1}{\uline{#2}\footnote{#1}}}
606
607 \newcommand{\www}[1]{{\normalfont\small\url{#1}}}
608