-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlecturenote.cls
More file actions
142 lines (118 loc) · 4.31 KB
/
Copy pathlecturenote.cls
File metadata and controls
142 lines (118 loc) · 4.31 KB
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Yi Pusen's Lecture Note
% Maintainer: Yi Pusen (bbcovd@126.com)
%
% Document class to produce simple lecture note
%
% This package is licensed under CC BY 4.0. To view a copy of this
% license, visit http://creativecommons.org/licenses/by/4.0/
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Identification
\NeedsTeXFormat{LaTeX2e} % we need to have LaTeX2e for this to compile
\ProvidesClass{lecturenote}[2022/02/24]
% lecturenote is the name we need to provide to the documentclass command on the .tex file
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Preliminary declarations:
%%%% These are some commands where we declare new commands for the class.
%%%% These are used for the titlepage.
% define the titlepage
\newcommand{\coursename}[1]{\newcommand{\coursenameLoc}{#1}}
\newcommand{\courseteacher}[1]{\newcommand{\courseteacherLoc}{#1}}
\newcommand{\coursenumber}[1]{\newcommand{\coursenumberLoc}{#1}}
\newcommand{\institute}[1]{\newcommand{\instituteloc}{#1}}
\newcommand{\optionalinfo}[2]{\ifx#1\undefined{}\else{#2} \fi}
% these are auxiliary definitions used in the title section
\newcommand{\courseNum}{Num}
\newcommand{\courseLang}{Course}
% This is the definitions used in the header
\newcommand{\lectureLang}[1]{Lecture #1}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Options
%%%% We now pass the options of the class
% Two Columns are difficult to read and grade, we will not use them
\DeclareOption{twocolumn}{\OptionNotUsed}
% Two sided paper are difficult to read and grade, we will not use them
\DeclareOption{twoside}{\OptionNotUsed}
% we hardcode some language options
\DeclareOption{Chinese}{
\renewcommand{\courseLang}{课程}
\renewcommand{\courseNum}{编号}
\renewcommand{\lectureLang}[1]{第 #1 讲}
}
\PassOptionsToClass{a4paper}{article}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions\relax
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Bulk Declarations
%%%% Here we do more declarations and call other files
% we need to load
\LoadClass{article}
% Geometry lets us modify the sizes of the document nicely
\RequirePackage{geometry}
% Decent margins for the documents, as it is meant to be printed
\geometry{left=3.18cm,right=3.18cm,top=2.54cm,bottom=2.54cm, headheight=15pt}
% Course contains basic information about the course.
% \RequirePackage{course}
% This command will generate the info on headers and footers
% whenevr taking a new lecture
\RequirePackage{xifthen} % for a more powerful if-else statement
\newcommand{\lecturetitle}[1]{}
\newcommand{\lecture}[3]{
\ifthenelse{\isempty{#3}}{
% \def\@lecture{Lecture #1}
\renewcommand{\lecturetitle}[1]{\lectureLang{#1}}
}{
% \def\@lecture{Lecture #1: #3}%
\renewcommand{\lecturetitle}[1]{\lectureLang{#1}: #3}
}
\section{\lecturetitle{}}
\marginpar{\small\textsf{\mbox{#2}}}
}
% Header and footers, we will use the lecturetitles also
\RequirePackage{fancyhdr}
\pagestyle{fancy}
\fancypagestyle{note}{
\pagenumbering{arabic}
\fancyhead[L]{\lecturetitle}
\fancyhead[R]{\coursenameLoc}
\fancyfoot[C]{\thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
}
\fancypagestyle{ToC}{
\pagenumbering{roman}
\fancyhead[R]{\coursenameLoc}
\fancyfoot[C]{\thepage}
}
% make title page, I will give no footnotes here, since it is just a
% personal note documents.
\renewcommand{\maketitle}{
\begin{titlepage}
\centering
% title
{\huge {\bfseries \@title} \par}
\vspace{8pt}
% author
{\large
\begin{tabular}[t]{c}
\@author
\end{tabular}\par}
\vspace{8pt}
\rule{\textwidth}{0.8pt}
\vspace{10pt}
% Course information
{\large \courseLang : \coursenameLoc{}}
\optionalinfo{\courseteacherLoc}{--
{\slshape \courseteacherLoc{}}\\
}
\optionalinfo{\coursenumberLoc}{{\upshape \courseNum :} {\itshape \coursenumberLoc} \\
}
\optionalinfo{\instituteloc}{\scshape \instituteloc}
% white space between course information and date
\vfill
\rule{\textwidth}{1pt}
{\large \@date}
\end{titlepage}
}
%%% We finish the class with this command
\endinput