From 3e21dfd1df3232fc62bdf7cccc325127a7328911 Mon Sep 17 00:00:00 2001
From: Jan Wille <jan.wille@stud.hs-hannover.de>
Date: Sat, 15 Jun 2024 14:02:58 +0200
Subject: [PATCH] proper error handling for `\maketitle`

---
 src/HsH-Logo.pdf       |  4 ++--
 src/HsH-article.cls    | 39 ++++++++++++++++---------------
 src/HsH-classes.dtx    | 53 ++++++++++++++++++++++++------------------
 src/HsH-classes.pdf    |  4 ++--
 src/HsH-report.cls     | 39 ++++++++++++++++---------------
 src/HsH-standalone.cls |  2 +-
 6 files changed, 76 insertions(+), 65 deletions(-)

diff --git a/src/HsH-Logo.pdf b/src/HsH-Logo.pdf
index eb0c23a..f76ccde 100644
--- a/src/HsH-Logo.pdf
+++ b/src/HsH-Logo.pdf
@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:d010945bf17d80d935a688d9c484c2424d6aa99c01fe1ddf74e330f3e13cef8d
-size 25799
+oid sha256:16b419c2e1327710c705d9c5af8bf16fdaf7d0ff98745c2a44e252d03e56f4ab
+size 25795
diff --git a/src/HsH-article.cls b/src/HsH-article.cls
index feca314..61e1bd7 100644
--- a/src/HsH-article.cls
+++ b/src/HsH-article.cls
@@ -17,7 +17,7 @@
 %% 
 \NeedsTeXFormat{LaTeX2e}[2022-06-01]
 \ProvidesClass{HsH-article}
-  [2024-06-14 3.03.pre0 HsH-class based on KOMA]
+  [2024-06-15 3.03.pre1 HsH-class based on KOMA]
 \let\HsHClassName\@currname
 \def\HsHClassName@ParrentClass{%
   scrartcl%
@@ -463,6 +463,14 @@
 \ofoot*{\pagemark}
 \pagestyle{HsHheadings}
 \automark{section}
+\renewcommand\maketitle[1][c]{
+  \if#1l\@maketitle{#1}\else%
+  \if#1c\@maketitle{#1}\else%
+  \if#1r\@maketitle{#1}\else%
+    \ClassWarning{\HsHClassName}{unkown option for \maketitle}
+    \thispagestyle{empty}\null\clearpage
+  \fi\fi\fi
+}
 \newtoks\@tabtoks
 \newcommand\addtabtoks[1]{\global\@tabtoks\expandafter{\the\@tabtoks#1}}
 \newcommand\eaddtabtoks[1]{\edef\mytmp{#1}\expandafter\addtabtoks\expandafter{\mytmp}}
@@ -470,7 +478,7 @@
 \newcommand*\printtabtoks{\the\@tabtoks}
 \addtokomafont{publishers}{\normalsize}
 \g@addto@macro\titlepage{\singlespacing}
-\renewcommand\maketitle[1][c]{
+\renewcommand*\@maketitle[1]{
   \expandafter\ifnum \csname scr@v@3.12\endcsname>\scr@compatibility\relax
   \else
     \def\and{%
@@ -495,13 +503,6 @@
     }
   \fi
   \begingroup
-    \let\@param#1
-    \ifx\@param\@empty
-      \ClassError{\myClassName}{\maketitle\space with empty option}{
-        \maketitle[] has been called (with an empty parameter), this doesn't work.
-        Use \maketitle instead.
-      }
-    \fi
     \let\titlepage@restore\relax
     \renewcommand*\thefootnote{\@fnsymbol\c@footnote}%
     \let\@oldmakefnmark\@makefnmark
@@ -533,8 +534,8 @@
     \null
     \vskip 2em
     \begingroup
-      \if\@param c\centering\fi
-      \if\@param r\raggedleft\fi
+      \if#1c\centering\fi
+      \if#1r\raggedleft\fi
       \ifx\@subject\@empty\else
         {\usekomafont{subject}{\@subject\par}}
         \vskip 1.5em
@@ -546,8 +547,8 @@
       {\ifx\@matrikelnr\@empty
         \if\@author\@empty\else\usekomafont{author}{
           \parbox{\dimexpr\linewidth}{
-            \if\@param c\centering\fi
-            \if\@param r\raggedleft\fi
+            \if#1c\centering\fi
+            \if#1r\raggedleft\fi
             \@author
           }
         }\fi
@@ -557,9 +558,9 @@
           \foreach \x [count=\i,evaluate=\i as \y using {{\@matrikelnr,}[\i-1]}] in \@author {\eaddtabtoks{\x & \y\protect\\}}
           \usekomafont{author}{
             \def\arraystretch{1.2}
-            \if\@param l\begin{tabular}{@{}l l}\fi
-            \if\@param c\begin{tabular}{l l}\fi
-            \if\@param r\begin{tabular}{r r@{}}\fi
+            \if#1l\begin{tabular}{@{}l l}\fi
+            \if#1c\begin{tabular}{l l}\fi
+            \if#1r\begin{tabular}{r r@{}}\fi
               \printtabtoks
             \end{tabular}
           }%
@@ -570,9 +571,9 @@
       \vskip 1em
       \usekomafont{publishers}{
         \def\arraystretch{1.2}
-        \if\@param l\begin{tabular}{@{}l l}\fi
-        \if\@param c\begin{tabular}{l l}\fi
-        \if\@param r\begin{tabular}{r r@{}}\fi
+        \if#1l\begin{tabular}{@{}l l}\fi
+        \if#1c\begin{tabular}{l l}\fi
+        \if#1r\begin{tabular}{r r@{}}\fi
           \if\@professor\@empty\else\textbf{\professorname:}&\@professor\\\fi
           \if\@firstexaminer\@empty\else\textbf{\firstexaminername:}&\@firstexaminer\\\fi
           \if\@secondexaminer\@empty\else\textbf{\secondexaminername:}&\@secondexaminer\\\fi
diff --git a/src/HsH-classes.dtx b/src/HsH-classes.dtx
index c79c9ec..0d0eb4e 100644
--- a/src/HsH-classes.dtx
+++ b/src/HsH-classes.dtx
@@ -74,7 +74,7 @@ http://www.latex-project.org/lppl.txt
 %<report>\ProvidesClass{HsH-report}
 %<standalone>\ProvidesClass{HsH-standalone}
 %<*article|report|standalone>
-  [2024-06-14 3.03.pre0 HsH-class based on KOMA]
+  [2024-06-15 3.03.pre1 HsH-class based on KOMA]
 %</article|report|standalone>
 %<*driver> ^^A ---------- documentation driver -----------------------------------------
 \documentclass{ltxdoc}
@@ -1552,10 +1552,27 @@ http://www.latex-project.org/lppl.txt
 %   \subsubsection{Titlepage}
 %
 %     \begin{macro}{\maketitle}
-%       The definiton of |\maketitle| is mostly taken from the source-code of the
-%       \KOMAScript{} parrentclass, but was modified to create the desired style.
+%       |\maketitle| is a wrapper for |\@maketitle| that just checks the
+%       parameter and issues an error message if it is incorrect.
+%       It also handles the diffrent default for article or report.
 %    \begin{macrocode}
 %<*article|report>
+%<article>\renewcommand\maketitle[1][c]{
+%<report>\renewcommand\maketitle[1][l]{
+  \if#1l\@maketitle{#1}\else%
+  \if#1c\@maketitle{#1}\else%
+  \if#1r\@maketitle{#1}\else%
+    \ClassWarning{\HsHClassName}{unkown option for \maketitle}
+    \thispagestyle{empty}\null\clearpage
+  \fi\fi\fi
+}
+%    \end{macrocode}
+%     \end{macro}
+%
+%     \begin{macro}{\@maketitle}
+%       The definiton of |\@maketitle| is mostly taken from the source-code of the
+%       \KOMAScript{} parrentclass, but was modified to create the desired style.
+%    \begin{macrocode}
 \newtoks\@tabtoks
 \newcommand\addtabtoks[1]{\global\@tabtoks\expandafter{\the\@tabtoks#1}}
 \newcommand\eaddtabtoks[1]{\edef\mytmp{#1}\expandafter\addtabtoks\expandafter{\mytmp}}
@@ -1564,8 +1581,7 @@ http://www.latex-project.org/lppl.txt
 \addtokomafont{publishers}{\normalsize}
 \g@addto@macro\titlepage{\singlespacing}
 %
-%<article>\renewcommand\maketitle[1][c]{
-%<report>\renewcommand\maketitle[1][l]{
+\renewcommand*\@maketitle[1]{
   \expandafter\ifnum \csname scr@v@3.12\endcsname>\scr@compatibility\relax
   \else
     \def\and{%
@@ -1593,13 +1609,6 @@ http://www.latex-project.org/lppl.txt
 %</article>
 %<report>  \begin{titlepage}
 %<article>  \begingroup
-    \let\@param#1
-    \ifx\@param\@empty
-      \ClassError{\myClassName}{\maketitle\space with empty option}{
-        \maketitle[] has been called (with an empty parameter), this doesn't work.
-        Use \maketitle instead.
-      }
-    \fi
 %<*report>
     \if@titlepageiscoverpage
       \edef\titlepage@restore{
@@ -1684,8 +1693,8 @@ http://www.latex-project.org/lppl.txt
 %<article>    \vskip 2em
 %<report>    \vfill
     \begingroup
-      \if\@param c\centering\fi
-      \if\@param r\raggedleft\fi
+      \if#1c\centering\fi
+      \if#1r\raggedleft\fi
       \ifx\@subject\@empty\else
         {\usekomafont{subject}{\@subject\par}}
 %<article>        \vskip 1.5em
@@ -1699,8 +1708,8 @@ http://www.latex-project.org/lppl.txt
       {\ifx\@matrikelnr\@empty
         \if\@author\@empty\else\usekomafont{author}{
           \parbox{\dimexpr\linewidth}{
-            \if\@param c\centering\fi
-            \if\@param r\raggedleft\fi
+            \if#1c\centering\fi
+            \if#1r\raggedleft\fi
             \@author
           }
         }\fi
@@ -1710,9 +1719,9 @@ http://www.latex-project.org/lppl.txt
           \foreach \x [count=\i,evaluate=\i as \y using {{\@matrikelnr,}[\i-1]}] in \@author {\eaddtabtoks{\x & \y\protect\\}}
           \usekomafont{author}{
             \def\arraystretch{1.2}
-            \if\@param l\begin{tabular}{@{}l l}\fi
-            \if\@param c\begin{tabular}{l l}\fi
-            \if\@param r\begin{tabular}{r r@{}}\fi
+            \if#1l\begin{tabular}{@{}l l}\fi
+            \if#1c\begin{tabular}{l l}\fi
+            \if#1r\begin{tabular}{r r@{}}\fi
               \printtabtoks
             \end{tabular}
           }%
@@ -1725,9 +1734,9 @@ http://www.latex-project.org/lppl.txt
 %<report>      \vskip \z@ \@plus3fill
       \usekomafont{publishers}{
         \def\arraystretch{1.2}
-        \if\@param l\begin{tabular}{@{}l l}\fi
-        \if\@param c\begin{tabular}{l l}\fi
-        \if\@param r\begin{tabular}{r r@{}}\fi
+        \if#1l\begin{tabular}{@{}l l}\fi
+        \if#1c\begin{tabular}{l l}\fi
+        \if#1r\begin{tabular}{r r@{}}\fi
           \if\@professor\@empty\else\textbf{\professorname:}&\@professor\\\fi
           \if\@firstexaminer\@empty\else\textbf{\firstexaminername:}&\@firstexaminer\\\fi
           \if\@secondexaminer\@empty\else\textbf{\secondexaminername:}&\@secondexaminer\\\fi
diff --git a/src/HsH-classes.pdf b/src/HsH-classes.pdf
index ba48d16..b7fe37d 100644
--- a/src/HsH-classes.pdf
+++ b/src/HsH-classes.pdf
@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:7849fd44b916d0c09a9a8001f12f4453db42e21b833ba9a6addc2ec55b6c6dd5
-size 314950
+oid sha256:a3ca4d9ef1ccd59568fd1dda194377c0e06b81b98f3f491ef05fbe0232b4d407
+size 314945
diff --git a/src/HsH-report.cls b/src/HsH-report.cls
index 3c74cd9..8ab2109 100644
--- a/src/HsH-report.cls
+++ b/src/HsH-report.cls
@@ -17,7 +17,7 @@
 %% 
 \NeedsTeXFormat{LaTeX2e}[2022-06-01]
 \ProvidesClass{HsH-report}
-  [2024-06-14 3.03.pre0 HsH-class based on KOMA]
+  [2024-06-15 3.03.pre1 HsH-class based on KOMA]
 \let\HsHClassName\@currname
 \def\HsHClassName@ParrentClass{%
   scrreprt%
@@ -477,6 +477,14 @@
 \pagestyle{HsHheadings}
 \automark{chapter}
 \renewcommand*{\chapterpagestyle}{HsHheadings}
+\renewcommand\maketitle[1][l]{
+  \if#1l\@maketitle{#1}\else%
+  \if#1c\@maketitle{#1}\else%
+  \if#1r\@maketitle{#1}\else%
+    \ClassWarning{\HsHClassName}{unkown option for \maketitle}
+    \thispagestyle{empty}\null\clearpage
+  \fi\fi\fi
+}
 \newtoks\@tabtoks
 \newcommand\addtabtoks[1]{\global\@tabtoks\expandafter{\the\@tabtoks#1}}
 \newcommand\eaddtabtoks[1]{\edef\mytmp{#1}\expandafter\addtabtoks\expandafter{\mytmp}}
@@ -484,7 +492,7 @@
 \newcommand*\printtabtoks{\the\@tabtoks}
 \addtokomafont{publishers}{\normalsize}
 \g@addto@macro\titlepage{\singlespacing}
-\renewcommand\maketitle[1][l]{
+\renewcommand*\@maketitle[1]{
   \expandafter\ifnum \csname scr@v@3.12\endcsname>\scr@compatibility\relax
   \else
     \def\and{%
@@ -494,13 +502,6 @@
     }
   \fi
   \begin{titlepage}
-    \let\@param#1
-    \ifx\@param\@empty
-      \ClassError{\myClassName}{\maketitle\space with empty option}{
-        \maketitle[] has been called (with an empty parameter), this doesn't work.
-        Use \maketitle instead.
-      }
-    \fi
     \if@titlepageiscoverpage
       \edef\titlepage@restore{
         \noexpand\endgroup
@@ -563,8 +564,8 @@
     \null
     \vfill
     \begingroup
-      \if\@param c\centering\fi
-      \if\@param r\raggedleft\fi
+      \if#1c\centering\fi
+      \if#1r\raggedleft\fi
       \ifx\@subject\@empty\else
         {\usekomafont{subject}{\@subject\par}}
         \vskip 3em
@@ -576,8 +577,8 @@
       {\ifx\@matrikelnr\@empty
         \if\@author\@empty\else\usekomafont{author}{
           \parbox{\dimexpr\linewidth}{
-            \if\@param c\centering\fi
-            \if\@param r\raggedleft\fi
+            \if#1c\centering\fi
+            \if#1r\raggedleft\fi
             \@author
           }
         }\fi
@@ -587,9 +588,9 @@
           \foreach \x [count=\i,evaluate=\i as \y using {{\@matrikelnr,}[\i-1]}] in \@author {\eaddtabtoks{\x & \y\protect\\}}
           \usekomafont{author}{
             \def\arraystretch{1.2}
-            \if\@param l\begin{tabular}{@{}l l}\fi
-            \if\@param c\begin{tabular}{l l}\fi
-            \if\@param r\begin{tabular}{r r@{}}\fi
+            \if#1l\begin{tabular}{@{}l l}\fi
+            \if#1c\begin{tabular}{l l}\fi
+            \if#1r\begin{tabular}{r r@{}}\fi
               \printtabtoks
             \end{tabular}
           }%
@@ -600,9 +601,9 @@
       \vskip \z@ \@plus3fill
       \usekomafont{publishers}{
         \def\arraystretch{1.2}
-        \if\@param l\begin{tabular}{@{}l l}\fi
-        \if\@param c\begin{tabular}{l l}\fi
-        \if\@param r\begin{tabular}{r r@{}}\fi
+        \if#1l\begin{tabular}{@{}l l}\fi
+        \if#1c\begin{tabular}{l l}\fi
+        \if#1r\begin{tabular}{r r@{}}\fi
           \if\@professor\@empty\else\textbf{\professorname:}&\@professor\\\fi
           \if\@firstexaminer\@empty\else\textbf{\firstexaminername:}&\@firstexaminer\\\fi
           \if\@secondexaminer\@empty\else\textbf{\secondexaminername:}&\@secondexaminer\\\fi
diff --git a/src/HsH-standalone.cls b/src/HsH-standalone.cls
index 29b2630..b1720da 100644
--- a/src/HsH-standalone.cls
+++ b/src/HsH-standalone.cls
@@ -17,7 +17,7 @@
 %% 
 \NeedsTeXFormat{LaTeX2e}[2022-06-01]
 \ProvidesClass{HsH-standalone}
-  [2024-06-14 3.03.pre0 HsH-class based on KOMA]
+  [2024-06-15 3.03.pre1 HsH-class based on KOMA]
 \let\HsHClassName\@currname
 \def\HsHClassName@ParrentClass{%
   standalone%
-- 
GitLab