-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfkpset.cls
294 lines (222 loc) · 7.93 KB
/
fkpset.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
% ================================================================== %
% %
% Requirement Things %
% %
% ================================================================== %
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{pset}[2018/3/21 v0.01 pset class]
% This class based on the standard article class
\LoadClass{article}
% ================================================================== %
% %
% Packages %
% %
% ================================================================== %
% Sensible margins
\RequirePackage[margin=1in, tmargin=1.25in]{geometry}
% Better fonts
\RequirePackage{lmodern}
% Make sure we're inputting stuff correctly
\RequirePackage[utf8]{inputenc}
% And in english!
\RequirePackage[english]{babel}
% Add a color package for color manipulations.
\RequirePackage[dvipsnames]{xcolor}
% I've offloaded my math macros into a separate package (in this repo)
\RequirePackage{fkmath}
% For \includegraphics
\RequirePackage{graphicx}
% Fancy page header
\RequirePackage{fancyhdr}
% For multi-column environment
\RequirePackage{multicol}
% In case you want any diagrams, etc.
\RequirePackage{tikz}
\usetikzlibrary{arrows} % Better arrows
\usetikzlibrary{arrows.meta}
\usetikzlibrary{calc} % Add coordinates and stuff
\usetikzlibrary{patterns} % distinguishing shapes
\usetikzlibrary{decorations.pathreplacing} % For braces and such
\usetikzlibrary{decorations.markings} % For arrows on lines
\RequirePackage{pgfplots}
% ...Which you would probably place in figure environments
\RequirePackage{float}
\RequirePackage{subcaption}
% For referencing page count
\RequirePackage{lastpage}
% Because I've learned my lesson about manual line breaks
\RequirePackage{parskip}
% For customizing the enumerate environment
\RequirePackage{enumitem}
% So that the whitespace around section headers can be made less
% obnoxiously large
\RequirePackage{titlesec}
% For better commands
\RequirePackage{xifthen}
% For quasi-legitimate looking tables
\RequirePackage{booktabs}
% For margin modification in subsections
\RequirePackage{changepage}
% Problem and reading set lists, for top of document
\RequirePackage{etoolbox}
% For more bearable referencing
\RequirePackage{fancyref}
% For referencing things with links
\RequirePackage[colorlinks=true]{hyperref}
% Use smarter referencing and stuff
\RequirePackage[capitalise]{cleveref}
% Boxed problem statements
\RequirePackage{boxedminipage}
% ================================================================== %
% %
% Control Sequences %
% %
% ================================================================== %
% ------------------------ Creature Comforts ----------------------- %
% Default to letters for enumerate formatting
\setenumerate[0]{label=$($\alph*$)$}
% For units
% FIXME: Is this really something I use often still?
\RequirePackage{siunitx}
% Problem environment. Relies on `mdframed' being imported in
% `fkmath'.
\theoremstyle{definition}
\newmdtheoremenv[%
outerlinewidth = .025,
leftmargin = .025\linewidth,
rightmargin = .025\linewidth,
innerleftmargin = 3,
innertopmargin = 3,
splittopskip = \topskip,
]{newproblem}{Problem}
\newenvironment{problem}[1][]{\begin{newproblem}[{#1}]~}{\end{newproblem}}
\renewcommand{\qed}{\hfill $\blacksquare$}
\newenvironment{solution}[1][Solution.]
{\noindent\begin{center}\begin{adjustwidth}{.05\linewidth}{.05\linewidth}\emph{#1}\ }
{\qed\end{adjustwidth}\end{center}}
\theoremstyle{plain}% default
\newtheorem{theorem}{Theorem}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{conjecture}[theorem]{Conjecture}
\theoremstyle{definition}
\newtheorem{definition}{Definition}
\newtheorem{example}{Example}
\newtheorem{axiom}{Axiom}
\newtheorem*{remark}{Remark}
\newtheorem*{note}{Note}
% ================================================================== %
% %
% Misc. Formattings %
% %
% ================================================================== %
% We want to let align environments overflow page breaks
\allowdisplaybreaks
% I don't like autoindentation for new paragraphs
\setlength\parindent{0pt}
% Thicker top rule for header and footer
\newcommand{\trule}{\vspace{-.5\baselineskip}%
\rule{\textwidth}{1pt}\vspace*{-\baselineskip}\vspace*{2pt}
\rule{\textwidth}{0.4pt}}
% Flanked by a thinner bottomrule
\newcommand{\brule}{\vspace{.125\baselineskip}
\rule{\textwidth}{0.4pt}\vspace*{-\baselineskip}\vspace*{2.4pt}
\rule{\textwidth}{1pt}}
% Points table rule (if so desired). Thinner!
\newcommand{\prule}{\rule{\linewidth}{.75pt}}
% Draw the header line
\renewcommand\headrule{
\begin{minipage}{1\textwidth}
\trule
\end{minipage}}%
% And footer
\renewcommand\footrule{
\begin{minipage}{1\linewidth}
\brule
\end{minipage}
}
% internal state for coverblock
\def\fkpset@name{}
\def\fkpset@class{}
\def\fkpset@duedate{}
\def\fkpset@assignment{}
\def\fkpset@problems{}
% Commands to set header block info
\newcommand{\name}[1]{\def\fkpset@name{#1}}
\newcommand{\class}[1]{\def\fkpset@class{#1}}
\newcommand{\duedate}[1]{\def\fkpset@duedate{#1}}
\newcommand{\assignment}[1]{\def\fkpset@assignment{#1}}
\newcommand{\problems}[1]{\def\fkpset@problems{#1}
\forcsvlist{\saveitem}{#1}\forcsvlist{\listadd\problist}{#1}}
% So that we can iterate through problems to fill the coversheet table
\newcounter{problemCounter}
% This stores each problem as a new command sequence,
% `\problems<problem_name>`. This allows us to get each problem back
% out easily, e.g. typesetting problem `10.3.1` is as easy as
% `\problems10.3.1`. This is inelegant, but it works.
\def\saveitem#1{%
\stepcounter{problemCounter}%
\expandafter\def\csname problems\theproblemCounter\endcsname{#1}%
}
\def\getProblem#1{\expandafter{\csname problems#1\endcsname}}
\newcounter{prob}
\newcommand{\dothis}[1]{\stepcounter{prob}
\getProblem{\number\value{prob}} & }
\newcommand{\pointstable}[2][centering]{
\begin{table}[h]
\vspace{-2.85cm}
\csname#1\endcsname
#2
% *{\theproblemCounter} gets us that many c's. Since indexing starts at 0,
% we have to add one on at the end manually.
\begin{tabular}{l *{\theproblemCounter} c r}
\toprule
Problem & \forlistloop{\dothis}{\problist} Total \\ \midrule
Points & \\
\bottomrule
\end{tabular}
\vspace{.75cm}
\end{table}
% \prule
% \vspace{.5cm}
}
\pagestyle{fancy}
\fancyhf{}
\lhead{\fkpset@name}
\rfoot{\thepage\ of \pageref{LastPage}}
\setlength{\headheight}{15.2pt}
\setlength{\headsep}{10pt}
\newcommand{\rblock}{
\begin{flushright}%
\mbox{\fkpset@name}\protect\\
\mbox{\fkpset@class}\protect\\
\mbox{\fkpset@assignment}\protect\\
\fkpset@duedate%
\end{flushright}%
\brule}%
%
\DeclareOption{norblock}{
\renewcommand{\rbloc}{\@gobble}
}
% Verbose error messages
\DeclareOption{verbose}{
\setcounter{errorcontextlines}{999}
}
% Start indexing of problem numbers at 1
\stepcounter{section}
\DeclareOption{algs}{
\geometry{paperwidth=10.5in, paperheight=11in, lmargin=2in, rmargin=2in}
\fancyhfoffset[E,O]{0pt}
\renewcommand{\rblock}{}%
\renewenvironment{problem}[1][Problem \thesection.\ ]
{\section*{#1}}
{
\hrulefill
}
}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions\relax
% Typeset the name block
\AtBeginDocument{\rblock}
\endinput