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