]> pere.pagekite.me Git - text-free-culture-lessig.git/blob - myclass.cls
Correct quote chars.
[text-free-culture-lessig.git] / myclass.cls
1 \NeedsTeXFormat{LaTeX2e}
2 \ProvidesPackage{myclass}[]
3
4 %% Just use the original class and pass the options
5 \LoadClassWithOptions{report}
6 % report, book, memoir, scrreprt or scrbook ?
7
8 % Show frames, make it easier to debug borders
9 %\usepackage{showframe}% http://ctan.org/pkg/showframe
10 \makeatletter
11
12 %
13 % Customize the titlepage: remove the date, place the publisher name, and
14 % load a specific file for the verso page, containing some legal notices
15 %
16 \def\maketitle{%
17 \titlerecto%
18 \titleverso}
19
20 \def\titlerecto{\begin{titlepage}%
21 \null\vfil
22 \vskip 160\p@
23 \begin{center}%
24 {\LARGE \@title \par}%
25 \vskip 3em%
26 {\Large
27 \lineskip .75em%
28 \begin{tabular}[t]{c}%
29 \@author
30 \end{tabular}\par}%
31 \vskip 20em%
32 {\large \DBKpublishername \par}
33 \vskip .75em%
34 {\large \DBKpublisheraddress \par}%
35 \end{center}\par
36 \vfil\null
37 \end{titlepage}}%
38
39 \def\titleverso{%
40 \def\titlepagefile{titlepg.input.tex}
41 \IfFileExists{\titlepagefile}{\input{\titlepagefile}}{}
42 }%
43
44
45 % Divide by 2 the index item indentation (10pt -> 5pt)
46 \renewcommand\@idxitem{\par\hangindent 20\p@}
47 \renewcommand\subitem{\@idxitem \hspace*{10\p@}}
48 \renewcommand\subsubitem{\@idxitem \hspace*{15\p@}}
49
50 % Put the index in the TOC
51 \let\stdindex=\theindex
52 \let\endstdindex=\endtheindex
53 \renewenvironment{theindex}{
54 \begin{stdindex}
55 % Use a smaller font except for the letter heading which is bold
56 \newfontfamily\indexfont[Scale=0.7,
57 BoldFeatures={Scale=1}]{Crimson Text}
58 \@ifundefined{chapter}{}{
59 % To not have the number, replace by:
60 % \addcontentsline{toc}{chapter}{\numberline{}\indexname}
61 \refstepcounter{chapter}
62 \ifnum \c@secnumdepth >\z@
63 \ifnum \value{part} >\z@
64 \addcontentsline{toc}{part}{\numberline{\thechapter}\hspace{-1em}\indexname}
65 \else
66 \addcontentsline{toc}{chapter}{\numberline{\thechapter}\indexname}
67 \fi
68 \else
69 \addcontentsline{toc}{chapter}{\indexname}
70 \fi
71 }
72 % Adapt the vertical sizes to the smaller font
73 \setlength{\baselineskip}{0.7\baselineskip}%
74 \setlength{\parskip}{0.2\baselineskip}%
75 \indexfont
76 }{
77 \end{stdindex}
78 }
79 \makeatother
80
81 \newenvironment{colophon}{
82 \pagebreak %
83 % FIXME change when page size changes, use {x}{x*1.2}
84
85 % Note, these numbers are not correct any more for the sizes mentioned:
86 % \fontsize{6.5}{7.8}\selectfont % fits in one 4.25x6.875" pocket size page
87 % \fontsize{7.5}{9}\selectfont % fits in one 5.06x7.71" size page
88 % \fontsize{9.1}{10.92}\selectfont % fits in one 5.5x8.5" digest size page
89
90 \fontsize{8.2}{9.84}\selectfont % fits in one 6x9'' size page
91 \setlength{\parskip}{0.5em} %
92 \setlength{\parindent}{0pt} %
93 }{}
94
95
96 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
97 % Based on ideas from https://bugs.debian.org/684772
98 \usepackage{titlesec}
99 \usepackage{titletoc}
100 %
101 % Useless with unnumbered sections (e.g. use of \setcounter{secnumdepth}{0})
102 %
103 %
104 \newcommand\makeletterof[1]{%
105 \ifthenelse{\equal{#1}{1}}{EN}{%
106 \ifthenelse{\equal{#1}{2}}{TO}{%
107 \ifthenelse{\equal{#1}{3}}{TRE}{%
108 \ifthenelse{\equal{#1}{4}}{FIRE}{%
109 \ifthenelse{\equal{#1}{5}}{FEM}{%
110 \ifthenelse{\equal{#1}{6}}{SEKS}{%
111 \ifthenelse{\equal{#1}{7}}{SJU}{%
112 \ifthenelse{\equal{#1}{8}}{ÅTTE}{%
113 \ifthenelse{\equal{#1}{9}}{NI}{%
114 \ifthenelse{\equal{#1}{10}}{TI}{%
115 \ifthenelse{\equal{#1}{11}}{ELLEVE}{%
116 \ifthenelse{\equal{#1}{12}}{TOLV}{%
117 #1}}}}}}}}}}}}}
118
119 % Make TOC entries without label
120 \titlecontents{chapter} %
121 [1.5em] %
122 {\addvspace{0.3em plus 0pt}\bfseries} %
123 {\hspace{-1.3em}} % no number, remove room reserved for it
124 {\hspace{-1.3em}} %
125 {\hfill \contentspage} % dots and page number
126 [\addvspace {0pt}]
127
128 \dottedcontents{section} %
129 [0em] % was (3.8)
130 {\addvspace{0pt}} %
131 {2.3em} % tab
132 {0.75em} % space between dots
133 [\addvspace{0pt}]
134
135 %% Redefines the headings to remove the chapter label
136 \titleformat{\chapter}[block]
137 {\filcenter\Large}{\filcenter}{20pt}{\Large}
138
139 \titleformat{\section}
140 {\filcenter\Large\bfseries}{\thesection}{1em}{}
141
142 \titleformat{\subsection}
143 {\filcenter\large\bfseries}{\thesubsection}{1em}{}
144
145 %% New header, behaving like a section but formatted differently
146 \titleclass{\enoteheader}{straight}[\chapter]
147 \newcounter{enoteheader}
148 \renewcommand{\theenoteheader}{\Alph{enoteheader}}
149
150 \titleformat{\enoteheader}
151 {\normalfont\large}{}{0pt}{}
152 \titlespacing*{\enoteheader}{0pt}{2.5ex plus 1ex minus .2ex}{1.3ex plus .2ex}
153
154 \dottedcontents{enoteheader} %
155 [0em] % was (3.8)
156 {\addvspace{0pt}} %
157 {2.3em} % tab
158 {0.75em} % space between dots
159 [\addvspace{0pt}]
160
161 %% New header, behaving like a chapter but formatted differently
162 \titleclass{\lotheader}{top}[\part]
163 \newcounter{lotheader}
164 \renewcommand{\thelotheader}{\Alph{lotheader}}
165
166 \titleformat{\lotheader}[block]
167 {\filcenter\huge}{\filcenter}{20pt}{\Huge}
168 \titlespacing*{\lotheader}{0pt}{-30pt}{40pt}
169
170 % Use the new header in TOC
171 \let\stdtoc=\tableofcontents
172 \let\stdchapter=\chapter
173 \def\tableofcontents{\let\chapter\lotheader \stdtoc{} \let\chapter\stdchapter}
174
175
176 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
177
178 % From
179 % https://amyrhoda.wordpress.com/2012/06/04/latex-to-lulu-the-making-of-aosa-other-useful-packages-and-settings/
180
181 % The microtype package provides the ability to micromanage your
182 % typography. When invoked without any options it does some nice things
183 % like protruding punctuation over the edge of the right margin to make
184 % the margin appear smoother. Basically it makes your book look more
185 % professional with very little effort. It also has a ton of options if
186 % you want to micromanage even more.
187 \usepackage{microtype}
188
189 % By dafault, LaTeX will try and make all your pages the length that
190 % you set using the geometry setting. If a page has images, tables,
191 % headings or paragraph breaks which make it shorter than that page
192 % length, LaTeX will pad the page by adding whitespace between
193 % elements. We thought that looked sillier than having pages be
194 % different lengths, so we used the raggedbottom command.
195 \raggedbottom
196
197 % Hint for figure with empty title: remove the colon label separator
198 \usepackage{caption}
199 \captionsetup[figure]{labelsep=none}
200
201 % Fix the page number reset done by abstract by redefining it
202 % Patch from
203 % https://github.com/petterreinholdtsen/free-culture-lessig/pull/7
204
205 \def\nocount#1#2{}
206 \let\stdsetcounter\setcounter
207 \let\stdabstract=\abstract
208 \let\endstdabstract=\endabstract
209 \renewenvironment{abstract}{%
210 \let\setcounter\nocount%
211 \begin{stdabstract}%
212 \noindent%
213 \setlength\parskip{\medskipamount}%
214 \setlength\parindent{0pt}%
215 }{
216 \end{stdabstract}
217 \let\setcounter\stdsetcounter
218 }