-
Notifications
You must be signed in to change notification settings - Fork 5
/
hp-header.tex
278 lines (251 loc) · 10.5 KB
/
hp-header.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
\documentclass[10pt,extrafontsizes,twoside,openany,final]{memoir}
% THIS DOCUMENT REQUIRES XeLaTeX TO COMPILE!
\usepackage{lettrine} % Used for the fancy caps at the start of each chapter
\usepackage{xspace} % Takes care of spaces after macros
\usepackage{amsmath} % Provides the align environment, used in chapter 13 for the notes
\usepackage[protrusion=basictext]{microtype}
% Makes right margin neater by letting certain punctuation protrude slightly
\usepackage{fontspec} % For the many fonts
\usepackage{xunicode} % Probably needed for something
\usepackage{xstring} % Needed for something
\usepackage{censor} % Used in "Time Pressure" to redact Hermione's name
\usepackage[useregional]{datetime2}
% Used for the build timestamp in the colophon
\usepackage[bookmarks=true,unicode=true,pdfborder={0 0 0},
pdftitle={Harry Potter and the Methods of Rationality},
pdfauthor={LessWrong}, breaklinks={true},
pdfkeywords={Harry Potter, rationality},pdfencoding=auto
]{hyperref} % Hyperlinks and bookmarks in PDF
\usepackage[autostyle=false, style=english]{csquotes}
\MakeOuterQuote{"} % Automatic curly quotes
\usepackage{fmtcount} % Provides \NUMBERstringnum
\usepackage{graphicx} % for \reflectbox in header
\input{ushyphex} % US Hyphenation exceptions
%
% Set-up page sizes and margins
%
\setstocksize{9in}{6in}
\settrimmedsize{\stockheight}{\stockwidth}{*}
\settypeblocksize{7.34in}{4.31in}{*}
\setlrmargins{*}{*}{0.65}
\setulmargins{*}{*}{0.8}
\setheadfoot{\topskip + \baselineskip}{2\baselineskip}
\checkandfixthelayout[fixed]
\fixdvipslayout % fix for xelatex
%
% Font setup: URW Garamond No. 8
%
\setmainfont[
, Ligatures={Common,TeX}
, UprightFont=*-Regular
, ItalicFont=*-Italic
, BoldFont=*-Medium
, BoldItalicFont=*-Medium-Italic
]{GaramondNo8}
%
% Chapters, headings, etc.: Lumos (extra spacing looks much better)
\newfontface\hp[ExternalLocation, LetterSpace=18.0, WordSpace=1.5]{Lumos}
\newcommand{\lumos}[1]{{\hp\MakeUppercase{#1}}}
% Chapter numbers: Lumos (extreme spacing for effect)
\newfontface\hpchap[ExternalLocation, LetterSpace=80.0, WordSpace=2.0]{Lumos}
%
% Font used to draw the magic star
\newfontface\starfont[ExternalLocation]{Miscelanea.ttf}
%
% Draws a “magic star”, used as a decoration
\newcommand*{\Star}{{\starfont{}*}}
%
% Draws three “magic stars”, used as a decoration everywhere
\newcommand*{\Stars}{{\Large\Star\kern-.6ex\lower1.1ex\hbox{\Large\Star}%
\kern-.1ex\raise.1ex\hbox{\small\Star}\spacefactor1000}}
%
% Section break with three spaced stars
%
\newcommand{\sbreak}{\par\vskip 0pt plus .5\baselineskip%
{\begin{center} \Star\qquad\Star\qquad\Star \end{center}}\vskip 0pt plus .5\baselineskip \par\noindent}
%
% Simple linebreak
%
\newcommand{\lbreak}{\vspace*{\baselineskip}}
%
% Custom chapter style
%
\makechapterstyle{evans}{%
\renewcommand*{\chapnamefont}{\hpchap\normalsize}
\renewcommand*{\chapnumfont}{\chapnamefont\normalsize}
\renewcommand*{\chaptitlefont}{\hp\large}
\setlength{\beforechapskip}{0pt}
\setlength{\midchapskip}{0pt}
\setlength{\afterchapskip}{1\baselineskip}
\renewcommand*{\printchapternum}{% " C H A P T E R O N E "
\begin{center} \chapnumfont \hyperref[contents]{CHAPTER \NUMBERstringnum{\thechapter}}\end{center}}
\renewcommand*{\printchaptername}{}% Not needed, "CHAPTER" added above
\renewcommand*{\printchaptertitle}[1]{% "A DAY OF VERY LOW PROBABILITY"
\vskip 1cm \begin{center}\chaptitlefont \MakeUppercase{##1}\end{center}\par \vskip 1cm}
\renewcommand*{\chaptermark}[1]{% "CHAPTER ONE" and "A DAY OF..."
\markboth{\MakeUppercase{##1}}{%
\MakeUppercase{\chaptername}~\protect\NUMBERstringnum{\thechapter}}}
\renewcommand*{\tocmark}{\markboth{}{\MakeUppercase{Contents}}}
\renewcommand{\tocheadstart}{\chapterheadstart}
\renewcommand{\aftertoctitle}{\thispagestyle{empty}\afterchaptertitle}
}
\chapterstyle{evans}% Actually implements the above chapter style code
\newcommand*{\hpmorchapbreak}{\linebreak} % Allows the break to be disabled in TOC
\newcommand{\wrapchapter}[2]{\chapter[% Custom linebreak for long chapter titles
\texorpdfstring{%
#1\protect\hpmorchapbreak #2}{% Header
#1 #2}]{% Bookmark for PDF
#1\protect\hpmorchapbreak #2}}% First page of chapter
%
% Subsection
%
\setsubsecheadstyle{\bfseries\scshape} % Subsection titles in small caps
\beforesubsecskip=1.5\baselineskip % skip before the heading
\aftersubsecskip=.5\baselineskip plus .5\baselineskip % skip after the heading
\setsubsechook{\nopagebreak\vskip 0pt plus 3\baselineskip}
%
% Configure line spacing and paragraph spacing, and modifying penalties
%
\linespread{1.17} % Wider line spacing looks much better
\raggedbottom % Better to have consistent line spacing than vertically justified text
% \sloppybottom % Allows widow lines to be added to the bottom of the page.
\frenchspacing % Single space after a period
%
\setlength{\emergencystretch}{.07\textwidth}
% If a paragraph cannot be typeset without compromises, try wider line spacing
%
\clubpenalty=80 % Mildly discourages first line of paragraph on previous page
\widowpenalty=9000 % Avoids last line of paragraph on next page
\brokenpenalty=2000 % Avoids hyphenation across a page break
\hyphenpenalty=60 % Penalty for automatic hyphenation
\exhyphenpenalty=75 % Penalty for breaking after a dash or explicit hyphen
\adjdemerits=80000 % Penalty for visually incompatible lines
\doublehyphendemerits=70000 % Avoids hyphenation on consecutive lines
\hbadness=4000 % When compiling, only reports underfull lines if badness>4000
%
% Adjust space around lists (not entirely sure why)
%
\setlength{\topsep}{.5\baselineskip plus 1\baselineskip minus .5\baselineskip}
\setlength{\partopsep}{.5\baselineskip plus 1\baselineskip minus .5\baselineskip}
%
% Lettrine font pick and configuration
%
\renewcommand{\LettrineFontHook}{\hp} % Uses Lumos for the large letter
\renewcommand{\LettrineTextFont}{} % Normal font for the rest of the first word
% For when the first word is in italics, use this command instead
\newcommand{\lettrinemph}[3][]{\lettrine[#1]{#2}{\emph{#3}}}
\setcounter{DefaultLines}{1}
% Large cap instead of drop cap because of many short first lines
\renewcommand{\DefaultLoversize}{0}
\renewcommand{\DefaultLraise}{0}
%
% Page numbering, footer, header (confusing)
%
\newcommand{\pageInFooter}{{\small\Star\ \makebox[2em][c]{\thepage\,}\Star}}
% Page number centered between two small stars in footer
% Same on all pages in body text
\makeevenfoot{plain}{}{\pageInFooter}{}
\makeoddfoot{plain}{}{\pageInFooter}{}
\makeevenfoot{headings}{}{\pageInFooter}{}
\makeoddfoot{headings}{}{\pageInFooter}{}
%
% Left side header: chapter number
% Right side header: chapter name
% Decorative stars in corners
\makeevenhead{headings}{\Stars}{
\hp\hyperref[contents]{\small\rightmark}}{\reflectbox{\Stars}}
\makeatletter
\makeoddhead{headings}{\Stars}{\parbox{99mm}{\centering\hp\small\leftmark}}{\reflectbox{\Stars}}
\copypagestyle{cleared}{empty}
\makepsmarks{headings}{%
\createmark{chapter}{right}{shownumber}{\@chapapp\ }{. \ }}
\makeatother
%
% XeTeX character classes (hacks)
%
\newXeTeXintercharclass \punctuationClass
\XeTeXcharclass `\’ \punctuationClass
\XeTeXcharclass `\‘ \punctuationClass
\XeTeXcharclass `\“ \punctuationClass
\XeTeXcharclass `\” \punctuationClass
\XeTeXcharclass `\. \punctuationClass
\XeTeXcharclass `\, \punctuationClass
\XeTeXcharclass `\: \punctuationClass
\XeTeXcharclass `\? \punctuationClass
\XeTeXcharclass `\! \punctuationClass
\XeTeXcharclass `\: \punctuationClass
%
\newXeTeXintercharclass \digitClass
\XeTeXcharclass `\0 \digitClass
\XeTeXcharclass `\1 \digitClass
\XeTeXcharclass `\2 \digitClass
\XeTeXcharclass `\3 \digitClass
\XeTeXcharclass `\4 \digitClass
\XeTeXcharclass `\5 \digitClass
\XeTeXcharclass `\6 \digitClass
\XeTeXcharclass `\7 \digitClass
\XeTeXcharclass `\8 \digitClass
\XeTeXcharclass `\9 \digitClass
%
\newXeTeXintercharclass \dashClass
\XeTeXcharclass `\— \dashClass % em
\XeTeXcharclass `\– \dashClass % en
%
\newXeTeXintercharclass \hyphenClass
\XeTeXcharclass `\- \hyphenClass % hyphen
%
\XeTeXinterchartokenstate = 1 % enable functionality
%
% Automatic spacing around em dashes, allows line breaks after
\XeTeXinterchartoks \dashClass 0 = {\discretionary{}{}{\,}}
\XeTeXinterchartoks 0 \dashClass = {\,}
\XeTeXinterchartoks \dashClass 255 = {\discretionary{}{}{\,}}
\XeTeXinterchartoks 255 \dashClass = {\,}
%
% Style definitions and hacks
%
% In the text, em dashes are encoded explicitly
% and the ellipsis is encoded with {\el}
\newcommand*{\el}{\,.\,.\,.} % Ellipsis definition
%
% Logical formatting macros
\newcommand*{\parsel}[1]{\textit{#1}} % Parseltongue
\newcommand*{\prophecy}[1]{\textbf{\textit{\textsc{#1}}}} % Prophecies
\newcommand*{\headline}[1]{\begin{center}\textsc{#1}\end{center}} % Newspaper headlines
\newcommand*{\inlineheadline}[1]{\textsc{#1}} % Newspaper headlines inline with text
%
% Macros to format certain words and abbreviations automatically
\newcommand*{\AM}{{\scshape am}\xspace} % AM in small caps, for time of day
\newcommand*{\PM}{{\scshape pm}\xspace} % PM in small caps, for time of day
%
% Makes a written note in italics (first used, Hogwarts acceptance letter)
\newenvironment{writtenNote}{%\parindent=1cm%
\vskip 1\baselineskip plus 1\baselineskip minus .5\baselineskip%
\begin{adjustwidth}{\parindent}{\parindent}\begin{em}%
\par\noindent}
{\end{em}\end{adjustwidth}\vskip 1\baselineskip plus 1\baselineskip minus .5\baselineskip}
% Makes a letter address and closing, for use with above writtenNote environment
\newcommand{\letterAddress}[1]{\pagebreak[1]\noindent{}#1\nopagebreak[4]\par}
\newcommand{\letterClosing}[2][\vskip 1\baselineskip]{\nopagebreak[4]#1\par\nopagebreak[5]\noindent#2}
%
% Makes an inscription in small caps (first used, Gringotts)
\newenvironment{inscription}{%\parindent=1cm%
\vskip 1\baselineskip plus .5\baselineskip minus .5\baselineskip%
\begin{adjustwidth}{4\parindent}{\parindent}\scshape}
{\end{adjustwidth}\vskip 1\baselineskip plus .5\baselineskip minus .5\baselineskip}
%
% Not sure what these are included for:
\fboxrule=1pt
\fboxsep=-1pt
%
%
%
% Hyphenation corrections
%
\hyphenation{Gryf-fin-dor Huf-fle-puff Sly-the-rin Wi-zen-ga-mot
McGon-a-gall Dum-ble-dore Malfoy Potter Her-mione Flit-wick
Vol-de-mort Le-strange Gil-deroy Scour-gify Sev-erus
Alo-ho-mora Mun-dun-gus Hogs-meade Nym-pha-dora
Ver-i-ta-serum Tre-lawney Az-ka-ban Poly-juice Sirius basi-lisk
Phi-neas McKin-non Filius Quiri-nus Love-good whom-ever
Gryf-fin-dors Huf-fle-puffs Sly-the-rins}