-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmanuscript.cls
185 lines (167 loc) · 7.63 KB
/
manuscript.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
% Copyright 2022 Darwin Bautista
%
% Licensed under the Apache License, Version 2.0 (the "License");
% you may not use this file except in compliance with the License.
% You may obtain a copy of the License at
%
% https://www.apache.org/licenses/LICENSE-2.0
%
% Unless required by applicable law or agreed to in writing, software
% distributed under the License is distributed on an "AS IS" BASIS,
% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
% See the License for the specific language governing permissions and
% limitations under the License.
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{manuscript}[2022/02/24 NGSE Manuscript]
% ----- Class Options -----
\RequirePackage{scrlfile} % provides \AfterPackage{}
\RequirePackage{etoolbox}
\newtoggle{proposal}
\newtoggle{review}
\newtoggle{amsthm}
% Proposal version
\DeclareOption{proposal}{\toggletrue{proposal}}
% Review version. Show line numbers and timestamp title page.
\DeclareOption{review}{\toggletrue{review}}
% Use 1.5 line spacing instead of double
\DeclareOption{onehalfspacing}{\AtEndOfClass{\onehalfspacing}}
% Place page numbers in the header instead of the footer
\DeclareOption{pagenumhead}{\AtEndOfClass{%
\RequirePackage[singlespacing=true]{scrlayer-scrpage}
\clearpairofpagestyles % Remove page numbers from the footer
\ohead[\pagemark]{\pagemark} % Place page numbers in the "outer" part of header (top-right for one-side)
}}
% Customized biblatex styles
\DeclareOption{ieee}{\PassOptionsToPackage{bibstyle=ieee,citestyle=numeric-comp,sorting=nty,dashed=false}{biblatex}}
\DeclareOption{apa}{%
\PassOptionsToPackage{style=apa}{biblatex}
\AfterPackage{biblatex}{\setlength\bibitemsep{0.2\baselineskip}} % add a bit of separation between bib items
}
% Use the `amsthm` package. Added as an option to ensure correct loading order w.r.t. newtx.
\DeclareOption{amsthm}{\toggletrue{amsthm}}
% Pass unknown options to the scrbook class
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{scrbook}}
\ProcessOptions\relax
% ----- \printpreliminarypages command -----
% Smaller font size and centered title for prelim chapters
\newcommand{\@prelimchapterstyle}{\addtokomafont{chapter}{\LARGE}\let\raggedchapter\centering}
\newcommand{\printpreliminarypages}{%
\iftoggle{proposal}{%
\begin{singlespace}
\begin{titlepage}\input{prelim_pages/title_proposal}\end{titlepage}
\end{singlespace}
}{%
\begin{singlespace}
\begin{titlepage}\input{prelim_pages/title}\end{titlepage}
\newpage
\input{prelim_pages/univ_permission}
\newpage
\phantomsection % anchor for hyperref in ToC
\addcontentsline{toc}{chapter}{Approval Page}
\input{prelim_pages/approval}
\end{singlespace}
{\@prelimchapterstyle\input{prelim_pages/acknowledgments}}
}
{\@prelimchapterstyle\input{prelim_pages/abstract}}
\begin{singlespace}
\microtypesetup{protrusion=false} % Disable protrusion
\tableofcontents
\listoftables
\listoffigures
\end{singlespace}
}
% ----- Abbreviations (extracted from CVPR template) -----
% Add a period to the end of an abbreviation unless there's one already, then \xspace.
\RequirePackage{xspace}
\DeclareRobustCommand\onedot{\futurelet\@let@token\@onedot}
\newcommand\@onedot{\ifx\@let@token.\else.\null\fi\xspace}
\newcommand\eg{\emph{e.g}\onedot} \newcommand\Eg{\emph{E.g}\onedot}
\newcommand\ie{\emph{i.e}\onedot} \newcommand\Ie{\emph{I.e}\onedot}
\newcommand\cf{\emph{cf}\onedot} \newcommand\Cf{\emph{Cf}\onedot}
\newcommand\etc{\emph{etc}\onedot} \newcommand\vs{\emph{vs}\onedot}
\newcommand\wrt{w.r.t\onedot} \newcommand\dof{d.o.f\onedot}
\newcommand\iid{i.i.d\onedot} \newcommand\wolog{w.l.o.g\onedot}
\newcommand\etal{\emph{et al}\onedot}
% ----- Start of internals -----
% listof=totoc: add List of Tables, Figures to ToC
% captions=tableheading: adjusts the spacing of captions placed above tables
\LoadClass[12pt,oneside,listof=totoc,captions=tableheading]{scrbook}
% --- Metadata ---
\input{manuscript-meta}
\PassOptionsToPackage{pdflang=en-PH,pdftitle={\Title},pdfauthor={\Student},pdfkeywords={\Keywords},pdfsubject={\Degree}}{hyperref}
% Infer manuscript type from the degree. FIXME: comparison should be case-insensitive
\RequirePackage{xstring}
\IfBeginWith{\Degree}{Master}{\newcommand\Type{Thesis}}{\newcommand\Type{Dissertation}}
% --- Page size and margins ---
\RequirePackage[margin=1in,footskip=0.6in,\iftoggle{proposal}{a4paper}{left=1.5in,letterpaper}]{geometry}
% --- Indents and line spacing ---
\setlength{\parindent}{0.5in} % Half-inch indents
\RequirePackage{indentfirst} % Indent the first paragraph of a section
\RequirePackage[doublespacing]{setspace} % Set line spacing globally
% --- Hyphenation and typesetting ---
\RequirePackage[english]{babel}
\RequirePackage[activate={true,nocompatibility},final,tracking=true,kerning=true,spacing=true,factor=1100]{microtype}
\microtypecontext{spacing=nonfrench}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
% --- Fonts (load after babel) ---
\RequirePackage{newtxtext} % Use Times Roman fonts
\RequirePackage[zerostyle=d,straightquotes]{newtxtt} % Enhancement of typewriter fonts
\iftoggle{amsthm}{\RequirePackage{amsmath,amsthm}}{}
\RequirePackage{newtxmath} % Use Times Roman-compatible math fonts
\RequirePackage[T1]{fontenc}
% --- General style tweaks ---
\pagestyle{plain} % No headers
\addtokomafont{disposition}{\rmfamily} % Use Roman font for section headings
\setkomafont{caption}{\footnotesize} % Smaller caption font
\setkomafont{captionlabel}{\itshape} % Italic caption label
\renewcommand*{\captionformat}{~} % Space separator
\setcapindent{0pt} % Don't indent captions
% --- ToC tweaks ---
\addto\captionsenglish{\renewcommand{\contentsname}{Table of Contents}} % Rename ToC
\setuptoc{toc}{totoc} % Add a ToC entry to the ToC
\PassOptionsToPackage{titletoc}{appendix} % Prepend 'Appendix ' to each listing in the ToC
% --- Configure packages loaded by main.tex ---
\AfterPackage{biblatex}{\setcounter{biburlnumpenalty}{9000}} % Make sure long URLs have line breaks
\PassOptionsToPackage{capitalize,nameinlink}{cleveref}
\AfterPackage{cleveref}{%
\crefname{section}{Sec.}{Secs.}
\Crefname{section}{Section}{Sections}
\crefname{table}{Tab.}{Tabs.}
\Crefname{table}{Table}{Tables}
}
% --- Wrap \chapter in a singlespace env for vspace consistency ---
\NewCommandCopy\chapter@orig\chapter
\RequirePackage{xparse}
\RenewDocumentCommand \chapter { s o m } {%
\edef\@optargs{\IfBooleanT{#1}{*}\IfValueT{#2}{[#2]}}
\if \baselinestretch \setspace@singlespace % Already single-spaced
\expandafter\chapter@orig\@optargs{#3}
\else
\let\baselinestretch@orig\baselinestretch % Save original spacing
\singlespace\expandafter\chapter@orig\@optargs{#3}
\setstretch{\baselinestretch@orig} % Restore spacing
\fi
}
% --- Review mode ---
\iftoggle{review}{%
% Add timestamp to the title page
\RequirePackage{datetime2}
\renewcommand{\SubmissionDate}{\texttt{\DTMnow}}
% Show line numbers
\RequirePackage{lineno}
\RequirePackage{color}
\renewcommand{\linenumberfont}{\normalfont\footnotesize\sffamily\color[rgb]{.5,.5,1}} % blue font color, larger font
\setlength\linenumbersep{1cm} % wider separation
% Line numbers in both margins (adapted from: https://tex.stackexchange.com/a/199593)
\renewcommand\makeLineNumberLeft{%
\linenumberfont
\llap{\hss\LineNumber\hskip\linenumbersep} % left margin
\hskip\columnwidth\hskip\linenumbersep
\rlap{\hb@xt@\linenumberwidth{\hss\LineNumber}\hss} % right margin
}
\leftlinenumbers % Re-issue [left] option
\linenumbers
}{}
% FIXME: biblatex is using the obsolete command \tt for some reason.
\def\tt{\normalfont\ttfamily}
\endinput