summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/seu-ml-assign
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/seu-ml-assign')
-rw-r--r--macros/latex/contrib/seu-ml-assign/README.md40
-rw-r--r--macros/latex/contrib/seu-ml-assign/seu-ml-assign-doc.pdfbin483948 -> 173930 bytes
-rw-r--r--macros/latex/contrib/seu-ml-assign/seu-ml-assign-doc.tex234
-rw-r--r--macros/latex/contrib/seu-ml-assign/seu-ml-assign-sample.tex3
-rw-r--r--macros/latex/contrib/seu-ml-assign/seu-ml-assign.cls149
5 files changed, 318 insertions, 108 deletions
diff --git a/macros/latex/contrib/seu-ml-assign/README.md b/macros/latex/contrib/seu-ml-assign/README.md
index 86702d3812..505e6d9d85 100644
--- a/macros/latex/contrib/seu-ml-assign/README.md
+++ b/macros/latex/contrib/seu-ml-assign/README.md
@@ -1,30 +1,34 @@
# SEU-ML-Assign LaTeX Template
LaTeX Template for Southeast University Machine Learning Assignment
-> GitHub Project Site: https://tvj.one/ml-tex
+> - GitHub Project Site: https://tvj.one/ml-tex
+> - CTAN: https://ctan.org/pkg/seu-ml-assign
+> - Website: https://seu-ml-assign.github.io
## Class and Options
This project provides the `seu-ml-assign` class.
-| Option | Explanation |
-| - | - |
-| `solution` | Write solutions (for students). **[default]** |
-| `problem` | Write problem sets (for instructors). |
-| `9pt` | Set font size as 9 points. |
-| `10pt` | Set font size as 10 points. **[default]** |
-| `11pt` | Set font size as 11 points. |
-| `12pt` | Set font size as 12 points. |
+| Option | Explanation | Default |
+| - | - | :-: |
+| `solution` | Write solutions (for students). | • |
+| `problem` | Write problem sets (for instructors). ||
+| `oneside` | One-sided document. | • |
+| `twoside` | Two-sided document. ||
+| `9pt` | Set font size as 9 points. ||
+| `10pt` | Set font size as 10 points. | • |
+| `11pt` | Set font size as 11 points. ||
+| `12pt` | Set font size as 12 points. ||
## Commands and Usage
-Please refer to the [documentation](seu-ml-assign-doc.pdf).
+Please refer to the [documentation](http://mirrors.ctan.org/macros/latex/contrib/seu-ml-assign/seu-ml-assign-doc.pdf).
-## TODOs
-- [x] Class Definition
-- [x] Example `tex` File
-- [x] Class Documentation
-- [ ] Class Website
-- [ ] Submission to CTAN
-- [ ] Demonstration Video
+The main higher level commands provided in this template are `\problem[<points>]{title}` and `\subproblem{title}`.
+
+## Publication
+This project has been contained in [**CTAN**](https://ctan.org/pkg/seu-ml-assign), and so is in **TeX Live**.
+
+## Issues
+Please go to [issues](https://github.com/Teddy-van-Jerry/SEU-ML-Assign_LaTeX_Template/issues) to report them if any.
## License
-This project is licensed under the [MIT License](LICENSE).
+This project is licensed under the [MIT License](https://github.com/Teddy-van-Jerry/SEU-ML-Assign_LaTeX_Template/blob/master/LICENSE).
diff --git a/macros/latex/contrib/seu-ml-assign/seu-ml-assign-doc.pdf b/macros/latex/contrib/seu-ml-assign/seu-ml-assign-doc.pdf
index 43504378ae..2037332b1c 100644
--- a/macros/latex/contrib/seu-ml-assign/seu-ml-assign-doc.pdf
+++ b/macros/latex/contrib/seu-ml-assign/seu-ml-assign-doc.pdf
Binary files differ
diff --git a/macros/latex/contrib/seu-ml-assign/seu-ml-assign-doc.tex b/macros/latex/contrib/seu-ml-assign/seu-ml-assign-doc.tex
index c9556da739..3331bd97b8 100644
--- a/macros/latex/contrib/seu-ml-assign/seu-ml-assign-doc.tex
+++ b/macros/latex/contrib/seu-ml-assign/seu-ml-assign-doc.tex
@@ -1,21 +1,25 @@
%! TEX program = pdflatex
-\documentclass{seu-ml-assign}
+\documentclass[twoside]{seu-ml-assign}
+
+\usepackage{booktabs}
+\usepackage{colortbl}
+\usepackage{multicol}
+\usepackage{threeparttable}
\title{Documentation}
\author{Teddy van Jerry}
\studentID{}
\instructor{TeX - LaTeX Stack Exchange}
\date{\today}
-\duedate{20:00 March 21, 2022}
-\assignno{1.0}
+\duedate{20:00 March 30, 2022}
+\assignno{1.1}
\semester{LaTeX Template}
+\mainproblem{Template Documentation}
\renewcommand{\sectionheadname}{Section}
\renewcommand{\pdftitleadditionalname}{}
-\usepackage{booktabs}
-\usepackage{colortbl}
% option for tabular with '\midrule'
\aboverulesep = 0mm \belowrulesep = 0mm
@@ -24,7 +28,7 @@
\begin{document}
\maketitle
- \section{Basic Information of This Template Class}
+ \problem{Basic Information of This Template Class}
Despite this \textit{SEU-ML-Assign} class is dedicated to Southeast University as the Machine Learning assignment \LaTeX{} template both for teachers and students, it can also be used for other schools.
In the near future, it will eventually become an elegant template for all assignment requirememts.
@@ -35,13 +39,15 @@
\setlength{\tabcolsep}{1.5em}
\begin{tabular}{ll}
\toprule
- \grayrow \textbf{Package Class Name} & seu-ml-assign \\
- \textbf{Version} & 1.0 (2022/03/20) \\
+ \grayrow \textbf{Package Class Name} & \texttt{seu-ml-assign} \\
+ \textbf{Version} & 1.1 (2022/03/28) \\
\grayrow \textbf{Description} & \LaTeX{} Template for Southeast University Machine Learning Assignment \\
\textbf{Author} & Teddy van Jerry (Wuqiong Zhao) \\
\grayrow \textbf{Maintainer} & Teddy van Jerry (Wuqiong Zhao) \\
\textbf{GitHub Repository} & \url{https://tvj.one/ml-tex} \\
\grayrow \textbf{Issues} & \url{https://tvj.one/ml-tex/issues} \\
+ \textbf{CTAN Package} & \url{https://www.ctan.org/pkg/seu-ml-assign} \\
+ \grayrow \textbf{Information Page} & \url{https://seu-ml-assign.github.io} \\
\textbf{Open Source License} & MIT License (\url{https://tvj.one/ml-tex/blob/master/LICENSE}) \\
\bottomrule
\end{tabular}%
@@ -50,46 +56,54 @@
You can contact me at \href{mailto:me@tvj.one}{me@tvj.one} for support.
- \section{Class Options}
+ \problem{Class Options}
To use this template, put \texttt{seu-ml-assign.cls} file under the same directory with your main \texttt{tex} file.
\begin{lstlisting}[language=tex,numbers=none]
\documentclass{seu-ml-assign} % SEU Machine Learning Assignment Template
\end{lstlisting}
- There are 6 supported options:
+ The page size is A4 paper. There are 8 supported options:
\begin{table}[htbp]
\bgroup
\def\arraystretch{1.2}
\setlength{\tabcolsep}{1.5em}
- \begin{tabular}{ll}
+ \begin{tabular}{llc}
\toprule
- \textbf{Option} & \textbf{Description} \\
+ \textbf{Option} & \textbf{Description} & \textbf{Default} \\
\midrule\midrule
- \grayrow \texttt{solution} & Write solutions (for students). \textbf{[Default]} \\
- \texttt{problem} & Write problem sets (for instructors). \\
- \grayrow \texttt{9pt} & Set font size as 9 points. \\
- \texttt{10pt} & Set font size as 10 points. \textbf{[Default]} \\
- \grayrow \texttt{11pt} & Set font size as 11 points. \\
- \texttt{12pt} & Set font size as 12 points. \\
+ \grayrow \texttt{solution} & Write solutions (for students). & \Large\textbullet \\
+ \texttt{problem} & Write problem sets (for instructors). & \\
+ \hline
+ \grayrow \texttt{oneside} & One-sided document. & \Large\textbullet \\
+ \texttt{twoside}& Two-sided document. & \\
+ \hline
+ \grayrow \texttt{9pt} & Set font size as 9 points. & \\
+ \texttt{10pt} & Set font size as 10 points. & \Large\textbullet \\
+ \grayrow \texttt{11pt} & Set font size as 11 points. & \\
+ \texttt{12pt} & Set font size as 12 points. & \\
\bottomrule
\end{tabular}%
\egroup
\end{table}
- For example, a 10pt document for instructors to create an assignment consisting of problem sets should use
+ For example, a 10pt, two-sided document for instructors to create an assignment consisting of problem sets should use
\begin{lstlisting}[language=tex,numbers=none]
-\documentclass[10pt,problem]{seu-ml-assign} % The 10pt option can be omitted.
+\documentclass[10pt,twoside,problem]{seu-ml-assign} % The 10pt option can be omitted.
\end{lstlisting}
+ With the \texttt{twoside} option, the header will switch style every page, as is the case in this documentation.
+ In contrast, the sample file uses the \texttt{oneside} option.
+
There are several differences between the \texttt{solution} mode and \texttt{problem} mode,
including the preset texts on the document (for example the student name is not shown in the \texttt{problem} mode) and some properties can only be used with the \texttt{problem} mode which will be elaborated on in \S\ref{subsec:prob_only_properties}.
- \section{Document Properties}
+ \problem{Document Properties}
- \subsection{Fields}
+ \subproblem{Fields}
There are several fields to set.
+ The \verb|\mainproblem{}| can be left empty.
Consider the following example used in the sample file:
\begin{lstlisting}[language=tex,numbers=none]
\title{Assignment} % Document Type: assignment, quiz, etc.
@@ -100,40 +114,63 @@
\duedate{20:00 March 21, 2022} % The Time the Assignment is Due
\assignno{1} % Assignment Number
\semester{SEU --- 2022 Spring} % Semester
+\mainproblem{Linear Algreba} % The Main Problem or Topic
\end{lstlisting}
With these fields set, you can use the command \verb|\maketitle| to print the title.
At the same time, the metadata for the PDF document is automatically set.
- \subsection{Problem Mode Only Properties}\label{subsec:prob_only_properties}
+ \subproblem{Problem Mode Only Properties}\label{subsec:prob_only_properties}
One of the fields \verb|\author{}| and \verb|\instructor{}| can be omitted or set as empty provided that they are the same.
- \section{Section Title (Problem) Settings}
+ \problem{Section Title (Problem) Settings}
+
+ \subproblem{Normal Title}\label{subsec:section_normal_title}
- \subproblem{Normal Title}
+ The title of a problem can be set as \verb|\problem{This is a Section Title}| or uses a lower level command \verb|\section{This is a Section Title}|.
+ There are two slight different between these two ways.
+ \begin{itemize}
+ \item The name in the table of contents (ToC) using \verb|\problem{}| will add the section/problem number before the section/problem title name.
+ \item The optional argument of \verb|\section{}| will set the name in the ToC which is by default in \LaTeX{} in the format of \verb|\section[<ToC Name>]{<Section Title Name>}|.
+ By contrast, the optional argument in \verb|\problem{}| sets the problem points as is detailed in \S\ref{subsec:problem_with_points}.
+ \end{itemize}
+ \verb|\section[\thesection~<Title>]{<Title>}|
+ is equivalent to
+ \verb|\problem{<Title>}| or \verb|\problem[]{<Title>}|.
+
+
+ \subproblem{Unnumbered Title}
- The title of a problem can be set as \verb|\section{This is a Section Title}| or uses a higher level command \verb|\problem{This is a Section Title}|.
+ Use the \verb|\section*{}| or \verb|\problem*{}| to get an unnumbered section.\vspace{-8mm}
- \subproblem{Problem with Points}
+ \problem*{This is an Unnumbered Problem}
+
+ This title will also not appear in the ToC or bookmarks of the PDF.
+
+ \subproblem{Problem with Points}\label{subsec:problem_with_points}
The points of a problem can be set using command \verb|\problempts{xxx}| before calling the \verb|\section{}| command.
These two commands can be simplified to \verb|\problem[xxx]{}|.
- For example, using the command \verb|\problem[15]{This is a Problem Worth 15 Points}| will have:\vspace{-8mm}
+ For example, using the command \verb|\problem[15]{This is a Problem Worth 15 Points}| will have:\footnote{This title is actually faked in this documentation because I do not want the ToC of this documentation contaminated. But it will look the same.}\vspace{-8mm}
\renewcommand{\sectionheadname}{Problem}
\setproblem{1}
% \problem[15]{This is a Problem Worth 15 Points}
+ % Here I have to 'fake' this title
+ % because I do not want it to ruin the ToC.
\problempts{15}
- \section*{This is a Problem Worth 15 Points}
+ \section*{Problem 1:\hspace{0.33em}This is a Problem Worth 15 Points}
Note that if the point is an empty string, the point information will not be shown.
\subproblem{Long Title Compatibility}
- There is also no problem if the section title is too long.\vspace{-8mm}
+ There is also no problem if the section title is too long.\footnote{This title is also faked.}\vspace{-8mm}
+ % Here I have to 'fake' this title again
+ % because I do not want it to ruin the ToC.
\setproblem{2}
\problempts{20}
- \section*{I Don't Think that Anyone Will Enjoy Themselves Seeing a Very Very Long Problem That is Worth Twenty Points in this Machine Learning Course}
+ \section*{Problem 2:\hspace{0.33em}I Don't Think that Anyone Will Enjoy Themselves Seeing a Very\\\hspace{5.2em}Very Long Problem That is Worth Twenty Points in this Machine\\\hspace{5.2em}Learning Course}
\renewcommand{\sectionheadname}{Section}
\setproblem{4}
@@ -149,66 +186,163 @@
You can use \verb|\startsolution| to declare you start writing the solution.
This will reset the section number and it is especially useful when your document contains problems and solutions as two separate parts.
There is an option \texttt{print} and if you use \verb|\startsolution[print]| you will get:
+ \vspace{-\baselineskip}
\startsolution[print]
and the word \textsc{Solution} can be changed using command \verb|\renewcommand{\solutionname}{Other Name}|.
\setproblem{4}
- \section{Subsection Title (Sub Problem) Settings}
+ \problem{Subsection Title (Sub Problem) Settings}
- \subproblem{Normal Title} This is a normal title using command \verb|\subproblem{Normal Title}| or its equivalent command \verb|\subsection{Normal Title}|.
+ \subproblem{Normal Title} This is a normal title using command \verb|\subproblem{Normal Title}| or alternatively the command \verb|\subsection{Normal Title}|.
+ There is a slight difference between these two commands which is similar to the case stated in \S\ref{subsec:section_normal_title}.
+ The command
+ \verb|\subproblem{}| adds the sub problem number in ToC and bookmarks.
+ \verb|\subsection[(\arbic{subsection}) <Title>]{<Title>}|
+ is equivalent to \verb|\subproblem{<Title>}|.
\subproblem{} Use \verb|\subproblem{}| or \verb|\subsection{}| if only the sub problem number is required (like this line).
\subproblem{Subsection Number} Similar to \verb|\setproblem{}|, there is also \verb|\setsubproblem{}|.
- \section{Other Tools}
+ \subproblem{Subsubsection (Sub Sub Problem)} For completeness,
+ \verb|\subsubsection{}| and \verb|\subsubproblem{}| are provided.
+ One example is \S\ref{subsubsec:hint}, where
+ \verb|\subsubsection[\arbic{subsubsection}. <Title>]{<Title>}|
+ is equivalent to \verb|\subsubproblem{<Title>}|.
- \subsection{Equation Numbering} The equation number is within the section (problem), for example
+ \problem{Other Tools}
- \begin{equation}\label{eq:2-1-det}
+ \subproblem{Equation Numbering} The equation number is within the section (problem), for example
+ \begin{equation}\label{eq:eq_num_example}
\mathrm{det}(\mathbf{A})=1\times\begin{vNiceArray}{rr}
-5&3\\-6&4
\end{vNiceArray}-(-3)\times\begin{vNiceArray}{rr}
3&3\\6&4
\end{vNiceArray}+3\times\begin{vNiceArray}{rr}
3&-5\\6&-6
- \end{vNiceArray}=1\times(-2)+3\times(-6)+3\times 12=16.
+ \end{vNiceArray}=1\times(-2)+3\times(-6)+3\times 12=16,
\end{equation}
+ which uses the \texttt{equation} environment and can be referenced using the command \verb|\eqref{eq:xxx}|
+ with a corresponding \verb|\label{eq:xxx}| in Eq.~\eqref{eq:eq_num_example}.
- \subsection{Maths Packages} Maths Package \texttt{mathtools}, \texttt{amssymb}, \texttt{amsthm}, \texttt{bm} and \texttt{nicematrix} are automatically loaded.
+ \subproblem{Maths Packages} Maths Package \texttt{mathtools}, \texttt{amssymb}, \texttt{amsthm}, \texttt{bm} and \texttt{nicematrix} are automatically loaded.
The \texttt{nicematrix} package is especially powerful in terms of writing a matrix.
You can find its documentation at \url{https://ctan.org/pkg/nicematrix}.
+ It is worth noting that \texttt{nccmath} can lead to potential subsection (sub problem) title indentation problem and therefore should not be loaded.
+
+ \subproblem{Theorem Environment} Environments \texttt{theorem}, \texttt{proposition}, \texttt{lemma}, \texttt{corollary} have been defined.
+ For example:
+ \begin{lemma}
+ This is a lemma. Its numbering is within the section.
+ You can create such environment using the code \verb|\begin{lemma} Your lemma contents here. \end{lemma}|.
+ % The same code pattern applies to \texttt{theorem}, \texttt{proposition} and \texttt{corollary}.
+ \end{lemma}
+
+ \subproblem{Additional Math Operator} The additional math operator is listed in the table below.
+ \begin{table}[htbp]
+ \begin{threeparttable}
+ \bgroup
+ \def\arraystretch{1.2}
+ \setlength{\tabcolsep}{1.5em}
+ \begin{tabular}{lll}
+ \toprule
+ \textbf{Command} & \textbf{Definition} & \textbf{Inline Example} \\
+ \midrule\midrule
+ \grayrow \verb|\argmin| & \verb|\DeclareMathOperator*{\argmin}{\arg\min}| & $\argmin_{x}(x-2)^2+1$ \\
+ \verb|\argmax| & \verb|\DeclareMathOperator*{\argmax}{\arg\max}| & $\argmax_{\mathbf{x}} f(\mathbf{x})$ \\
+ \bottomrule
+ \end{tabular}%
+ \begin{tablenotes}\footnotesize
+ \item Operators defined with the \texttt{*} after \verb|\DeclareMathOperator| have their subscript under the operator in the \texttt{equation} mode, which can be suppressed by adding \verb|\nolimits| before the \verb|_|.
+ \end{tablenotes}
+ \egroup
+ \end{threeparttable}
+ \end{table}
- \subsection{Fancy Box} A fancy box has been defined.
- \begin{fancybox}{This is a Title}
+ Here is an example:
+ \begin{lstlisting}[language=tex,numbers=none,morekeywords={begin}]
+\begin{equation}
+ \argmin_{x}(x-2)^2+1,\quad \argmax_{\mathbf{x}} f(\mathbf{x}),\quad \argmin\nolimits_{\alpha}g(\alpha)
+\end{equation}
+ \end{lstlisting}
+ \begin{equation}
+ \argmin_{x}(x-2)^2+1,\quad \argmax_{\mathbf{x}} f(\mathbf{x}),\quad \argmin\nolimits_{\alpha}g(\alpha)
+ \end{equation}
+
+ \subproblem{Shortcuts} Some shortcuts commands have been defined in this class.
+
+ \subsubproblem{Hint}\label{subsubsec:hint}
+ You can easily use command \verb|\hint{}| to show a hint to a problem.
+ This is especially useful in the \texttt{problem} mode.
+ \hint{You can use \texttt{\string\renewcommand\{\string\hintstyle\}\{<Your Style>\}} to change the default one.}
+
+ \subproblem{Code Block} You can use code blocks in this class which is implemented by the \texttt{lstlisting} environment.
+ Their default styles have been set and you can make changes by passing optional arguments when using the environment.
+ For more information, please refer to \url{https://ctan.org/pkg/listings}.
+
+ \subproblem{Fancy Box} A fancy box has been defined.
+ \begin{fancybox}{This is a Fancy Box}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin viverra massa rutrum felis vulputate, ac faucibus velit accumsan. Vivamus aliquet felis nec interdum sollicitudin. Nullam ornare eu velit id cursus. Maecenas a sodales velit, vel cursus magna. Cras lobortis venenatis.
\end{fancybox}
-
You can use the following code to generate it.
\begin{lstlisting}[language=tex,numbers=none,morekeywords={begin}]
-\begin{fancybox}{This is a Title}
+\begin{fancybox}{This is a Fancy Box}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin viverra massa rutrum felis vulputate, ac faucibus velit accumsan. Vivamus aliquet felis nec interdum sollicitudin. Nullam ornare eu velit id cursus. Maecenas a sodales velit, vel cursus magna. Cras lobortis venenatis.
\end{fancybox}
\end{lstlisting}
+ There is also a \texttt{notice} box:
+ \begin{notice}{This is a Notice Box}
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin viverra massa rutrum felis vulputate, ac faucibus velit accumsan. Vivamus aliquet felis nec interdum sollicitudin. Nullam ornare eu velit id cursus. Maecenas a sodales velit, vel cursus magna. Cras lobortis venenatis.
+ \end{notice}
+
+ You can use the following code to generate it.
+ \begin{lstlisting}[language=tex,numbers=none,morekeywords={begin}]
+\begin{notice}{This is a Notice Box}
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin viverra massa rutrum felis vulputate, ac faucibus velit accumsan. Vivamus aliquet felis nec interdum sollicitudin. Nullam ornare eu velit id cursus. Maecenas a sodales velit, vel cursus magna. Cras lobortis venenatis.
+\end{notice}
+ \end{lstlisting}
+
\appendix
\renewcommand{\sectionheadname}{Appendix}
- \section{Known Issues}\label{sec:known_issues}
+ \problem{Known Issues}\label{sec:known_issues}
\begin{itemize}
- \item \verb|\section*{}| still shows the section number except for it does not increment the section counter by one;
\item The section title background height may not be accurate;
- \item The style of the footnote line has not been adapted to the current colorful theme.
\end{itemize}
- \section{Source Code}
-
- The source code of \texttt{SEU-ML-Assign.cls} is listed below.
-
- \lstinputlisting[language=tex,linerange={15-1000},firstnumber=15]{SEU-ML-Assign.cls}
+ If you find more issues, please report them on \url{https://tvj.one/ml-tex/issues}.
+
+ \problem{Change Log}
+
+ \begin{multicols}{2}
+ \begin{itemize}
+ \item [\textbf{v1.1}] 2022/03/28 -- Bug Fix and Enhancement
+ \begin{enumerate}
+ \item Add \verb|\mainproblem{}| command;
+ \item Add \verb|\subsubproblem{}| command;
+ \item Add \verb|\hint{}| shortcut;
+ \item Support for \verb|\section*{}|, \verb|\problem*{}|, \verb|\subsection*{}| and \verb|\subproblem*{}|;
+ \item Fix ToC/Bookmarks problem;
+ \item Set footnote line style;
+ \item Add the \texttt{twoside} option.
+ \end{enumerate}
+ \item [\textbf{v1.0}] 2022/03/19 -- Initial Version
+ \begin{enumerate}
+ \item Initial \texttt{cls} file in addition to a sample file and documentation;
+ \item Publish at GitHub and CTAN.
+ \end{enumerate}
+ \end{itemize}
+ \end{multicols}
+
+ \problem{Source Code}
+
+ The source code of \texttt{seu-ml-assign.cls} is listed below.
+
+ \lstinputlisting[language=tex,linerange={15-1000},firstnumber=15,morekeywords={begin}]{seu-ml-assign.cls}
\end{document} \ No newline at end of file
diff --git a/macros/latex/contrib/seu-ml-assign/seu-ml-assign-sample.tex b/macros/latex/contrib/seu-ml-assign/seu-ml-assign-sample.tex
index de5bf5f833..0c706af756 100644
--- a/macros/latex/contrib/seu-ml-assign/seu-ml-assign-sample.tex
+++ b/macros/latex/contrib/seu-ml-assign/seu-ml-assign-sample.tex
@@ -1,6 +1,6 @@
%! TEX program = pdflatex
-\documentclass[solution]{seu-ml-assign}
+\documentclass[oneside,solution]{seu-ml-assign}
\title{Assignment}
\author{Teddy van Jerry}
@@ -10,6 +10,7 @@
\duedate{20:00 March 21, 2022}
\assignno{1}
\semester{SEU --- 2022 Spring}
+\mainproblem{Linear Algreba}
\begin{document}
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}
}