1 \NeedsTeXFormat{LaTeX2e}
2 \ProvidesPackage{myclass}[]
4 %% Just use the original class and pass the options
5 \LoadClassWithOptions{report}
6 % report, book, memoir, scrreprt or scrbook ?
8 % Show frames, make it easier to debug borders
9 %\usepackage{showframe}% http://ctan.org/pkg/showframe
12 % Customize the titlepage: remove the date
13 \let\stdmaketitle=\maketitle
14 \def\maketitle{\let\@date\empty\stdmaketitle}
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@}}
21 % Put the index in the TOC
22 \let\stdindex=\theindex
23 \let\endstdindex=\endtheindex
24 \renewenvironment{theindex}{
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}
37 \addcontentsline{toc}{chapter}{\numberline{\thechapter}\indexname}
40 \addcontentsline{toc}{chapter}{\indexname}
43 % Adapt the vertical sizes to the smaller font
44 \setlength{\baselineskip}{0.7\baselineskip}%
45 \setlength{\parskip}{0.2\baselineskip}%
52 \newenvironment{colophon}{
54 % FIXME change when page size changes, use {x}{x*1.2}
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
61 \fontsize{8.2}{9.84}\selectfont % fits in one 6x9'' size page
62 \setlength{\parskip}{0.5em} %
63 \setlength{\parindent}{0pt} %
67 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
68 % Based on ideas from https://bugs.debian.org/684772
72 % Useless with unnumbered sections (e.g. use of \setcounter{secnumdepth}{0})
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}{%
90 % Make TOC entries without label
91 \titlecontents{chapter} %
93 {\addvspace{0.3em plus 0pt}\bfseries} %
94 {\hspace{-1.3em}} % no number, remove room reserved for it
96 {\hfill \contentspage} % dots and page number
99 \dottedcontents{section} %
103 {0.75em} % space between dots
106 %% Redefines the headings to remove the chapter label
107 \titleformat{\chapter}[block]
108 {\filcenter\Large}{\filcenter}{20pt}{\Large}
110 \titleformat{\section}
111 {\filcenter\Large\bfseries}{\thesection}{1em}{}
113 \titleformat{\subsection}
114 {\filcenter\large\bfseries}{\thesubsection}{1em}{}
116 %% New header, behaving like a section but formatted differently
117 \titleclass{\enoteheader}{straight}[\chapter]
118 \newcounter{enoteheader}
119 \renewcommand{\theenoteheader}{\Alph{enoteheader}}
121 \titleformat{\enoteheader}
122 {\normalfont\large}{}{0pt}{}
123 \titlespacing*{\enoteheader}{0pt}{2.5ex plus 1ex minus .2ex}{1.3ex plus .2ex}
125 \dottedcontents{enoteheader} %
129 {0.75em} % space between dots
132 %% New header, behaving like a chapter but formatted differently
133 \titleclass{\lotheader}{top}[\part]
134 \newcounter{lotheader}
135 \renewcommand{\thelotheader}{\Alph{lotheader}}
137 \titleformat{\lotheader}[block]
138 {\filcenter\huge}{\filcenter}{20pt}{\Huge}
139 \titlespacing*{\lotheader}{0pt}{-30pt}{40pt}
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}
147 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
150 % https://amyrhoda.wordpress.com/2012/06/04/latex-to-lulu-the-making-of-aosa-other-useful-packages-and-settings/
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}
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.
168 % Hint for figure with empty title: remove the colon label separator
170 \captionsetup[figure]{labelsep=none}
172 % Fix the page number reset done by abstract by redefining it
174 % https://github.com/petterreinholdtsen/free-culture-lessig/pull/7
177 \let\stdsetcounter\setcounter
178 \let\stdabstract=\abstract
179 \let\endstdabstract=\endabstract
180 \renewenvironment{abstract}{%
181 \let\setcounter\nocount%
184 \setlength\parskip{\medskipamount}%
185 \setlength\parindent{0pt}%
188 \let\setcounter\stdsetcounter