7806be1a7484825e760b2621d3d0d8da7da605ce
[librarian.git] / librarian / pdf / fnprep.cls
1 % -*- coding: utf-8 -*-
2 \NeedsTeXFormat{LaTeX2e}
3 \ProvidesClass{fnprep}[2011/11/28 Modern Poland Foundation Report style]
4
5
6 %\RequirePackage{geometry}
7 \RequirePackage{setspace}
8 \RequirePackage{type1cm}
9 \RequirePackage{amssymb}
10 \RequirePackage{amsmath}
11 \RequirePackage{paralist}
12 \RequirePackage[normalem]{ulem}
13 \RequirePackage{xifthen}
14 \RequirePackage{environ} % environments with \BODY, for wyimek
15
16
17 \DeclareOption*{\PassOptionsToClass{\CurrentOption}{report}}
18 \ProcessOptions\relax
19 \LoadClass{report}
20 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21
22 \usepackage{multicol}
23 \usepackage{trace}
24 \usepackage{caption}
25 \usepackage{tabularx}
26 \usepackage[MeX]{polski}
27 \usepackage{icomma}
28 \usepackage[xetex]{graphicx}
29 \usepackage[silent]{fontspec} % silent - no warnings, quiet - warn only to log
30 \usepackage{xunicode}
31 \usepackage{xltxtra}
32 %\usepackage{trimspaces} % imported by something else?
33 \usepackage{xcolor}
34 \usepackage[overload]{textcase}
35 \usepackage{scalefnt}
36 \usepackage[colorlinks=true,linkcolor=black,setpagesize=false,urlcolor=black,xetex,linktocpage]{hyperref}
37 %\usepackage{hyperref}
38 \usepackage{fancyhdr}
39 \usepackage{endnotes}
40 %\usepackage{fnpos}
41 \usepackage{printlen}
42 \usepackage{calc}
43 \usepackage[stable]{footmisc}
44
45 %http://tex.stackexchange.com/questions/40510/set-first-paragraph-no-indentation-after-re-definition-of-section#40512
46
47 \usepackage{chngcntr}
48 \counterwithout{footnote}{chapter}
49
50 \usepackage[explicit]{titlesec}
51 \usepackage{microtype}
52
53 \usepackage[landscape]{geometry}
54
55
56
57 %%% Hyphenation opts:
58 %\pretolerance=10000
59 \tolerance=2600
60 \emergencystretch=30pt
61
62
63
64
65 %%%%%%%%%%%%%%%%%%%%%%% Paper size
66 %\setlength\baselineskip{7.14pt}
67 %% \ifcutafivepaper
68 %%   \usepackage[%
69 %%     paperwidth=160mm,%
70 %%     paperheight=225mm,%
71 %%     text={117mm,162mm},%
72 %%     top=30mm,%
73 %%     headsep=8mm,%
74 %%     left=23mm,%
75 %%     right=30mm]{geometry}%
76 %% \else
77 %%   \usepackage[%
78 %%     top=\dimexpr14.5mm+\baselineskip-16pt\relax, % margin will be smaller to accomodate for bigger header (16pt)
79 %%     headsep=3\baselineskip,
80 %%     headheight=16pt,
81 %%     bottom=26.3mm,%
82 %%     inner=14.5mm,%
83 %%     outer=22.5mm,%
84 %%     textheight=\dimexpr7.14pt*(32*2+1)\relax,%
85 %%     includehead]{geometry}
86 %% \fi
87
88 %%%%%%%%%%%%%%%%%%%%%%%% Fonts
89
90 \setmainfont[
91 ItalicFont = Lato-Italic,
92 BoldFont = Lato-Bold,
93 BoldItalicFont = Lato-BoldItalic,
94 Ligatures={Common, Contextual},
95 SmallCapsFont = Lato-Regular,
96 SmallCapsFeatures={Letters=SmallCaps},
97 Mapping=tex-text
98 ]{Lato-Regular}
99 \newfontface\headfont{LeagueGothic-Regular}
100
101
102 \setlength{\parindent}{3mm}
103 \setlength{\parskip}{0mm}
104
105 % \normalsize – normalny tekst 
106 % \large - normalny tekst headingowy (nie wiem czy jest inny niz normalsize?)
107 % \Large - troche większy tekst headingowy (spis treści)
108 % \huge - pagina tytuł rozdziału
109 % \Huge - naglowek na szarym tle
110
111 %% \renewcommand{\normalsize}{\fontsize{10.4}{14.28}\addfontfeature{LetterSpace=3.0}\selectfont}
112 %% \renewcommand{\large}{\fontsize{14}{14.28}\addfontfeature{LetterSpace=3.0,Letters=Uppercase}\selectfont} % srodtytul
113 %% \renewcommand{\small}{\fontsize{8}{14.28}\addfontfeature{LetterSpace=5.0}\selectfont} % paginy
114 %% \renewcommand{\Large}{\fontsize{15}{21.42}\addfontfeature{LetterSpace=0.0}\selectfont} % tytuł rozdziału
115 %% \renewcommand{\huge}{\fontsize{18}{28.56}\addfontfeature{LetterSpace=1.0}\selectfont} % wyimek
116 %% \renewcommand{\Huge}{\fontsize{24}{40}\selectfont} % cover
117 %% \renewcommand{\footnotesize}{\addfontfeature{LetterSpace=1.0}\fontsize{9}{10.74}\selectfont}
118
119
120
121 % • • • • • • • • • COLORS • •
122 \definecolor{stoK}{cmyk}{0,0,0,1}
123 \definecolor{theme}{gray}{.3}
124 \definecolor{headcolor}{HTML}{EA5F21}
125 \definecolor{graybg}{HTML}{737372}
126 %\color{stoK}
127
128 % • • • • • • • • METADATA • •
129
130 \makeatletter
131 \newcommand{\@address}{}
132 \newcommand{\address}[1]{\renewcommand{\@address}{#1}}
133 \makeatother
134
135 % • • • • • • • • HEADINGS • •
136 %% this will go to \leftmark
137
138 \makeatletter
139 \pagestyle{fancy}
140 \fancyhf{}
141 \renewcommand{\chaptermark}[1]{\markboth{\MakeTextUppercase{#1}}{}}
142 % on the odd right : chapter title
143 \fancyhead[LE,RO]{{\color{headcolor}\headfont\huge\leftmark}}
144 \fancyfoot[LE,RO]{{\headfont\Large\thepage}}
145 \fancyfoot[LO]{{\headfont\normalfont\MakeTextUppercase{\@title}}}
146 \fancyfoot[RE]{{\headfont\normalfont\MakeTextUppercase{\@address}}}
147
148 \renewcommand{\headrulewidth}{0pt}
149 \renewcommand{\footrulewidth}{0pt}
150 \makeatother
151
152 %%%%%%%%%% Nagłówek pierwszej strony rozdziału
153 \makeatletter
154 \fancypagestyle{plain}{%
155 \fancyhf{}
156 \fancyfoot[LE,RO]{{\headfont\Large\thepage}}
157 \fancyfoot[LO]{{\headfont\normalfont\MakeTextUppercase{\@title}}}
158 }
159 \makeatother
160
161 % • • • • • • • • TITLES • • •
162 % no chapter numbers and no ``Rozdział'' word
163 %\renewcommand{\thechapter}{}
164 %\renewcommand{\chaptername}{}
165
166 % • chapter •
167 \makeatletter\newenvironment{chaptertitlebox}{%
168    \begin{lrbox}{\@tempboxa}\begin{minipage}[t][\dimexpr\textheight-0.5cm\relax]{\dimexpr\linewidth-0.5\columnsep\relax}}{\end{minipage}\end{lrbox}%
169    \colorbox{graybg}{\raisebox{1cm}{\usebox{\@tempboxa}}}
170 }\makeatother
171
172 \titleformat{\chapter}[block]%
173 {\begin{chaptertitlebox}}%
174 {}{0pt}%
175 {:E #1}%
176 [\end{chaptertitlebox}]
177
178 \titlespacing*{\chapter}{0pt}{0pt}{0pt}
179
180
181 % • section •
182 \titleformat{\section}[runin]%
183 {\large\headfont}%
184 {}{0pt}{\makebox[\linewidth][l]{\color{headcolor}\raggedright{}#1}%
185 % this is just to make the spacing between section and following
186 % text right (newlines produce strange amount of space
187 \\\makebox[\linewidth][l]{~}}%
188
189 %\titlespacing*{\section}{0pt}{0pt}{2\baselineskip}
190
191
192 %% \titleformat{\chapter}[block]%
193 %% {\Large\intro\addfontfeature{LetterSpace=0.5,Kerning={Uppercase}}}%
194 %% {}{0pt}{\parbox{80mm}{\raggedright#1}}
195 %% \newlength{\chapterposcorrection}\newlength{\chapterspaceafter}
196 %% \setlength{\chapterposcorrection}{-\headsep-2\baselineskip-2.352mm} % 2.352 is a measured correction:
197 %% \setlength{\chapterspaceafter}{14\baselineskip-14pt+2.352mm}%\f@size of large
198 %% \titlespacing*{\chapter}{0pt}{\chapterposcorrection}{\chapterspaceafter}
199
200 %% %% Sections
201 %% \titleformat{\section}%
202 %% {\addfontfeature{LetterSpace=0.3}\large}%
203 %% {\thesection{}.}{.5em}{\MakeTextUppercase{#1}}
204 %% \renewcommand{\thesection}{\Roman{section}}
205 %% \titlespacing*{\section}{0pt}{\baselineskip}{0em}
206
207 %% \titleformat{\subsection}[block]%
208 %% {}%
209 %% {\thesubsection{}.}{.5em}{\MakeTextUppercase{#1}.}[]
210
211 %% \renewcommand{\thesubsection}{\Alph{subsection}}
212 %% \titlespacing*{\subsection}{0pt}{\baselineskip}{0em}
213
214 %% \newcommand{\typosubsubsection}[1]{%
215 %% {\textsc{#1}}
216 %% }
217
218
219 %%%%% Footnotes (works with footmisc) %%%%%%%%
220 \newlength{\footnoteindent}\newlength{\footnoteprespace}
221 \setlength{\footnoteindent}{8mm}%{3.5mm}
222 \setlength{\footnoteprespace}{0em}
223 \makeatletter
224
225 \renewcommand\@makefnmark{%
226 \hspace{\footnoteprespace}
227 \hbox{{\normalfont \@thefnmark}}%
228 }
229 \renewcommand\thefootnote{[\arabic{footnote}]}
230
231 \setlength{\footnotemargin}{-\footnoteindent-\footnoteprespace-.3em}
232 \renewcommand\footnotelayout[1]{%
233   \setlength{\leftskip}{\footnoteindent}#1}
234
235 %% \long\def\@makefntext#1{%
236 %% \setlength{\leftskip}{\footnoteindent}%
237 %% \setlength{\hskip}{-\footnoteindent-\footnoteprespace-.1em}%
238 %% \hb@xt@ \dimexpr\footnoteindent+\footnoteprespace%
239 %% {\@makefnmark}#1
240 %% %  \parindent 1em\noindent \hb@xt@ 1.8em{\hss \@makefnmark \enskip}#1
241 %% }
242
243 %%%%% Endnotes
244 \newlength{\myendnoteprespace}\setlength{\myendnoteprespace}{.5em}
245 \newlength{\myendnoteindent}\setlength{\myendnoteindent}{14mm+.5em}
246
247 \renewcommand\theendnote{[\roman{endnote}]}
248 \renewcommand\makeenmark{\hspace{\myendnoteprespace}\theenmark}
249 \renewcommand{\notesname}{}
250 \newcommand{\authornotes}{
251 %  \newpage
252     \cleardoublepage
253     \chapter{Przypisy autora}
254     \setlength{\parindent}{0pt}
255     \def\enotesize{\normalsize}
256     \theendnotes
257 }
258 %% \newcommand{\@makeentext}[1]{%
259 %% \noindent\theenmark\hspace{\footnoteindent}#1
260 %% }
261
262 %% \def\enoteformat{\rightskip\z@ \parindent=0em
263 %%  \makebox[\myendnoteindent][l]{\makeenmark}} % 12.4mm - measured biggest endnote marker (in Moglen text [xxxviii])
264 \def\enoteformat{\rightskip\z@ \setlength{\leftskip}{\myendnoteindent-\myendnoteprespace} \parindent=0em
265   \leavevmode\llap{\makebox[\myendnoteindent][l]{\makeenmark}}}
266
267
268 % make public
269 \def\trimspace#1{\trim@spaces{#1}}
270
271 \makeatother
272
273 %%%%%%%%%%%%%%%%%%%%%% Wyimki
274 %% \floatstyle{plain}
275 %% \newfloat{wyimekbox}{p}{wmk}
276 %% \floatname{wyimekbox}{Wyimek}
277
278 \NewEnviron{wyimek}{%
279   \checkoddpage
280   \ifoddpage
281     \PackageWarning{wlpub}{Wyimek on odd page, omitting it ( \BODY )}
282   \else
283     \begin{figure}[tp]
284       \begin{center}
285         \begin{minipage}[t][\textheight][c]{70mm}
286           \huge\it\BODY
287         \end{minipage}
288       \end{center}
289     \end{figure}
290   \fi
291   \BODY
292 }
293
294 %% wyimek that doesn't leave text in text flow
295 %% TODO: reduce code duplication
296 \NewEnviron{wyimekextra}{%
297   \checkoddpage
298   \ifoddpage
299     \PackageWarning{wlpub}{Wyimek on odd page, omitting it ( \BODY )}
300   \else
301     \begin{figure}[tp]
302       \begin{center}
303         \begin{minipage}[t][\textheight][c]{70mm}
304           \huge\it\BODY
305         \end{minipage}
306       \end{center}
307     \end{figure}
308   \fi
309 }
310
311
312
313
314 %%%%%%%%%%%%%%%%%%%%%%%%%%
315
316
317 \clubpenalty=700
318 \widowpenalty=700
319 \hyphenpenalty=3500
320 \doublehyphendemerits=9000
321 \finalhyphendemerits=6000
322
323
324 % see http://osdir.com/ml/tex.xetex/2005-10/msg00003.html
325 \newsavebox{\ximagebox}\newlength{\ximageheight}
326 \newsavebox{\xglyphbox}\newlength{\xglyphheight}
327 \newcommand{\xbox}[1]
328 {\savebox{\ximagebox}{#1}\settoheight{\ximageheight}{\usebox {\ximapgebox}}%
329 \savebox{\xglyphbox}{\char32}\settoheight{\xglyphheight}{\usebox {\xglyphbox}}%
330 \raisebox{\ximageheight}[0pt][0pt]{%\raisebox{-\xglyphheight}[0pt] [0pt]{%
331 \makebox[0pt][l]{\usebox{\xglyphbox}}}%}%
332 \usebox{\ximagebox}%
333 \raisebox{0pt}[0pt][0pt]{\makebox[0pt][r]{\usebox{\xglyphbox}}}}
334
335
336 \newcommand{\makecover}{
337   %% \paperwidth=297mm
338
339
340   %% \paperheight=210mm
341
342   \newgeometry{paperwidth=297mm,paperheight=210mm}
343   \pdfpageheight=210mm
344   \pdfpagewidth=297mm
345
346   \thispagestyle{empty}
347   \newlength{\PictHOffset}
348   \newlength{\PictVOffset}
349   \setlength{\PictHOffset}{1in}
350   \addtolength{\PictHOffset}{\hoffset}
351   \addtolength{\PictHOffset}{\oddsidemargin}
352
353   \setlength{\PictVOffset}{1in}
354   \addtolength{\PictVOffset}{\voffset}
355   \addtolength{\PictVOffset}{\topmargin}
356   \addtolength{\PictVOffset}{\headheight}
357   \addtolength{\PictVOffset}{\headsep}
358   \addtolength{\PictVOffset}{\topskip}
359
360   \addtolength{\PictVOffset}{-\paperheight}
361
362   \noindent\hspace*{-\PictHOffset}%
363   \raisebox{\PictVOffset}[0pt][0pt]{\makebox[0pt][l]{%
364       \includegraphics[height=\pdfpageheight,width=\pdfpagewidth]{cover.pdf}}}
365
366   \restoregeometry
367   \pdfpageheight=210mm
368   \pdfpagewidth=148mm
369
370   }
371
372 \renewcommand{\maketitle}{
373   %\vspace{\paperheight}
374   \thispagestyle{empty}
375   \cleardoublepage
376   \setcounter{page}{1}
377   \thispagestyle{empty}
378   \begin{center}
379   \intro
380   {
381     \begin{spacing}{1.4}
382     \Huge \noindent \thetitle
383     \end{spacing}
384   }
385   \end{center}
386
387   \vspace{\baselineskip}
388
389   \begin{center}
390     \intro
391     {
392       \huge \noindent
393       \theauthor
394
395     }
396   \end{center}
397                   %\emph{\thankyou}\\
398                   %\indent\emph{You made this book possible.}
399   \vspace{7\baselineskip}
400
401   \begin{center}
402     \includegraphics[scale=.2]{logo.eps}
403   \end{center}
404
405 }
406
407
408 \newcommand{\editorialsection}{
409   \clearpage
410   \thispagestyle{empty}
411   {
412     \setlength{\parindent}{0mm}
413     \small
414   \input{editorial}
415   }
416 }
417
418 \renewcommand*\contentsname{Spis treści}
419 \newcommand{\spistresci}{
420 {
421   \intro
422   \setcounter{tocdepth}{0}
423   \tableofcontents
424   \newpage
425 }
426 }
427
428
429
430
431 \newcommand{\tytul}[1]{%
432 #1%
433 \vspace{1em}%
434 }
435
436 \newcommand{\nazwapodutworu}[1]{%
437 \section*{#1}%
438 }
439
440 \newcommand{\autorutworu}[1]{%
441 #1
442 %\subsection*{\typosubsection{#1}}%
443 }
444
445 \newcommand{\dzielonadrzedne}[1]{%
446 \subsection*{#1}%
447 }
448
449 \newcommand{\nazwautworu}[1]{%
450 \section*{#1}%
451 }
452
453 \newcommand{\podtytul}[1]{%
454 \subsection*{\typosubsubsection{#1}}%
455 }
456
457 \newcommand{\podtytulpodutworu}[1]{%
458 \subsection*{\typosubsubsection{#1}}%
459 }
460
461 \newcommand{\translator}[1]{%
462 \subsection*{\typosubsubsection{tłum. #1}}%
463 }
464 \newcommand{\translatorsline}[1]{%
465 #1
466 }
467
468 \newcommand{\powiesc}[1]{#1}
469 \newcommand{\opowiadanie}[1]{#1}
470 \newcommand{\lirykal}[1]{#1}
471 \newcommand{\lirykalp}[1]{#1}
472 \newcommand{\dramatwierszowanyl}[1]{#1}
473 \newcommand{\dramatwierszowanylp}[1]{#1}
474 \newcommand{\dramatwspolczesny}[1]{#1}
475
476
477 \newcommand{\dedykacja}[1]{%
478 \begin{em}%
479 \begin{flushright}%
480 #1%
481 \end{flushright}%
482 \end{em}%
483 }
484
485 \newcommand{\dlugicytat}[1]{%
486 \begin{quotation}%
487 \noindent{}\ignorespaces#1%
488 \end{quotation}%
489 \hspace{\parindent}
490 }
491
492 \newcommand{\poezjacyt}[1]{%
493 \begin{verse}%
494 #1%
495 \end{verse}%
496 }
497 \newcommand{\motto}[1]{%
498 \begin{em}%
499 #1%
500 \end{em}%
501 }
502 \newcommand{\listaosob}[2]{%
503 \par{#1}%
504 \begin{itemize}%
505 #2%
506 \end{itemize}%
507 }
508
509 \newcommand{\nagloweklisty}[1]{%
510 \typosubsubsection{#1}%
511 }
512
513 \newcommand{\listaosoba}[1]{%
514 \item{#1}%
515 }
516
517 \newcommand{\kwestia}[1]{%
518 \par{#1}%
519 }
520
521 \newcommand{\naglowekakt}[1]{%
522 \pagebreak
523 \subsection*{\typosubsection{#1}}%
524 }
525 \newcommand{\naglowekczesc}[1]{%
526 \pagebreak
527 \part{#1}%
528 }
529 \newcommand{\srodtytul}[1]{%
530 \subsection{#1}%
531 }
532
533 \newcommand{\naglowekscena}[1]{%
534 \subsubsection*{\typosubsubsection{#1}}%
535 }
536
537 \newcommand{\theautorrozdzialu}{}
538
539 \newcommand{\autorrozdzialu}[1]{%
540 \renewcommand{\theautorrozdzialu}{{\normalfont\normalsize\newline{}\newline{}\parbox{\textwidth}{\normalsize\it #1}}}
541 }
542
543
544 \newcommand{\naglowekrozdzial}[1]{%
545 \chapter[#1]{\MakeUppercase{#1}\theautorrozdzialu{}}
546 \renewcommand{\theautorrozdzialu}{}%
547 }
548
549 \newcommand{\naglowekosoba}[1]{%
550 \par{\textsc{#1}}\nopagebreak%
551 }
552 \newcommand{\naglowekpodrozdzial}[1]{%
553 \section{#1}\nopagebreak%
554 }
555
556 \newcommand{\miejsceczas}[1]{%
557 \par{\emph{#1}}%
558 }
559 \newcommand{\didaskalia}[1]{%
560 \par{\emph{#1}}%
561 }
562
563 \newcommand{\akap}[1]{%
564 #1
565
566 % newline here needed, we don't use \par cause it ignores \noindent before
567 }
568 \newcommand{\akapdialog}[1]{%
569 \par{#1}%
570 }
571 \newcommand{\akapcd}[1]{%
572 \par{#1}%
573 }
574
575 \newcommand{\mottopodpis}[1]{%
576 \begin{em}%
577 \begin{flushright}%
578 #1%
579 \end{flushright}%
580 \end{em}%
581 }
582
583 \newcommand{\strofa}[1]{%
584 #1\vspace{\baselineskip}%
585 }
586
587 \newcommand{\wers}[1]{#1}
588
589 \newcommand{\wersakap}[1]{%
590 \hspace*{1em}#1%
591 }
592 \newcommand{\werscd}[1]{%
593 \hspace*{8em}#1%
594 }
595 \newcommand{\werswciety}[2][1em]{%
596 \hspace*{#1}#2%
597 }
598
599
600 \newcommand{\mat}[1]{$#1$}
601
602 \newcommand{\didasktekst}[1]{%
603 \emph{#1}%
604 }
605 \newcommand{\slowoobce}[1]{%
606 \emph{#1}%
607 }
608 \makeatletter
609
610 \newif\ifinnota \innotafalse
611
612 \newcommand{\tytuldziela}[1]{%
613   \ifinnota
614    #1%
615   \else
616    \emph{#1}%
617   \fi
618 }
619 \makeatother
620
621 \newcommand{\wyroznienie}[1]{%
622 \emph{#1}%
623 }
624
625 \newcommand{\nota}[1]{%
626 %\sekcjaasterysk{}
627 \begin{em}%
628   \innotatrue
629 %\begin{flushleft}%
630   \noindent{}\small{}#1%
631   \innotafalse
632 %\end{flushleft}%
633 \end{em}%
634 }
635
636
637 \newcommand{\osoba}[1]{%
638 #1%
639 }
640
641 \newcommand{\sekcjaswiatlo}{%
642 \vspace{\baselineskip}%
643 }
644
645 \newcommand{\sekcjaasterysk}{%
646 \vspace{\baselineskip}%
647 \begin{center}%
648 \par{*}%
649 \end{center}%
650 }
651
652 \newcommand{\separatorlinia}{%
653 \vspace{10pt}%
654 \hrule{}%
655 \vspace{10pt}%
656 }
657
658 \newcommand{\ilustrscale}[0]{1}
659 \newcommand{\setilustrscale}[1]{\renewcomand{\ilustrscale}{#1}}
660
661 \newcommand{\ilustr}[3][]{
662   \begin{center}%
663     \ifthenelse{\isempty{#1}}%
664     {\par{\includegraphics{\trimspace{#2}}\\#3}}%
665     {\par{\includegraphics[#1]{\trimspace{#2}}\\#3}}%
666   \end{center}%
667 }
668
669
670 \newcommand{\lista}[1]{%
671 \begin{compactenum}
672 %\setlength{\parskip}{\parindent}
673 #1
674 \end{compactenum}
675 }
676
677 \newcommand{\punkt}[1]{%
678 \item #1
679 }
680 \newcommand{\link}[2]{\href{#1}{\uline{#2}\footnote{#1}}}
681
682 \newcommand{\www}[1]{{\normalfont\href{#1}{#1}}}