-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpredoc.cls
150 lines (136 loc) · 3.72 KB
/
predoc.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
% predoc.cls
% Preprint template class
% 01.09.2022 Yann McLatchie yann.mclatchie (at) aalto.fi
% --- Class structure: identification part
% ---
\ProvidesClass{predoc}[01.09.2022 version 1.00 Preprint template]
\NeedsTeXFormat{LaTeX2e}
% --- Class structure: declaration of options part
% ---
% This class extends the article class
% Read all the documentclass options; pass them to article,
% unless the file "<currentoption>.min" exists, then it is loaded
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions*
% --- Class structure: execution of options part
% ---
\ProcessOptions \relax
% --- Class structure: declaration of options part
% ---
\LoadClass{article}
% Use custom fonts
\RequirePackage[utf8]{inputenc}
\RequirePackage{newtxtext} % times
\RequirePackage[scaled=.95]{cabin} % sans serif
\RequirePackage[varqu,varl]{inconsolata} % typewriter
\RequirePackage{amsmath,amsthm}
\RequirePackage[varg]{newtxmath}
% Finer resolution type
\RequirePackage{microtype}
% Section heads and title
\RequirePackage{titlesec}
\titleformat*{\section}{\Large\bfseries\sffamily}
\titleformat*{\subsection}{\large\bfseries\sffamily}
\titleformat*{\subsubsection}{\bfseries\sffamily}
\titleformat*{\paragraph}{\bfseries\sffamily}
% make abstract title \sffamily
\RequirePackage{abstract}
\renewcommand\abstractnamefont{\bfseries\sffamily}
% Custom title section
\makeatletter
\def\@maketitle{%
\newpage%
\null%
\begin{center}%
\vspace*{-5em} %
\let\footnote\thanks %
{\sffamily\bfseries\LARGE \@title %
\par
}
{\large
\lineskip .5em
\begin{tabular}[t]{c}
\baselineskip=12pt
\@author
\end{tabular}
\par
}
{\large \@date}
\end{center}
\par
}
\makeatother
% Custom captions
\RequirePackage{caption}
\DeclareCaptionFormat{custom}
{%
{\small\sffamily#1#2} {\small #3}
}
\DeclareCaptionLabelSeparator{custom}{.}
\captionsetup{format=custom, labelsep=custom}
% Page layout
\RequirePackage[
a4paper,
margin=1in,
includehead,
includefoot
]{geometry}
% Author block
\RequirePackage{authblk}
\renewcommand{\Authfont}{\normalsize \mdseries}
\renewcommand{\Affilfont}{\small \mdseries}
\setlength{\affilsep}{2pt}
% Headers and footers
\RequirePackage{fancyhdr}
\setlength{\headheight}{13.6pt}
% fancy head
\fancypagestyle{firstpage}{%
\fancyhf{} % clear all six fields
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
}
\fancypagestyle{followingpage}{%
\fancyhf{} % clear all six fields
\fancyhead[CO]{{\sffamily \mdseries \runauthor}}
\fancyhead[CE]{{\sffamily \mdseries \runtitle}}
\fancyfoot[CE,CO]{\sffamily \thepage}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
}
\pagestyle{followingpage}
\AtBeginDocument{\thispagestyle{firstpage}}
% References
\RequirePackage{natbib}
\RequirePackage{etoolbox}
\bibliographystyle{apalike}
%
% Patch natbib cittation hyperlinks
\makeatletter
% Patch case where name and year are separated by aysep
\patchcmd{\NAT@citex}
{\@citea\NAT@hyper@{%
\NAT@nmfmt{\NAT@nm}%
\hyper@natlinkbreak{\NAT@aysep\NAT@spacechar}{\@citeb\@extra@b@citeb}%
\NAT@date}}
{\@citea\NAT@nmfmt{\NAT@nm}%
\NAT@aysep\NAT@spacechar\NAT@hyper@{\NAT@date}}{}{}
% Patch case where name and year are separated by opening bracket
\patchcmd{\NAT@citex}
{\@citea\NAT@hyper@{%
\NAT@nmfmt{\NAT@nm}%
\hyper@natlinkbreak{\NAT@spacechar\NAT@@open\if*#1*\else#1\NAT@spacechar\fi}%
{\@citeb\@extra@b@citeb}%
\NAT@date}}
{\@citea\NAT@nmfmt{\NAT@nm}%
\NAT@spacechar\NAT@@open\if*#1*\else#1\NAT@spacechar\fi\NAT@hyper@{\NAT@date}}
{}{}
\makeatother
% Hyperrefs
\RequirePackage[
colorlinks=true,
linkcolor=red,
filecolor=black,
citecolor=black,
urlcolor=black,
]{hyperref}
\urlstyle{same}