-
Notifications
You must be signed in to change notification settings - Fork 7
/
pset.cls
187 lines (162 loc) · 5.11 KB
/
pset.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
%% pset.cls
%%
%% A (Xe)LaTeX 3 class for problem sets.
\RequirePackage{expl3, xparse, iftex}
\ExplSyntaxOn
%% Define Class Metadata
%% ---------------------
%% Provides information to the LaTeX3 compiler
%% about what our class does.
\tl_const:Nn \c__pset_class_name_tl {pset}
\tl_const:Nn \c__pset_class_version_tl {1.0.0}
\tl_const:Nn \c__pset_class_date_tl {2018/07/04}
\tl_const:Nn \c__pset_class_description_tl {A~LaTeX3~class~for~problem~sets.}
\tl_const:Nn \c__pset_class_parent_class_tl {article}
\ProvidesExplClass{\c__pset_class_name_tl} % Class
{\c__pset_class_date_tl} % Date
{\c__pset_class_version_tl} % Version
{\c__pset_class_description_tl} % Description
%% Define Class Data
%% -----------------
%% Data set by the user about the assignment.
%% Used to create headers, title page, etc.
\tl_new:N \g_pset_title_tl % Title of the assignment
\tl_new:N \g_pset_author_tl % Your name
\tl_new:N \g_pset_duedate_tl % When the assignment is due
\tl_new:N \g_pset_course_tl % What course the assignment is for
\tl_new:N \g_pset_blurb_tl % A short blurb on the first page
\tl_new:N \g_pset_professor_tl % The professor of the course
% Clear and set default values
\tl_clear_new:N \g_pset_title_tl
\tl_clear_new:N \g_pset_author_tl
\tl_clear_new:N \g_pset_course_tl
\tl_clear_new:N \g_pset_duedate_tl
\tl_clear_new:N \g_pset_blurb_tl
\tl_clear_new:N \g_pset_professor_tl
% Provide user-facing interface to the data
\RenewDocumentCommand\title{ m }{ \tl_gset:Nn \g_pset_title_tl {#1} }
\NewDocumentCommand\assignment{ m }{ \title{#1} }
\RenewDocumentCommand\author{ m }{ \tl_gset:Nn \g_pset_author_tl {#1} }
\NewDocumentCommand\name{ m }{ \author{#1} }
\NewDocumentCommand\due{ m }{ \tl_gset:Nn \g_pset_duedate_tl {#1} }
\RenewDocumentCommand\date{ m }{ \due{#1} }
\NewDocumentCommand\course{ m }{ \tl_gset:Nn \g_pset_course_tl {#1} }
\NewDocumentCommand\blurb{ m }{ \tl_gset:Nn \g_pset_blurb_tl {#1} }
\NewDocumentCommand\professor{ m }{ \tl_gset:Nn \g_pset_professor_tl {#1} }
% Class Options
\bool_new:N \g_pset_coverpage_bool
\tl_new:N \g_pset_loadcode_tl
\tl_new:N \g_pset_loaddiag_tl
\bool_gset_false:N \g_pset_coverpage_bool
\tl_clear_new:N \g_pset_loadcode_tl
\tl_clear_new:N \g_pset_loaddiag_tl
\DeclareOption{cover}{\bool_gset_true:N \g_pset_coverpage_bool}
\DeclareOption{code}{\tl_gset:Nn \g_pset_loadcode_tl {code}}
\DeclareOption{diagram}{\tl_gset:Nn \g_pset_loaddiag_tl {diagram}}
\DeclareOption*{ \PassOptionsToClass{\CurrentOption}{\c__pset_class_parent_class_tl} }
\ProcessOptions\relax
%% Process Options and Load Base Class
\LoadClass[letterpaper, 10pt]{\c__pset_class_parent_class_tl}
%% Load shared definitions
\RequirePackage[
\g_pset_loadcode_tl ,
\g_pset_loaddiag_tl,
nothmnum
]{coursework}
%% Customization for Pset Only
%% ============================
%% Remove section numbering in all numbered theorem-like environments
\renewcommand*{\thecproblem}{\arabic{cproblem}}
\renewcommand*{\thecexercise}{\arabic{cexercise}}
\renewcommand*{\thecexample}{\arabic{cexample}}
\renewcommand*{\thelemma}{\arabic{lemma}}
\renewcommand*{\thetheorem}{\arabic{theorem}}
\renewcommand*{\thecorollary}{\arabic{corollary}}
\renewcommand*{\theconjecture}{\arabic{conjecture}}
\renewcommand*{\theproposition}{\arabic{proposition}}
\renewcommand*{\thecremark}{\arabic{cremark}}
\renewcommand*{\thecwarning}{\arabic{cwarning}}
\renewcommand*{\thecclaim}{\arabic{cclaim}}
\renewcommand*{\thecquestion}{\arabic{cquestion}}
%% Load Packages
\RequirePackage{fancyhdr}
\RequirePackage{textcase}
\RequirePackage{afterpage}
\RequirePackage{geometry}
%% Create Page Formats
\fancypagestyle{normal}{
\renewcommand{\headrulewidth}{0pt}
\fancyfoot{}
\fancyfoot[L]{
\footnotesize \thepage
}
\fancyhead[C]{
\ifXeTeX
\scshape\MakeTextLowercase{\g_pset_course_tl{}}
\else
\lsstyle \footnotesize \MakeTextUppercase{\g_pset_course_tl{}}
\fi
}
\fancyhead[R]{}
\fancyhead[L]{}
\fancyfoot[R]{
\ifXeTeX \else \lsstyle \fi
\footnotesize
\tl_if_empty:NF \g_pset_author_tl {
\g_pset_author_tl{}
}
\tl_if_empty:NF \g_pset_duedate_tl {
,~\g_pset_duedate_tl{}
}
}
}
%% Redefine \maketitle
\RenewDocumentCommand\maketitle{}{
\newpage
\thispagestyle{empty}
\null
\begin{center}
{\bfseries
\ifXeTeX
\Large\scshape \g_pset_course_tl{}\quad\g_pset_title_tl{}
\else \normalsize
\lsstyle\MakeTextUppercase{\g_pset_course_tl{}\quad\g_pset_title_tl{}}
\fi
}\par
\vskip 2ex
{\small \scshape\ifPDFTeX \lsstyle \fi
\tl_if_empty:NF \g_pset_author_tl {
\g_pset_author_tl{}
\tl_if_empty:NF \g_pset_duedate_tl {,\quad}
}
\tl_if_empty:NF \g_pset_duedate_tl {
\g_pset_duedate_tl{}
}
\par
}
\end{center}
\tl_if_empty:NTF \g_pset_blurb_tl {
\vskip 8ex
}{
\vskip 2ex
\g_pset_blurb_tl{}\par
\vskip 4ex
}
}
% Prevent the coloring of links
\hypersetup{ colorlinks = false }
% Make Page Symmetric
\geometry{
letterpaper,
top = 1.45in,
bottom = 1.35in,
inner = 1.9in,
outer = 1.9in,
marginparwidth=1.4in,
marginparsep=0.25in,
}
\AtBeginDocument{
\maketitle
\pagestyle{normal}
}
\ExplSyntaxOff