]> pere.pagekite.me Git - text-free-culture-lessig.git/blob - myclass.cls
Merge remote-tracking branch 'upstream/master'
[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 \newenvironment{colophon}{
64 \pagebreak %
65 \fontsize{7}{8.4}\selectfont %
66 \setlength{\parskip}{0.5em} %
67 \setlength{\parindent}{0pt} %
68 }{}
69
70
71 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
72 % Based on ideas from https://bugs.debian.org/684772
73 \usepackage{titlesec}
74 \usepackage{titletoc}
75 %
76 % Useless with unnumbered sections (e.g. use of \setcounter{secnumdepth}{0})
77 %
78 %
79 \newcommand\makeletterof[1]{%
80 \ifthenelse{\equal{#1}{1}}{EN}{%
81 \ifthenelse{\equal{#1}{2}}{TO}{%
82 \ifthenelse{\equal{#1}{3}}{TRE}{%
83 \ifthenelse{\equal{#1}{4}}{FIRE}{%
84 \ifthenelse{\equal{#1}{5}}{FEM}{%
85 \ifthenelse{\equal{#1}{6}}{SEKS}{%
86 \ifthenelse{\equal{#1}{7}}{SJU}{%
87 \ifthenelse{\equal{#1}{8}}{ÅTTE}{%
88 \ifthenelse{\equal{#1}{9}}{NI}{%
89 \ifthenelse{\equal{#1}{10}}{TI}{%
90 \ifthenelse{\equal{#1}{11}}{ELLEVE}{%
91 \ifthenelse{\equal{#1}{12}}{TOLV}{%
92 #1}}}}}}}}}}}}}
93
94 % Make TOC entries without label
95 \titlecontents{chapter} %
96 [1.5em] %
97 {\addvspace{1em plus 0pt}\bfseries} %
98 {\hspace{-1.3em}} % no number, remove room reserved for it
99 {\hspace{-1.3em}} %
100 {\hfill \contentspage} % dots and page number
101 [\addvspace {0pt}]
102
103 \dottedcontents{section} %
104 [0em] % was (3.8)
105 {\addvspace{0pt}} %
106 {2.3em} % tab
107 {0.75em} % space between dots
108 [\addvspace{0pt}]
109
110
111 %% Redefines the headings to remove the chapter label
112 \titleformat{\chapter}[block]
113 {\filcenter\huge}{\filcenter}{20pt}{\Huge}
114
115 \titleformat{\section}
116 {\filcenter\Large\bfseries}{\thesection}{1em}{}
117
118 \titleformat{\subsection}
119 {\filcenter\large\bfseries}{\thesubsection}{1em}{}
120 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
121
122 % From
123 % https://amyrhoda.wordpress.com/2012/06/04/latex-to-lulu-the-making-of-aosa-other-useful-packages-and-settings/
124
125 % The microtype package provides the ability to micromanage your
126 % typography. When invoked without any options it does some nice things
127 % like protruding punctuation over the edge of the right margin to make
128 % the margin appear smoother. Basically it makes your book look more
129 % professional with very little effort. It also has a ton of options if
130 % you want to micromanage even more.
131 \usepackage{microtype}
132
133 % By dafault, LaTeX will try and make all your pages the length that
134 % you set using the geometry setting. If a page has images, tables,
135 % headings or paragraph breaks which make it shorter than that page
136 % length, LaTeX will pad the page by adding whitespace between
137 % elements. We thought that looked sillier than having pages be
138 % different lengths, so we used the raggedbottom command.
139 \raggedbottom
140
141 % Hint for figure with empty title: remove the colon label separator
142 \usepackage{caption}
143 \captionsetup[figure]{labelsep=none}
144
145 % Fix the page number reset done by abstract by redefining it
146 % Patch from
147 % https://github.com/petterreinholdtsen/free-culture-lessig/pull/7
148
149 \def\nocount#1#2{}
150 \let\stdsetcounter\setcounter
151 \let\stdabstract=\abstract
152 \let\endstdabstract=\endabstract
153 \renewenvironment{abstract}{%
154 \let\setcounter\nocount%
155 \begin{stdabstract}%
156 \noindent%
157 \setlength\parskip{\medskipamount}%
158 \setlength\parindent{0pt}%
159 }{
160 \end{stdabstract}
161 \let\setcounter\stdsetcounter
162 }