-
Notifications
You must be signed in to change notification settings - Fork 7
/
nsf-proposal.cls
296 lines (275 loc) · 8.66 KB
/
nsf-proposal.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
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{nsf-proposal}[2024/04/30 memoir class for NSF proposals]
\RequirePackage{xstring} % for \IfEqCase and \IfEq
\RequirePackage{iftex} % to detect TeX engine
\newcommand{\setvalue}[2]{
\ifdefined #1
\renewcommand{#1}{#2}
\else
\newcommand{#1}{#2}
\fi
}
\setvalue{\nsfproposalfont}{cm}
\DeclareOption{arial}{
% Arial can only work with LuaTeX or XeTeX
\iftutex
\setvalue{\nsfproposalfont}{arial}%
\else
\ClassError{nsf-proposal}{option arial requires LuaLaTeX or XeLaTeX}%
\fi
}
\DeclareOption{courier-new}{
% Courier New can only work with LuaTeX or XeTeX
\iftutex
\setvalue{\nsfproposalfont}{courier-new}%
\else
\ClassError{nsf-proposal}{option courier-new requires LuaLaTeX or XeLaTeX}%
\fi
}
\DeclareOption{helvetica}{
\setvalue{\nsfproposalfont}{helvetica}
}
\DeclareOption{palatino}{
\setvalue{\nsfproposalfont}{palatino}
}
\DeclareOption{palatino-linotype}{
% Palatino Linotype can only work with LuaTeX or XeTeX
\iftutex
\setvalue{\nsfproposalfont}{palatino-linotype}%
\else
\ClassError{nsf-proposal}{option palatino-linotype requires LuaLaTeX or XeLaTeX}%
\fi
}
\DeclareOption{times-new-roman}{
% Times New Roman can only work with LuaTeX or XeTeX
\iftutex
\setvalue{\nsfproposalfont}{times-new-roman}%
\else
\ClassError{nsf-proposal}{option times-new-roman requires LuaLaTeX or XeLaTeX}
\fi
}
\newif\ifusetg
\usetgfalse % don't use TeX Gyre by default
\DeclareOption{tg}{%
% Use TeX Gyre font variants
\iftutex%
\usetgtrue%
\else%
\ClassError{nsf-proposal}{option tg requires LuaLaTeX or XeLaTeX}%
\fi%
}
\DeclareOption{9pt}{
\ClassError{nsf-proposal}{base font too small (<10pt)}
}
\DeclareOption{10pt}{
% if 10pt, can only be:
% - Arial/Helvetica/Palatino,
% - Palatino Linotype, or
% - Courier New
%
% https://new.nsf.gov/policies/pappg/23-1/ch-2-proposal-preparation#2C2
% https://new.nsf.gov/policies/pappg/23-1/ch-2-proposal-preparation#_ftn6
% https://new.nsf.gov/policies/pappg/24-1/ch-2-proposal-preparation#ch2C2
% https://new.nsf.gov/policies/pappg/24-1/ch-2-proposal-preparation#ftn7
\IfEqCase{\nsfproposalfont}{%
{arial}{}%
{courier-new}{}%
{helvetica}{}%
{palatino}{}%
{palatino-linotype}{}%
}[\ClassError{nsf-proposal}{base font too small (10pt) for selected font \nsfproposalfont}]
}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{memoir}}
\ProcessOptions
\LoadClass[openany]{memoir}
% All the font setup we can't do while processing options
\IfEqCase{\nsfproposalfont}{%
{arial}{%
\ifusetg%
\ClassWarning{nsf-proposal}{option tg has no effect with option arial}%
\fi%
\RequirePackage{fontspec}%
\RequirePackage{unicode-math}
\setmainfont{Arial}%
\setsansfont{Arial}%
\setmathfont{latinmodern-math.otf}%
\setmathfont[range=up]{Arial}%
\setmathfont[range=it]{Arial Italic}%
\setmathfont[range=bfup]{Arial Bold}%
\setmathfont[range=bfit]{Arial Bold Italic}%
}%
{cm}{%
\ifusetg%
\ClassWarning{nsf-proposal}{option tg has no effect with (possibly default) option cm}%
\fi%
}%
{courier-new}{%
\ifusetg%
\RequirePackage{fontspec}%
\setmainfont{texgyrecursor}[
Extension = .otf,
UprightFont = *-regular,
ItalicFont = *-italic,
BoldFont = *-bold,
BoldItalicFont = *-bolditalic,
Ligatures = NoCommon,
]%
\else%
\RequirePackage{fontspec}%
\RequirePackage{unicode-math}
\setmainfont{Courier New}%
\setsansfont{Courier New}%
\setmathfont{latinmodern-math.otf}%
\setmathfont[range=up]{Courier New}%
\setmathfont[range=it]{Courier New Italic}%
\setmathfont[range=bfup]{Courier New Bold}%
\setmathfont[range=bfit]{Courier New Bold Italic}%
\fi%
}%
{helvetica}{%
\ifusetg%
\RequirePackage{fontspec}%
\setmainfont{texgyreheros}[
Extension = .otf,
UprightFont = *-regular,
ItalicFont = *-italic,
BoldFont = *-bold,
BoldItalicFont = *-bolditalic,
]%
\else%
\iftutex%
\RequirePackage{fontspec}%
\setmainfont{Helvetica}% for lualatex and xelatex, at least on Mac
\else%
\RequirePackage[scaled]{helvet}%
\RequirePackage{sansmath}%
\renewcommand{\familydefault}{\sfdefault}% for pdflatex, ends up with Nimbus Sans L
\fi%
\fi%
}%
{palatino}{%
\ifusetg%
\RequirePackage{fontspec}%
\setmainfont{texgyrepagella}[
Extension = .otf,
UprightFont = *-regular,
ItalicFont = *-italic,
BoldFont = *-bold,
BoldItalicFont = *-bolditalic,
]%
\else%
\iftutex%
\RequirePackage{fontspec}%
\setmainfont{Palatino}%
\else%
\RequirePackage{mathpazo}%
\fi%
\fi%
}%
{palatino-linotype}{%
\ifusetg%
\ClassWarning{nsf-proposal}{option tg has no effect with option palatino-linotype}%
\fi
\RequirePackage{mathpazo}
\RequirePackage{fontspec}
\setmainfont{Palatino Linotype}%
}%
{times-new-roman}{%
\ifusetg%
\RequirePackage{fontspec}%
\RequirePackage{unicode-math}
\setmainfont{texgyretermes}[
Extension = .otf,
UprightFont = *-regular,
ItalicFont = *-italic,
BoldFont = *-bold,
BoldItalicFont = *-bolditalic,
]%
\setmathfont{latinmodern-math.otf}%
\else%
\RequirePackage{fontspec}%
\RequirePackage{unicode-math}
\setmainfont{Times New Roman}%
\setmathfont{latinmodern-math.otf}%
\setmathfont[range=up]{Times New Roman}%
\setmathfont[range=it]{Times New Roman Italic}%
\setmathfont[range=bfup]{Times New Roman Bold}%
\setmathfont[range=bfit]{Times New Roman Italic}%
\fi%
}%
}
% Page setup
\setstocksize{11in}{8.5in}
\setlrmarginsandblock{1.0in}{1.0in}{*}
\setulmarginsandblock{1.0in}{1.05in}{*}
\raggedbottom
\checkandfixthelayout
% Clear out page headers/footers
\AtBeginDocument{%
\aliaspagestyle{chapter}{empty}%
\makeoddhead{headings}{}{}{}%
\makeevenhead{headings}{}{}{}%
}
% NSF's PDF parsers are too picky about the definition of ``no more than 6
% lines per inch'', so we add a bit of spacing when we're right at that
% limit for 10pt documents.
\AtBeginDocument{%
\makeatletter%
\ifdimcomp{\dimexpr\f@size pt}{>}{10pt}{% do nothing if >10pt
}{% set lengths if <=10pt
\setlength{\baselineskip}{12.05pt}%
\@ifpackageloaded{biblatex}{%
% Not sure why biblatex doesn't want to inherit the default spacing
\appto{\bibsetup}{\setSpacing{1.004}}%
}{}%
}%
\makeatother%
}
% Document division formatting: headstyle settings apply to that level and
% below, unless overridden
\chapterstyle{article} % no page breaks between chapters
% Unnumbered chapters, larger bold font, centered, whitespace before/after
\renewcommand{\chaptitlefont}{\normalfont\large\bfseries\centering}
\setlength{\beforechapskip}{0.25\baselineskip}
\setlength{\afterchapskip}{0.25\baselineskip}
\renewcommand{\printchapternum}{}
% Lettered sections, normal size bold font, centered, whitespace before/after
\setbeforesecskip{-0.45\baselineskip}
\setaftersecskip{0.25\baselineskip}
\setsecheadstyle{\normalfont\bfseries\centering}
\renewcommand{\thesection}{\Alph{section}}
\setsecnumformat{\csname the#1\endcsname:\quad}
% Lettered/numbered subsections, normal size bold font, whitespace before/after
\setbeforesubsecskip{-0.25\baselineskip}
\setaftersubsecskip{0.25\baselineskip}
\setsubsecheadstyle{\normalfont\bfseries}
% Unnumbered subsubsections and paragraphs, some whitespace before, inline bold
% title, whitespace after
\setsecnumdepth{subsection}
\setbeforesubsubsecskip{0.25\baselineskip}
\setaftersubsubsecskip{-\baselineskip}
\setbeforeparaskip{0.25\baselineskip}
\setafterparaskip{-\baselineskip}
% Number figures and tables continuously, not by chapter
\counterwithout{table}{chapter}
\counterwithout{figure}{chapter}
% URLs and other hyperlinks
\RequirePackage[bookmarks=false,
pdfpagelabels=false,
hyperfootnotes=false,
hyperindex=false,
pageanchor=false]{hyperref}
% How to turn on/off certain types (e.g. citation, url, file) of hyperref
% links? https://tex.stackexchange.com/a/117676
\let\saved@hyper@linkurl\hyper@linkurl
%\let\saved@hyper@linkfile\hyper@linkfile
\let\saved@hyper@link@\hyper@link@
\AtBeginDocument{%
% Since the whole document is affected, only the \begin part of
% environment `NoHyper' is needed.
\NoHyper
\let\hyper@linkurl\saved@hyper@linkurl % needed by \url
%\let\hyper@linkfile\saved@hyper@linkfile % needed by \href{<file>}
\let\hyper@link@\saved@hyper@link@ % needed by \href{<url>}
}
\endinput