-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmla.cls
364 lines (320 loc) · 9.33 KB
/
mla.cls
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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Preamble
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{mla}[2019/10/01 MLA v1.2-dev]
%% article uses 10pt by default.
\LoadClass[12pt]{article}
\RequirePackage{iftex}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Options
%% Option [justify]: use justified text instead of left-aligned.
\newif\if@justify\@justifyfalse
\DeclareOption{justify}{
\@justifytrue
}
%% Option [tinos]: use Tinos instead of Times New Roman.
\newif\if@tinos\@tinosfalse
\DeclareOption{tinos}{
\@tinostrue
}
%% Option [workscitedsamepage]: do not place the Works Cited on a new
%% page.
\newif\if@workscitedclearpage\@workscitedclearpagetrue
\DeclareOption{workscitedsamepage}{
\@workscitedclearpagefalse
}
%% Option [lowerrightpagenumbers]: put page numbers in the lower right
%% rather than the upper right.
\newif\if@lowerrightpagenumbers\@lowerrightpagenumbersfalse
\DeclareOption{lowerrightpagenumbers}{
\@lowerrightpagenumberstrue
}
%% Option [nofirstpagenumber]: don't display a page number in the
%% upper right corner.
\newif\if@nofirstpagenumber\@nofirstpagenumberfalse
\DeclareOption{nofirstpagenumber}{
\@nofirstpagenumbertrue
}
\ProcessOptions\relax
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Page layout
%% MLA requires 8.5x11 (letterpaper) and 1in margins on all sides.
\usepackage[letterpaper]{geometry}
\geometry{
top=1.0in,
bottom=1.0in,
left=1.0in,
right=1.0in
}
%% Package fancyhdr allows customizing the headers and footers.
%% Setting the pagestyle is required for the customized
%% headers/footers to be used. \fancyhf{} removes the default contents
%% of the headers and footers, leaving them blank.
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
% https://tex.stackexchange.com/q/528358
\setlength\headheight{15pt}
%% Put the author's last name and the page number in the
%% upper-right-hand corner.
\if@lowerrightpagenumbers
\rfoot{\ifno{lastname}{\thepage}{\get{lastname}~\thepage}}
\else
\rhead{\ifno{lastname}{\thepage}{\get{lastname}~\thepage}}
\fi
\if@nofirstpagenumber
\fancypagestyle{blank}{
\fancyhf{}
}
\thispagestyle{blank}
\fi
%% Remove the horizontal rule that is usually displayed just below the
%% page header.
\renewcommand*{\headrulewidth}{0pt}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Font
%% Set the appropriate font (Tinos or Times New Roman).
% Load New TX if not using OpenType-compatible engine
\iftutex
\usepackage{fontspec}
\if@tinos
\setmainfont{Tinos}
\else
\setmainfont{Times New Roman}
\fi
\else
\RequirePackage[T1]{fontenc}
\RequirePackage{newtxtext}
\fi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Text formatting
%% Smarter quotes.
\usepackage{csquotes}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Spacing
%% Unless justification is requested, use package ragged2e to inhibit
%% it. Note that vanilla \raggedright screws up paragraph indents.
\if@justify\else
\usepackage{ragged2e}
\setlength\RaggedRightParindent\parindent
\RaggedRight
\fi
%% MLA requires exactly 0.5in paragraph indents.
\setlength{\parindent}{0.5in}
%% MLA also says that every paragraph should be indented, including
%% the first paragraph of a section.
\usepackage{indentfirst}
%% Make a new version of the {center} environment that doesn't add
%% extra spacing.
\newenvironment
{centered}
{\parskip=0pt\par\par\nopagebreak\centering}
{\par\noindent\ignorespacesafterend}
%% Everyone loves double-spacing.
\usepackage{setspace}
\setstretch{2}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Header
%% Mutable field management. The declaration \newfield{foo} will
%% generate a command \foo{...} that can be used to set the value of
%% field foo. You can then insert the value with \get{foo}, and unset
%% it back to the default, which is the literal text \foo{?}, using
%% \unset{foo}. There is also \ifno{foo}{A}{B}, which expands to A if
%% foo is unset, and expands to B otherwise. If command \foo{...} is
%% already defined, you can allow redefining it with \renewfield{foo}.
\newcommand*{\newfield}[1]{%
\unset{#1}%
\expandafter\newcommand\csname #1\endcsname[1]{%
\expandafter\def\csname value#1\endcsname{##1}}%
}
\newcommand*{\renewfield}[1]{%
\unset{#1}%
\expandafter\renewcommand\csname #1\endcsname[1]{%
\expandafter\def\csname value#1\endcsname{##1}}%
}
\newcommand*{\get}[1]{\csname value#1\endcsname}
\newcommand{\ifno}[3]{%
\expandafter\ifdefempty\csname value#1\endcsname{#2}{#3}%
}
\newcommand*{\unset}[1]{%
\expandafter\def\csname value#1\endcsname{\textbackslash #1\{?\}}%
}
%% Fields used in header.
\newfield{firstname}
\newfield{lastname}
\newfield{professor}
\newfield{class}
\renewfield{date}
\renewfield{title}
%% Default values.
\date{\today}
%% Make an MLA date format in order to handle the above default date
%% value.
\usepackage[calc]{datetime2}
\DTMnewdatestyle{mladate}{%
\renewcommand{\DTMdisplaydate}[4]{##3 \DTMmonthname{##2} ##1}
\renewcommand{\DTMDisplaydate}{\DTMdisplaydate}}
\DTMsetdatestyle{mladate}
%% Define a general command for inserting MLA-style headers.
\newenvironment{header}{
\begingroup%
\rmfamily%
\fontsize{12}{2}%
\setlength{\parindent}{0pt}
}{%
\endgroup%
}
%% And a convenience function for the most common case.
\newcommand*{\makeheader}{%
\begin{header}
\ifno{firstname}{
\ifno{lastname}{}{
\get{lastname} \par
}
}{
\ifno{lastname}{
\get{firstname} \par
}{
\get{firstname}~\get{lastname} \par
}
}
\ifno{professor}{}{
\get{professor} \par
}
\ifno{class}{}{
\get{class} \par
}
\ifno{date}{}{
\get{date} \par
}
\end{header}%
\begin{centered}
\get{title}
\end{centered}%
}
\def\maketitle{
\makeheader
\indent
}
\newcommand*{\makeworkscited}{%
\if@workscitedclearpage%
\pagebreak%
\fi%
\printbibliography}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Sectioning commands
\renewcommand \thesection{\@arabic\c@section.}
\renewcommand\thesubsection{\thesection\@arabic\c@subsection}
\renewcommand \section{\@startsection
{section}
{1}
{\z@}%
{\z@}%
{\lineskip}%
{\normalfont}}
\renewcommand \subsection{\@startsection
{subsection}
{2}
{\z@}%
{\z@}%
{\lineskip}%
{\normalfont}}
\renewcommand\subsubsection{\@startsection
{subsubsection}
{3}
{\z@}%
{\z@}%
{\lineskip}%
{\normalfont}}
\renewcommand \paragraph{\@startsection
{paragraph}
{4}
{\z@}%
{\z@}%
{\lineskip}%
{\normalfont}}
\renewcommand \subparagraph{\@startsection
{subparagraph}
{5}
{\parindent}%
{\z@}%
{\lineskip}%
{\normalfont}}
%% Formatting section headings
\def\section{\@startsection{section}{1}{\z@}{-5.25ex plus -1ex minus
-.2ex}{1.5ex plus .2ex}{\center}}
\def\thesection{\arabic{section}.}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Works cited
%% Use American-style quotation marks.
\usepackage[american]{babel}
%% Hyperlink bibliography entries.
\usepackage[hidelinks]{hyperref}
%% Package doing all of our bibliography stuff.
\usepackage[style=mla,mladraft=true,annotation=true]{biblatex}
%% Bibliography commands
\DeclareFieldFormat{ibidpostnote}{#1}%
\renewbibmacro*{cite:idem}{%
\ifsingletitle%
{\iffieldundef{postnote}%
{\usebibmacro{cite:name}}%
{\unspace\global\boolfalse{cbx@named}}}%
{\addspace\global\boolfalse{cbx@named}}}
\renewbibmacro*{cite:mla:title:internal}{% 0.7.1 new internal macro
\ifbool{cbx@named}%
{\unspace\addcomma\addspace}%
{}%
\iffieldundef{title}%
{\iffieldequalstr{entrytype}{review}%
{\printtext[bibhyperref]{\printtext{\bibstring{reviewof}%
\addspace\printfield{booktitle}}}}%
{\ifthenelse{\iffieldequalstr{entrytype}{suppbook}% 0.7.1
\OR\iffieldequalstr{entrytype}{suppcollection}}%
{\printtext[bibhyperref]{%
\printfield[mla:capital]{entrysubtype}}}%
{}}}%
{\printtext[bibhyperref]{%
\printfield[citetitle:\strfield{entrytype}]{labeltitle}}}}%
\renewbibmacro*{cite:mla:title}{% 0.7.1 tidied up
\unspace%
\ifnameundef{labelname}%
{\unspace%
\printtext[bibhyperref]{%
\printfield[citetitle:\strfield{entrytype}]{labeltitle}}%
\iffieldundef{postnote}%
{}%
{\addspace}}%
{\ifsingletitle%
{}%
{\usebibmacro{cite:mla:title:internal}\addspace}}%
\ifthenelse{\iffieldequalstr{entrytype}{review}%
\and\ifnameundef{author}%
\and\iffieldundef{title}}%
{\printtext[bibhyperref]%
{\unspace\printtext{\bibcpstring{reviewof}%
\addspace\printfield{booktitle}}}}%
{}}%
\DeclareCiteCommand{\cite}[\mkbibparens]
{\usebibmacro{prenote}}%
{\usebibmacro{citeindex}%
\usebibmacro{cite:mla}}{}
{\usebibmacro{postnote}}
%% Annotations for the bibliography
\renewbibmacro{finentry}{% Renew the annotation macro
\finentry
\iffieldundef{annotation}%
{}%
{\ifbool{bbx@annotation}%
% Make the annotation look like a quotation and remove the
% indent
{\begin{quotation}\noindent%
\printfield{annotation}%
\end{quotation}}%
{}}%
}
\newenvironment{outline}
{
\renewcommand{\labelenumi}{\Roman{enumi}.}
\renewcommand{\labelenumii}{\Alph{enumii}.}
\renewcommand{\labelenumiii}{\arabic{enumiii}.}
}{}