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