summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/brandeis-problemset/brandeis-problemset.cls
blob: 3d18eea40e72d87f4cd0763d3d091ba875ec75ed (plain)
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
\ProvidesClass{brandeis-problemset}[2019/04/15 0.5.5 COSI problem sets at
	Brandeis University]
\NeedsTeXFormat{LaTeX2e}
% Description: A document class for Brandeis University's computer science
%              courses' problem sets
% Homepage:    https://github.com/9999years/brandeis-problemset
%              https://ctan.org/pkg/brandeis-problemset
% Maintainer:  Rebecca Turner <rebeccaturner@brandeis.edu>
%
% Copyright 2019 Rebecca Turner
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'. On 2021-05-01 (May
% 1st), this work will have the LPPL maintenance status `unmaintained'.
%
% The Current Maintainer of this work is Rebecca Turner.

\RequirePackage{xparse}
\RequirePackage{kvoptions}

\SetupKeyvalOptions{
	family=bps,
	prefix=bps@,
}

% passes an option to rebeccastyle
\newcommand{\bps@passoption}[1]
	{\DeclareVoidOption{#1}{%
		\PassOptionsToPackage{\CurrentOption}{brandeis-problemset}%
	}}

% pass a comma-list of options
\NewDocumentCommand{\bps@passoptions}{>{\SplitList{,}} m}
	{\ProcessList{#1}{\bps@passoption}}

\bps@passoptions{
	scheme,     noscheme,
	pseudocode, nopseudocode,
	assembly,   noassembly,
	gantt,      nogantt,
	solution,   nosolution,
	tabu,       notabu,
	maketitle,  nomaketitle,
	header,     noheader,
	listings,   nolistings,
	config,     noconfig,
}

\NewDocumentCommand{\bps@comploption}{O{false} m}{%
	\DeclareBoolOption[#1]{#2}%
	\DeclareComplementaryOption{no#2}{#2}}

\bps@comploption{antonella}
\bps@comploption{math}
\bps@comploption[true]{fonts}

\DeclareDefaultOption{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessKeyvalOptions*

\let\bps@comploption\relax
\let\bps@passoption\relax
\let\bps@passoptions\relax

\LoadClass[12pt]{article}

\RequirePackage[
	maketitle,
	header,
	listings,
]{brandeis-problemset}

% tables
\ifbps@tabu
	\RequirePackage{multirow}
	\RequirePackage{booktabs}
	\RequirePackage{longtable}
	\RequirePackage{tabu}
\fi

% formatting
\RequirePackage{enumitem}
\RequirePackage{titletoc}

% utility
\RequirePackage{hyperref}
\RequirePackage[
	letterpaper,
	margin=1.25in,
	tmargin=1.5in,
	bmargin=1.5in,
]{geometry}

% math
\ifbps@math
	% see note below
	\RequirePackage{mathtools}

	% for whatever reason, redefining this before the \begin{document}
	% has no effect
	\AtBeginDocument{\renewcommand{\Re}{\mathbb{R}}}
\fi

% fonts
% NOTE: The order these packages are loaded in is very important.
% - mathtools has to be loaded before these or overbrackets and such get
%   messed up
% - unicode-math overwrites a bunch of commands, so should be loaded after
%   amsmath and others
% - amsmath should be loaded after stix2 (not sure why, but the stix2
%   documentation specifies this) -- however, if we can use fontspec, we
%   just load the stix2 fonts without the stix2 package itself, so we load
%   amsmath before unicode-math (and the stix2 fonts)
\iffontspec@ok
	\ifbps@math
		\RequirePackage{amsmath}[2013/01/14]
		% unicode-math makes equations copy/pastable in pdf output
		\RequirePackage[
			warnings-off={mathtools-colon,mathtools-overbracket}
		]{unicode-math}
	\else
		\RequirePackage{fontspec}
	\fi
	\setmainfont[
		Extension      = .otf,
		UprightFont    = *-Regular,
		BoldFont       = *-Bold,
		ItalicFont     = *-Italic,
		BoldItalicFont = *-BoldItalic,
	]{STIX2Text}
	\ifbps@math
		\setmathfont[
			Extension = .otf,
			StylisticSet={
				1, % better caligraphic forms
				8, % upright integrals
			},
		]{STIX2Math}
	\fi
	\newcommand{\setcodefont}[2][]{%
		% don't fail if fontspec isn't loaded
		\@ifundefined{setmonofont}{}{%
			\let\pseudocodesymbolfont\ttfamily
			\setmonofont[#1]{#2}%
		}%
	}
\else
	\ifbps@math
		\RequirePackage[upint]{stix2}
		\RequirePackage{amsmath}[2013/01/14]
	\fi
\fi

\ifbps@antonella
	\instructor{Dr.~Antonella DiLillio}
	\iffontspec@ok
		\setmonofont{Courier New}%
	\else
		\RequirePackage{couriers}% package courier-scaled
	\fi
\fi

\widowpenalties 1 10000
\raggedbottom
\setlength{\parindent}{0em}
\setlength{\parskip}{0.5em}

\let\Sc\textsc
\let\Rm\textrm
\let\Up\textup
\let\Bf\textbf
\let\It\textit
\let\Tt\texttt

\renewcommand{\labelitemi}{---}
\setlist[itemize,enumerate,1]{
	leftmargin=0em,
}
\setlist{
	partopsep=0em,
	topsep=0em,
	leftmargin=2em,
}

\titlecontents{part}
	[3.8em] % left
	{\large\bfseries} % above-code
	% numbered entry format
	{\hspace*{-3.8em}\large\bfseries\contentspage\hspace*{3.8em}}
	% numberless entry format
	{\hspace*{-2.3em}}
	% filler pg format
	{}
	% below code
	[]

\titlecontents{section}
	[4.8em]
	{}
	{\hspace*{-3.8em}\contentspage\hspace*{3.8em}}
	{\hspace*{-2.3em}}
	{}
	[]

\titlecontents{subsection}
	[5.8em]
	{}
	{\hspace*{-4.8em}\contentspage\hspace*{4.8em}\small}
	{\hspace*{-3.3em}}
	{}
	[]