summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/seu-ml-assign/seu-ml-assign.cls
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/seu-ml-assign/seu-ml-assign.cls')
-rw-r--r--macros/latex/contrib/seu-ml-assign/seu-ml-assign.cls149
1 files changed, 110 insertions, 39 deletions
diff --git a/macros/latex/contrib/seu-ml-assign/seu-ml-assign.cls b/macros/latex/contrib/seu-ml-assign/seu-ml-assign.cls
index eedc7c2f0b..abaa2b967c 100644
--- a/macros/latex/contrib/seu-ml-assign/seu-ml-assign.cls
+++ b/macros/latex/contrib/seu-ml-assign/seu-ml-assign.cls
@@ -4,16 +4,16 @@
%% %%
%% ================================================== %%
%% %%
-%% Version: 1.0 (2022/03/20) %%
+%% Version: 1.1 (2022/03/28) %%
%% Author: Teddy van Jerry (Wuqiong Zhao) %%
%% License: MIT LICENSE %%
%% GitHub Repo: https://tvj.one/ml-tex %%
-%% Compiler: pdflatex, xelatex, lualatex %%
+%% Compiler: latex, pdflatex, xelatex, lualatex %%
%% %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\NeedsTeXFormat{LaTeX2e}
-\ProvidesClass{seu-ml-assign}[2022/02/20 SEU Machine Learning Assignment Template]
+\ProvidesClass{seu-ml-assign}[2022/03/28 SEU Machine Learning Assignment Template]
%% Class and Options
\def\@@ptsize{10pt} % font size
@@ -24,6 +24,9 @@
\def\@@solutionmode{1} % default as the solution mode
\DeclareOption{solution}{\def\@@solutionmode{1}} % solution mode
\DeclareOption{problem}{\def\@@solutionmode{0}} % problem mode
+\def\@twoside{0} % default as oneside
+\DeclareOption{oneside}{\def\@twoside{0}} % one-side document
+\DeclareOption{twoside}{\def\@twoside{1}} % two-side document
\ProcessOptions\relax
\LoadClass[a4paper,onecolumn,\@@ptsize]{article}
@@ -39,11 +42,13 @@
\global\let\@instructor\@empty
\global\let\@duedate\@empty
\global\let\@author\@empty
+\global\let\@mainproblem\@empty
\newcommand{\assignno}[1]{\gdef\@assignno{#1}} % Assignment Number
\newcommand{\semester}[1]{\gdef\@semester{#1}} % Semester
\newcommand{\studentID}[1]{\gdef\@studentID{#1}} % Student ID
\newcommand{\instructor}[1]{\gdef\@instructor{#1}} % Instructor
\newcommand{\duedate}[1]{\gdef\@duedate{#1}} % Due Date of the Assignment
+\newcommand{\mainproblem}[1]{\gdef\@mainproblem{#1}} % The main problem of the assignment
%% Fonts and Colors
\RequirePackage[T1]{fontenc}
@@ -56,6 +61,7 @@
%% Sections Settings
\RequirePackage[explicit]{titlesec} % explained in https://tex.stackexchange.com/a/292307/234654
+\RequirePackage{suffix}
% http://mirrors.ctan.org/macros/latex/contrib/titlesec/titlesec.pdf
\pgfdeclarelayer{background}
\pgfsetlayers{background,main}
@@ -64,32 +70,42 @@
\newcommand{\problemptsprint}{\ifx\@problempts\@empty\else(\@problempts~points)\fi}
\newcommand{\sectionheadname}{Problem} % Name for the Section (default as 'Problem')
% Reference: https://tex.stackexchange.com/a/12269/234654
-\newcommand{\boxedsection}[3][blue!20]{{%
+\newcommand{\boxedsection}[4][blue!20]{{%
\begin{tikzpicture}[inner sep=0pt, inner ysep=0.3ex]
\node[anchor=base west] at (0,0) (counter) {#2};
- \path let \p1 = (counter.base east) in node[anchor=base west, text width={\textwidth-\x1-0.33em}] (content)
- at ($(counter.base east)+(0.33em,0)$) {#3};
+ \path let \p1 = (counter.base east) in node[anchor=base west, text width={\textwidth-\x1-#4}] (content)
+ at ($(counter.base east)+(#4,0)$) {#3};
\begin{pgfonlayer}{background}
\shade[left color=#1,right color=white] let \p1=(counter.north), \p2=(content.north) in
(0,{max(\y1,\y2)}) rectangle (content.south east);
\end{pgfonlayer}
\end{tikzpicture}
}}
-% \titleformat{<command>}
-% [<shape>]{<format>}{<label>}{<sep>}{<before-code>}[<after-code>]
-\titleformat{\section}%
- {\Large\bfseries}%
- {}%
- {0pt}%
- {\boxedsection{\sectionheadname{} \thesection:}{#1}}%
+% For numbered section, i.e. \section{}
+\titleformat{\section}% <command>
+ {\Large\bfseries}% <format>
+ {}% <label>
+ {0pt}% <sep>
+ {\boxedsection{\sectionheadname{} \thesection:}{#1}{0.33em}}% <before-code>
[%
- \vspace{-2.1\baselineskip}\hfill{\normalfont\small\problemptsprint}%
+ \vspace{-2.2\baselineskip}\hfill{\normalfont\small\problemptsprint}%
\problempts{}% clear the problem points
- ]%
+ ]% <after-code>
+% For unnumbered section, i.e. \section*{}
+\titleformat{name=\section,numberless}% <command>
+ {\Large\bfseries}% <format>
+ {}% <label>
+ {0pt}% <sep>
+ {\boxedsection{}{#1}{0em}}% <before-code>
+ [%
+ \vspace{-2.2\baselineskip}\hfill{\normalfont\small\problemptsprint}%
+ \problempts{}% clear the problem points
+ ]% <after-code>
\newcommand{\setproblem}[1]{\ifx#1\@empty\else\setcounter{section}{#1}\fi} % force the number of problem
\newcommand{\setsubproblem}[1]{\ifx#1\@empty\else\setcounter{subsection}{#1}\fi} % force the number of subproblem
-\newcommand{\problem}[2][]{\problempts{#1}\section{#2}}%
-\newcommand{\solutionname}{Solution}
+\newcommand{\problem}[2][]{\problempts{#1}\section[\thesection~#2]{#2}}%
+\WithSuffix\newcommand\problem*[2][]{\problempts{#1}\section*{#2}}%
+\newcommand{\solutionname}{Solution}%
\newcommand{\startsolution}[1][print]{%
\setproblem{0}% reset the section counter
\def\startsolutionprintoption{print}
@@ -98,17 +114,21 @@
{%
\fontfamily{LinuxLibertineT-OsF}\selectfont% select font as Linux Libertine
\centering\LARGE\scshape%
+ \vspace{\baselineskip}%
\solutionname{}\\[-0.2em]%
}%
\noindent%
- \tikzrule[WildStrawberry, path fading=west]{.5\textwidth}{.2em}% <-- Do not remove this
- \tikzrule[WildStrawberry, path fading=east]{.5\textwidth}{.2em}
+ \tikzrule[WildStrawberry, path fading=west]{.5\textwidth}{.2em}%
+ \tikzrule[WildStrawberry, path fading=east]{.5\textwidth}{.2em}%
}\fi%
}
\titlespacing*{\section}{0em}{2.5\baselineskip}{1\baselineskip}
-\titleformat{\subsection}[runin]{\large\bfseries}{}{0pt}{(\arabic{subsection}) #1}%
-\newcommand{\subproblem}[2][]{\subsection[#1]{#2}}
-\titleformat{\subsubsection}[runin]{}{}{0pt}{(\arabic{subsubsection}. #1}
+\titleformat{\subsection}[runin]{\large\bfseries}{(\arabic{subsection})}{0.33em}{#1}
+\newcommand{\subproblem}[1]{\subsection[(\arabic{subsection}) #1]{#1}}
+\WithSuffix\newcommand\subproblem*[1]{\subsection*{#1}}
+\titleformat{\subsubsection}[runin]{\bfseries}{\arabic{subsubsection}.}{0.33em}{#1}
+\newcommand{\subsubproblem}[1]{\subsubsection[\arabic{subsubsection}. #1]{#1}}
+\WithSuffix\newcommand\subsubproblem*[1]{\subsubsection*{#1}}
%% Maths Settings
\RequirePackage{mathtools}
@@ -117,6 +137,14 @@
\RequirePackage{bm} % \bm command
\RequirePackage{nicematrix}
\numberwithin{equation}{section}
+\newtheorem{theorem}{Theorem}[section]
+\newtheorem{proposition}{Proposition}[section]
+\newtheorem{lemma}{Lemma}[section]
+\newtheorem{corollary}{Corollary}[section]
+\newcommand{\hintstyle}{\itshape}
+\newcommand{\hint}[1]{({\hintstyle Hint: #1})}
+\DeclareMathOperator*{\argmin}{\arg\min}
+\DeclareMathOperator*{\argmax}{\arg\max}
%% Code Block Settings
\RequirePackage{listings}
@@ -135,7 +163,7 @@
backgroundcolor=\color{gray!5},
basicstyle={\ttfamily\small},
numberstyle=\footnotesize\color{gray},
- keywordstyle=\bfseries\color{blue},
+ keywordstyle=\bfseries\color{MidnightBlue!95!black},
commentstyle=\color{dkgreen},
stringstyle=\color{mauve},
breaklines=true,
@@ -183,23 +211,52 @@
title={#2},#1
}
+%% Footnote Settings
+\RequirePackage[bottom]{footmisc} % glue footnote to bottom
+\renewcommand{\footnoterule}{\noindent\tikzrule[SeaGreen, path fading=east]{.4\textwidth}{.1em}}
+\renewcommand{\footnotesep}{1em}
+
%% Header and Footer
\RequirePackage{fancyhdr}
-\RequirePackage[colorlinks=true,urlcolor=blue,linkcolor=purple,citecolor=red]{hyperref}
+\RequirePackage[colorlinks=true, urlcolor=blue, linkcolor=purple, citecolor=red, hypertexnames=false]{hyperref}
\setlength{\headheight}{52pt}
\setlength{\marginparwidth}{2cm}
\pagestyle{fancy}
-\lhead{
- \fontfamily{LinuxLibertineT-OsF}\selectfont
- \if\@@solutionmode1
- \textsc{\@title~\@assignno} -- \@studentID~\@author
- \else
+\if\@twoside0
+ \lhead{
+ \fontfamily{LinuxLibertineT-OsF}\selectfont
+ \if\@@solutionmode1
+ \textsc{\@title~\@assignno} -- \@studentID~\@author
+ \else
+ \textsc{Machine Learning \@title~\@assignno}
+ \fi
+ }
+ \rhead{\thepage}
+ \renewcommand\headrule{\vspace{-0.7em}\tikzrule[BrickRed, path fading=east]{.5\textwidth}{0.3mm}}
+\else
+ \fancyhf{}
+ \renewcommand\headrule{%
+ \ifodd\thepage
+ \vspace{-0.7em}\tikzrule[BrickRed, path fading=east]{.5\textwidth}{0.3mm}
+ \else
+ \vspace{-0.7em}\hfill\tikzrule[BrickRed, path fading=west]{.5\textwidth}{0.3mm}
+ \fi
+ }
+ \fancyhead[LO]{
+ \fontfamily{LinuxLibertineT-OsF}\selectfont
+ \if\@@solutionmode1
+ \textsc{\@title~\@assignno} -- \@studentID~\@author
+ \else
+ \textsc{Machine Learning \@title~\@assignno}
+ \fi
+ \renewcommand\headrule{\vspace{-0.7em}\tikzrule[BrickRed, path fading=east]{.5\textwidth}{0.3mm}}
+ }
+ \fancyhead[RE]{
+ \fontfamily{LinuxLibertineT-OsF}\selectfont
\textsc{Machine Learning \@title~\@assignno}
- \fi
-}
-
-\rhead{\thepage}
-\renewcommand\headrule{\vspace{-0.7em}\tikzrule[BrickRed, path fading=east]{.5\textwidth}{0.3mm}}
+ }
+ \fancyhead[LE,RO]{\thepage}
+\fi
\cfoot{}
% header and footer style for the first page
\fancypagestyle{firstpage}{
@@ -210,7 +267,7 @@
\fontfamily{LinuxLibertineT-OsF}\selectfont
\vspace*{-\firstfooteradditionalheight}
\vspace{-1.5em}
- \tikzrule[purple, path fading=west]{.5\textwidth}{.15em}% <-- Do not remove this
+ \tikzrule[purple, path fading=west]{.5\textwidth}{.15em}%
\tikzrule[purple, path fading=east]{.5\textwidth}{.15em}
\footnotesize\centering
@@ -266,14 +323,23 @@
\centering
{
\large
- \textcolor{BrickRed}{\sffamily \@semester}
+ \fontfamily{LinuxBiolinumT-OsF}\selectfont
+ \textcolor{BrickRed}{\@semester}
\vspace{2mm}
}
\LARGE\@title~{\fontfamily{bch}\selectfont\@assignno}
\end{minipage}
\\[.3em]
\tikzrule[cyan, path fading=east]{\textwidth}{.4em}
- \vspace{2mm}
+
+ \ifx\@mainproblem\@empty
+ \vspace{2mm}
+ \else
+ \begin{center}
+ \vspace{-1\baselineskip}\color{RoyalPurple!50!black}
+ \LARGE\S~\@mainproblem~\S
+ \end{center}
+ \fi
\fontfamily{cmr}\selectfont % Computer Modern
@@ -287,10 +353,15 @@
\if\@@solutionmode1
\pdftitleadditionalname{}
\fi
- - Machine Learning
+ - Machine Learning%
},
pdfsubject={Machine Learning},
- pdfkeywords={Machine Learning, \@title},
+ pdfkeywords={%
+ Machine Learning, \@title%
+ \ifx\@mainproblem\@empty\else%
+ , \@mainproblem%
+ \fi%
+ },
pdfcreator={LaTeX with SEU-ML-Assign class},
pdfproducer={LaTeX}
}