-
Notifications
You must be signed in to change notification settings - Fork 0
/
hw-template.cls
277 lines (211 loc) · 6.14 KB
/
hw-template.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
%hw-template.cls
\ProvidesClass{hw-template}
[2020/01/17 v1.0 General Purpose Homework Template]
\NeedsTeXFormat{LaTeX2e}
% ---------------------------------------------------------------------------- %
% Load Parent Class
\LoadClass{article}
%
% LaTeX 3 project packages
%
% Better command/environment specification
\RequirePackage{xkeyval}
\RequirePackage{xparse} % command/environment
\RequirePackage{xcolor} % color
%
% Homework Details
% - Title
% - Due date
% - Class Name
% - Class Number
% - Instructor
% - Author Nmae
% - Author Short (for groupwork)
%
\def\hmwkTitle{Homework \#114514}
\def\hmwkDueDate{\today}
\def\hmwkClassNumber{ABCD1234.56}
\def\hmwkClassName{TEST}
\def\hmwkClassInstructor{Professor Unknown}
\def\hmwkAuthorName{Foo Bar}
\def\hmwkAuthorShort{Foo}
\define@key{hw-template.cls}{hw}[0]{
\def\hmwkTitle{Homework \##1}
}
\define@key{hw-template.cls}{due}[\today]{
\def\hmwkDueDate{#1}
}
\define@key{hw-template.cls}{classnum}[ABCD1234.56]{
\def\hmwkClassNumber{#1}
}
\define@key{hw-template.cls}{classname}[TEST]{
\def\hmwkClassName{#1}
}
\define@key{hw-template.cls}{teacher}[Unknown]{
\def\hmwkClassInstructor{Professor #1}
}
\define@key{hw-template.cls}{author}[]{
\def\hmwkAuthorName{#1}
}
\define@key{hw-template.cls}{authorshort}[]{
\def\hmwkAuthorShort{#1}
}
\ProcessOptionsX
% For making headers
\RequirePackage{fancyhdr}
\RequirePackage{extramarks}
% For math
\RequirePackage{amsmath}
\RequirePackage{amsthm}
\RequirePackage{amsfonts}
\RequirePackage{mathrsfs}
% For drawing picture
\RequirePackage{tikz}
% For changing the enumerate style
\RequirePackage{enumitem}
% For better column formatting
\RequirePackage{multicol}
% Make inserting images in multicols environment availabe
\RequirePackage{float}
% For creating fancy tables
\RequirePackage{booktabs}
% For fancy code blocks with syntax highlighting
% TODO: fix minted problem for TexLive
% \RequirePackage[newfloat]{minted}
% For compile multiple files
\RequirePackage{subfiles}
% For formatting pictures
\RequirePackage{sidecap}
\RequirePackage{graphicx}
\RequirePackage{subcaption}
% For better curly character presentation
\RequirePackage{BOONDOX-cal}
% -----------------------------------------------------------------------------%
%
% Configure Package Settings
%
% Set up code highlighting style
% \usemintedstyle{xcode} % Light
% \usemintedstyle{native} <- Nice dark theme
% \usemintedstyle{monokai} <- Not bad dark theme
\RequirePackage{tcolorbox}
\RequirePackage{etoolbox}
% Background color designed for dark highlighting style
\definecolor{bg}{HTML}{282828}
% \SetupFloatingEnvironment{listing}{name=Code Block} % Rename the label for listing
% Can set it to Code Block, if wanted to
\usetikzlibrary{automata,positioning}
\everymath{\displaystyle}
%
% Basic Document Settings
%
\topmargin=-0.45in
\evensidemargin=0in
\oddsidemargin=0in
\textwidth=6.5in
\textheight=9.0in
\headsep=0.25in
\linespread{1.1}
\pagestyle{fancy}
\IfNoValueTF{\hmwkAuthorShort}{
\lhead{\hmwkAuthorName}
}{
\lhead{\hmwkAuthorShort}
}
\chead{\hmwkClassNumber:\ (\hmwkClassInstructor): \hmwkTitle}
\rhead{\firstxmark}
\lfoot{\lastxmark}
\cfoot{\thepage}
\renewcommand\headrulewidth{0.4pt}
\renewcommand\footrulewidth{0.4pt}
\setlength\parindent{0pt}
%
% Create Problem Sections
%
\RequirePackage{xstring}
\newcommand*{\IsInteger}[3]{%
\IfStrEq{#1}{ }{%
#3% is a blank string
}{%
\IfInteger{#1}{#2}{#3}%
}%
}%
\newcommand{\enterProblemHeader}[1]{
\nobreak\extramarks{}{Problem \arabic{#1} continued on next page\ldots}\nobreak{}
\nobreak\extramarks{Problem \arabic{#1} (continued)}{Problem \arabic{#1} continued on next page\ldots}\nobreak{}
}
\newcommand{\exitProblemHeader}[1]{
\nobreak\extramarks{Problem \arabic{#1} (continued)}{Problem \arabic{#1} continued on next page\ldots}\nobreak{}
\stepcounter{#1}
\nobreak\extramarks{Problem \arabic{#1}}{}\nobreak{}
}
\setcounter{secnumdepth}{0}
\newcounter{partCounter}
\newcounter{homeworkProblemCounter}
\setcounter{homeworkProblemCounter}{1}
\nobreak\extramarks{Problem \arabic{homeworkProblemCounter}}{}\nobreak{}
\ExplSyntaxOn
\NewDocumentEnvironment{homeworkProblem} { oo }
{
\IsInteger{#1} {\setcounter{homeworkProblemCounter}{#1}}{}
\IfNoValueTF{#2}{\section{Problem\ \arabic{homeworkProblemCounter}}}{
\section{Problem\ \arabic{homeworkProblemCounter}:\ \textnormal{\textit{#2}}}
}
\setcounter{partCounter}{1}
\IsInteger{#1} {\setcounter{homeworkProblemCounter}{#1}}{}
\enterProblemHeader{homeworkProblemCounter}
}
{
% \IfNoValueTF{#1} {}{\exitProblemHeader{#1}}
\exitProblemHeader{homeworkProblemCounter}
}
\ExplSyntaxOff
%
% Title Page
%
\title{
\vspace{2in}
\textmd{\textbf{\hmwkClassNumber:\ \hmwkClassName\\ \hmwkTitle}}\\
\normalsize\vspace{0.1in}\small{Due\ on\ \hmwkDueDate}\\
\vspace{0.1in}\large{\textit{\hmwkClassInstructor}}
\vspace{3in}
}
\author{\textbf{\hmwkAuthorName}}
\date{\today}
%
% Formatting Commands
%
\renewcommand{\part}{\textbf{\large Part \Alph{partCounter}}\stepcounter{partCounter}}
\newcommand{\newpart}{\setcounter{partCounter}{1}}
% Alias for the Solution section header
\newcommand{\solution}{\section{Solution}}
\newcommand{\segline}{\rule{\linewidth}{0.1pt}}
%
% Various Helper Commands
%
% For derivatives
\newcommand{\derivlong}[2][x]{\frac{\mathrm{d}}{\mathrm{d}#1} \left(#2\right)}
\newcommand{\deriv}[2][x]{\frac{\mathrm{d}#2}{\mathrm{d}#1}}
% For partial derivatives
\newcommand{\pderivlong}[2]{\frac{\partial}{\partial #2} \left(#1\right)}
\newcommand{\pderiv}[2]{\frac{\partial #1}{\partial #2}}
% For differentials
\newcommand{\dx}{\mathrm{d}x}
\newcommand{\dy}{\mathrm{d}y}
\newcommand{\dt}{\mathrm{d}t}
% For integrations
\newcommand{\eval}[3]{{#1}\Bigr|_{#2}^{#3}}
% For linear algebra operations
% inner product
\newcommand{\innerprod}[2][\cdot]{\left\langle {#1}, {#2} \right\rangle}
% norm
\newcommand{\norm}[1]{\left\lVert #1 \right\rVert}
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
\hskip -\arraycolsep
\let\@ifnextchar\new@ifnextchar
\array{#1}}
\AtBeginDocument{%
\maketitle
\pagebreak
}
\endinput