forked from jopetty/coursework-latex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
term-paper.cls
160 lines (134 loc) · 4.19 KB
/
term-paper.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
%% term-paper.cls
%%
%% A (Xe)LaTeX 3 class for term papers.
\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 {term-paper}
\tl_const:Nn \c__pset_class_version_tl {1.0.0}
\tl_const:Nn \c__pset_class_date_tl {2019/10/29}
\tl_const:Nn \c__pset_class_description_tl {A~LaTeX3~class~for~term~papers.}
\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_byline_tl % The default byline
% 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_gset:Nn \g_pset_byline_tl {
\large {\scshape \MakeTextLowercase{\g_pset_author_tl},~\MakeTextLowercase{\g_pset_duedate_tl},}~{\small\textit{for}}~{\scshape \MakeTextLowercase{\g_pset_course_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\byline{ m }{ \tl_gset:Nn \g_pset_byline_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 Term Papers Only
%% ==================================
%% Load Packages
\RequirePackage{fancyhdr}
\RequirePackage{textcase}
\RequirePackage{afterpage}
\RequirePackage{geometry}
\usepackage[]{footmisc}
%% Create Page Formats
\fancypagestyle{normal}{
\renewcommand{\headrulewidth}{0pt}
\fancyfoot{}
\fancyfoot[L]{
\footnotesize \thepage
}
\fancyhead[C]{
\ifXeTeX
\scshape\MakeTextLowercase{\g_pset_title_tl{}}
\else
\lsstyle \footnotesize \MakeTextUppercase{\g_pset_title_tl{}}
\fi
}
\fancyhead[R]{}
\fancyhead[L]{}
\fancyfoot[R]{
\ifXeTeX \else \lsstyle \fi
\footnotesize\scshape
\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{flushleft}
{\LARGE\bfseries\sffamily \g_pset_title_tl}
\end{flushleft}
\begin{flushleft}
\g_pset_byline_tl
\end{flushleft}
\vspace*{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,
footnotesep = 1cm
}
% Footnotes
\let\footnote\oldfootnote
%\addtolength{\footnotesep}{10mm}
\AtBeginDocument{
\maketitle
\pagestyle{normal}
\noindent
}
\ExplSyntaxOff