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