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