-
Notifications
You must be signed in to change notification settings - Fork 189
/
jdf.cls
353 lines (296 loc) · 9.83 KB
/
jdf.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
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{jdf}[2022/05/22 v2.2.0 Joyner Document Format]
\newcommand{\papersize}{letterpaper} % Default value
\DeclareOption{a4paper}{\renewcommand{\papersize}{a4paper}}
\DeclareOption{letterpaper}{\renewcommand{\papersize}{letterpaper}}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}} % Pass through any options to the base class
\ProcessOptions\relax % Process given options
\LoadClass{article}
\RequirePackage{etoolbox} % Required for conditional logic
%%
% Page layout
\ifstrequal{\papersize}{a4paper}{ % A4 paper page geometry settings
% The text block is approximately 141.3x228.3mm, which is a ratio of 1:phi (and the ratio of the top margin to the bottom margin is also 1:phi)
\RequirePackage[
a4paper,
top=26.25mm,
bottom=42.472mm,
left=34.361mm,
right=34.361mm,
footskip=16.222mm, % Space from the bottom margin to the baseline of the footer
%showframe, % Uncomment to show how the type block is set on the page
]{geometry}
}{ % Default (letterpaper) page geometry settings
% The text block is 5.5x8.5in, which is exactly 1/2 the page size, divided lengthwise
\RequirePackage[
\papersize,
top=1in,
bottom=1.5in,
left=1.5in,
right=1.5in,
footskip=0.5in, % Space from the bottom margin to the baseline of the footer
%showframe, % Uncomment to show how the type block is set on the page
]{geometry}
}
\RequirePackage{hyperref} % Required for including links
\RequirePackage{changepage}
\RequirePackage[defaultlines=2,all]{nowidow} % Prevent line breaks in short paragraphs
%%
% Font stuff
% Encoding
\RequirePackage[T1]{fontenc}
\RequirePackage[utf8]{inputenc}
\RequirePackage[english]{babel}
% Set fonts
\RequirePackage[osf]{mathpazo} % Palatino with oldstyle figures
\newcommand\liningnums[1]{\fontfamily{ppl}\selectfont#1} % Enable switch to lining nums
\RequirePackage{amsmath, amssymb}
\RequirePackage{eulervm}
\RequirePackage[scaled=.8819]{sourcecodepro} % Source Code Pro typeface for monospace
\RequirePackage{csquotes}
% Letterspacing
\RequirePackage[
activate={true,nocompatibility},
final,
kerning=true,
spacing=true,
factor=1260,
stretch=10,
shrink=10
]{microtype}
\frenchspacing % Prevent double whitespaces between sentences
\lsstyle
\newcommand\lsstylehelp[1]{\edef\MT@letterspace@{#1}\lsstyle} % Enable change to letterspacing
\newcommand{\hairsp}{\ifmmode\mskip1mu\else\kern0.083em\fi}
\renewcommand{\,}{\ifmmode\mskip1mu\else\kern0.167em\fi}
% Font sizes
\renewcommand\huge{%
\@setfontsize\huge{22}{36}%
}
\renewcommand\normalsize{%
\@setfontsize\normalsize{11}{17}%
}
\renewcommand\large{%
\@setfontsize\large{17}{22}
}
\renewcommand\small{%
\@setfontsize\small{8.5}{14}%
}
\renewcommand\footnotesize{%
\@setfontsize\small{8.5}{14}%
}
% Paragraph indentation
\setlength{\parindent}{0pt}
\setlength{\parskip}{8.5pt}
%%
% Title
\RequirePackage{titlesec}
\newcommand{\email}[1]{%
\def \@email {#1}
}
\renewcommand{\maketitle}{\bgroup
\begin{center}
{\large\selectfont\liningnums\lsstylehelp{0} \par\@title\par}
{\normalfont \@author\\\@email}%
\vspace{-8.5pt}
\end{center}
\hypersetup{
pdftitle=\@title,
pdfauthor=\@author
}
}
%%
% Abstract
\renewenvironment{abstract}{%
\begin{center}
\begin{adjustwidth}{0.5in}{0.5in}
\normalfont%
\textbf{\textit{Abstract\hairsp—\hairsp}}\ignorespaces
}{%
\end{adjustwidth}
\vspace{-8.5pt}
\end{center}
}
%%
% Quotation
\renewenvironment{quotation}{%
\begin{center}
\vspace{-8.5pt}
\begin{adjustwidth}{0.5in}{0.5in}
\noindent }{%
\end{adjustwidth}
\vspace{-8.5pt}
\end{center}
}
%%
% Headings
% Heading 1
\titleformat{\section} % Section type being modified
{\normalfont\liningnums\lsstylehelp{60}\bfseries}
{\thesection}{0.333em} % Space between the title and label
{\MakeUppercase}
\titlespacing*{\section}{0pt}{0pt}{0pt}
% Heading 2
\titleformat{\subsection}
{\normalfont\bfseries}
{\thesubsection}{0.4em}{}
\titlespacing*{\subsection}{0pt}{0pt}{0pt}
% Heading 3
\titleformat{\subsubsection}
{\normalfont\bfseries\itshape}
{\textup{\thesubsubsection}}{0.4em}{}
\titlespacing*{\subsubsection}{0pt}{0pt}{0pt}
% Heading 4
\newcommand{\subsubsubsection}[1]{
\textbf{\textit{#1}}\hairsp—\hairsp\ignorespaces
}
\renewcommand{\paragraph}[1]{
\textbf{\textit{#1}}\hairsp—\hairsp\ignorespaces
}
%%
% Captions
% Note: don't use "figures" when floating is not desired. See:
% https://texblog.net/latex-archive/uncategorized/prevent-floating-image-figure-table/
\RequirePackage{caption} % Required for customising captions
\DeclareCaptionFormat{letterspaced}{%
\lsstylehelp{20}{%
#1#2#3\par%
}{}%
}
\captionsetup{hypcap=false} % Resolves warning
\captionsetup{format=letterspaced} % Use the letter spaced caption style by default
\captionsetup{margin=1in} % Margin on the left and right sides of captions
\captionsetup{justification=justified, singlelinecheck=false} % Left-align and justify captions
\captionsetup{font=small} % Reduce font size
\captionsetup{labelfont={bf,it}} % BoldItalic label and number
\DeclareCaptionLabelSeparator{emdash}{\hairsp—\hairsp} % Custom caption label separator
\captionsetup{labelsep=emdash} % Change the default colon between number and label to use the custom separator
\RequirePackage{mdframed}
\mdfdefinestyle{nonbreakingframe}{nobreak,linecolor=white,leftmargin=0,rightmargin=0,innerleftmargin=0,innerrightmargin=0,innertopmargin=0,innerbottommargin=0,skipabove=8.5pt,skipbelow=0}
\newenvironment{jdffigure}{%
\begin{mdframed}[style=nonbreakingframe]
\begin{center}
}{%
\vspace{-8.5pt}
\end{center}
\end{mdframed}
}
%%
% Lists
\RequirePackage{enumitem} % Required for list customisation
\setlist{leftmargin=*, noitemsep, nolistsep} % No left margin and space around/within lists
\setlist[itemize]{label={\tiny\textsuperscript{\textbullet}}}
%%
% Image stuff
\RequirePackage{graphicx} % Required for including images
\graphicspath{{Figures/}{./}} % Specifies where to look for included images
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
% Set default figure placement to htbp
\def\fps@figure{htbp}
%%
% Tables
\RequirePackage{siunitx} % Required for "S" to align by decimal
% Set default table placement to htbp
\def\fps@table{htbp}
\def\fps@longtable{htbp}
\RequirePackage{booktabs} % Required for better horizontal rules in tables
\RequirePackage{array} % Required for manipulating table columns
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}p{#1}} % Define a new right-aligned paragraph column type
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}} % Define a new left-aligned (no justification) paragraph column type
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}} % Define a new centered paragraph column type
\setlength\lightrulewidth{0.03em}
\newenvironment{jdftable}{%
\begin{mdframed}[style=nonbreakingframe]
\begin{center}
}{%
\vspace{-8.5pt}
\end{center}
\end{mdframed}
}
%%
% Footnotes
\RequirePackage[bottom]{footmisc} % Make footnotes flush w/ the bottom of the page
\setlength{\skip\footins}{17pt}
\setlength{\footnotesep}{8.5pt}
\RequirePackage{footnotebackref} % Add backreferencing
\long\def\@makefntext#1{
\lsstylehelp{20}{
{\footnotesize\@thefnmark~#1} % Footnote text position and width
}
}
%%
% References
\RequirePackage[
bibstyle=authoryear,
dashed=false,
sorting=ynt,
natbib=true,
maxbibnames=99
]{biblatex}
\DeclareFieldFormat{bibentrysetcount}{\mkbibparens{\mknumalph{#1}}}
\DeclareFieldFormat{labelnumberwidth}{#1.}
\defbibenvironment{bibliography}
{\list
{\printtext[labelnumberwidth]{%
\printfield{labelprefix}%
\printfield{labelnumber}}
}%
{\setlength{\labelwidth}{\labelnumberwidth}%
\setlength{\leftmargin}{\labelwidth}%
\setlength{\labelsep}{\biblabelsep}%
\addtolength{\leftmargin}{\labelsep}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}}%
\renewcommand*{\makelabel}[1]{\hss##1}}
{\endlist}
{\item}
\DeclareNameAlias{sortname}{family-given}
% editing answer by moewe to get multiyear things going (2021a, 2021b)
% https://tex.stackexchange.com/questions/312539/unwanted-comma-between-author-and-year-using-citet-command
\DeclareCiteCommand{\citeyear}
{\usebibmacro{prenote}}
{\printfield{year}\printfield{extrayear}}
{\multicitedelim}
{\usebibmacro{postnote}}
\DeclareCiteCommand{\citeyearpar}[\mkbibparens]
{\usebibmacro{prenote}}
{\printfield{year}\printfield{extrayear}}
{\multicitedelim}
{\usebibmacro{postnote}}
% Inline citations
\renewcommand{\cite}[1]{\citeauthor{#1}, \citeyear{#1}}
\renewcommand{\citep}[1]{(\citeauthor{#1}, \citeyear{#1})}
\newcommand{\citeinl}[1]{\citeauthor{#1} (\citeyear{#1})}
% Missing Author
\newcommand{\citenoauth}[1]{\citetitle{#1}, \citeyear{#1}}
\newcommand{\citenoauthp}[1]{(\citetitle{#1}, \citeyear{#1})}
% Missing Author and Year
\newcommand{\citenoauthdate}[1]{\citetitle{#1}, n.d.}
\newcommand{\citenoauthdatep}[1]{(\citetitle{#1}, n.d.)}
% Missing Year
\newcommand{\citeauthnodate}[1]{\citeauthor{#1}, n.d.}
\newcommand{\citeauthnodatep}[1]{(\citeauthor{#1}, n.d.)}
%%
% Metadata
\RequirePackage{xcolor} % Required for defining custom colours
\hypersetup{
% bookmarks=true,
% bookmarksopen=true,
pdfpagemode=UseOutlines,
colorlinks=true,
citecolor=blue,
urlcolor=blue,
linkcolor=blue
}
%% General Tex Notes
% Remove leading space on tables with "${}": https://stackoverflow.com/a/3155768/3219667
% Why \arraybackslash: https://tex.stackexchange.com/a/387741/224014
% Trailing comment swallows the end-of-line character: https://tex.stackexchange.com/a/7459/224014
%% Utilities
% Source: https://tex.stackexchange.com/a/484219/224014
\newcommand{\comment}[1]{}