From 779da3ad96e14e5644d167f52eac0ab6c43d31b9 Mon Sep 17 00:00:00 2001
From: Jan Wille <jan.wille@stud.hs-hannover.de>
Date: Fri, 26 Apr 2024 17:32:01 +0200
Subject: [PATCH] implement abstract

---
 CHANGELOG.md           |  7 ++++
 src/HsH-Logo.pdf       |  4 +--
 src/HsH-article.cls    | 50 ++++++++++++++++++++++++--
 src/HsH-classes.dtx    | 79 +++++++++++++++++++++++++++++++++++++++---
 src/HsH-classes.pdf    |  4 +--
 src/HsH-report.cls     | 50 ++++++++++++++++++++++++--
 src/HsH-standalone.cls | 16 ++++++++-
 test.pdf               |  4 +--
 test.tex               |  3 +-
 9 files changed, 200 insertions(+), 17 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 20a1262..71ee4cc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,8 +7,15 @@ All notable changes to this project will be documented in this file.
 
 ### Fixed
 
+- implement the `abstract` enviroment to behave as pre v3
 - removed debug print from `latexmk` inkscape recipy
 
+### Added
+
+- option `abstract`
+  - `abstract=keywords|nokeywords` to enable/disable the display of keywords after the abstract
+  - `abstract=totoc|notoc` to add the abstract to the TOC
+
 ## [3.0]
 
 ### Breaking
diff --git a/src/HsH-Logo.pdf b/src/HsH-Logo.pdf
index 12046a7..cf3b12a 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:a1c240f43ff581587a7ffc676b7ab7026855e2882259278ee766edb4a49317fa
-size 28164
+oid sha256:76197994ebca0e82c4fb4be663c9df2123c74d05991ca492fbfd44d8c0568a95
+size 25798
diff --git a/src/HsH-article.cls b/src/HsH-article.cls
index 0991933..4c23aeb 100644
--- a/src/HsH-article.cls
+++ b/src/HsH-article.cls
@@ -17,7 +17,7 @@
 %% 
 \NeedsTeXFormat{LaTeX2e}[2022-06-01]
 \ProvidesClass{HsH-article}
-  [2024-04-25 3.01 HsH-class based on KOMA]
+  [2024-04-26 3.01 HsH-class based on KOMA]
 \let\HsHClassName\@currname
 \def\HsHClassName@ParrentClass{%
   scrartcl%
@@ -122,6 +122,37 @@
 \AtEndOfClass{%
   \headheight=\HsH@opt@headheight%
 }
+\newif\if@HsH@option@abstract@show@keywords
+\def\HsH@abstract@chap{\addchap*}
+\DefineFamilyKey{HsH}{abstract}{%
+  \begingroup
+  \FamilySetNumerical{HsH}{abstract}{@tempa}{%
+    {keywords}{0},%
+    {nokeywords}{1},%
+    {totoc}{2},{toc}{2},%
+    {notoc}{3},{nottotoc}{3},%
+  }{#1}
+  \ifx\FamilyKeyState\FamilyKeyStateProcessed
+    \aftergroup\FamilyKeyStateProcessed
+    \ifcase\@tempa% 0
+      \endgroup
+      \@HsH@option@abstract@show@keywordstrue
+    \or% 1
+      \endgroup
+      \@HsH@option@abstract@show@keywordsfalse
+    \or% 2
+      \endgroup
+      \def\HsH@abstract@chap{\addchap}
+    \or% 3
+      \endgroup
+      \def\HsH@abstract@chap{\addchap*}
+    \else% should never be
+      \endgroup
+    \fi
+  \else
+    \endgroup
+  \fi
+}
 \DefineFamilyKey{HsH}{twoside}[semi]{%
   \HsH@Options@PassToParrent{twoside=#1,BCOR=1cm}
   \FamilyKeyStateProcessed
@@ -162,6 +193,7 @@
   headheight=2.15\baselineskip,
   toc=listof,
   toc=bibliography,
+  abstract=keywords,
   faculty=none,
 }
 \FamilyProcessOptions{HsH}\relax
@@ -361,6 +393,20 @@
 \renewcommand{\labelitemii}{\raisebox{.3ex}{\scalebox{0.7}{$\circ$}}}
 \renewcommand{\labelitemiii}{\raisebox{.1ex}{-}}
 \renewcommand{\labelitemiv}{\raisebox{-.1ex}{\scalebox{1.3}{$\cdot$}}}
+\defcaptionname{german,ngerman}\abstractname{Abstract}
+\newcaptionname{english}\keywordsname{Keywords}
+\newcaptionname{german,ngerman}\keywordsname{Schl{\"u}sselw{\"o}rter}
+\renewenvironment{abstract}{
+  \quotation
+  \setparsizes{\z@}{\z@}{.25\linewidth \@plus 1fil}\selectfont
+  \HsH@abstract@chap{\abstractname}
+}{%
+  \ifx\@keywords\@empty\else\if@HsH@option@abstract@show@keywords
+    \par\bigskip
+    \noindent\textbf{\keywordsname}\hskip 2em\@keywords
+  \fi\fi\par
+  \endquotation
+}
 \upsubscripts
 \raggedbottom
 \let\layercontentsmeasure\relax
@@ -551,7 +597,7 @@
     \global\let\@lowertitleback\@empty
     \global\let\@dedication\@empty
     \global\let\@matrikelnr\@empty
-    \global\let\@prof\@empty
+    \global\let\@professor\@empty
     \global\let\author\relax
     \global\let\title\relax
     \global\let\extratitle\relax
diff --git a/src/HsH-classes.dtx b/src/HsH-classes.dtx
index 6f21548..333d070 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-04-25 3.01 HsH-class based on KOMA]
+  [2024-04-26 3.01 HsH-class based on KOMA]
 %</article|report|standalone>
 %<*driver> ^^A ---------- documentation driver -----------------------------------------
 \documentclass{ltxdoc}
@@ -253,6 +253,16 @@ http://www.latex-project.org/lppl.txt
 %   message. The emssage should tell you what value you need, but you can pass any
 %   valid length.
 %
+%   \DescribeOption{abstract}
+%   The \opt{abstract=\meta{opt}} option allows you to configure different behaviors of the abstract.
+%   The availabel options are described below:
+%   \begin{options}
+%     \item[keywords] Print the \cmd{\keywords} after the abstract.
+%     \item[nokeywords] Do \emph{not} print the \cmd{\keywords} after the abstract.
+%     \item[totoc] The abstract will be listed in the table of contentes.
+%     \item[notoc] The abstract will \emph{not} be listed in the table of contentes.
+%   \end{options}
+%
 %   \paragraph{Often relevant \KOMAScript\ options}
 %   The following options are implemented by the parrent classes and only listed here
 %   for completness. For more detils, see \href{http://mirrors.ctan.org/macros/latex/contrib/koma-script/doc/scrguide-en.pdf?page=239#chapter.3}{its manual}.
@@ -272,11 +282,10 @@ http://www.latex-project.org/lppl.txt
 %   the inner edge.
 %
 %   \DescribeOption{BCOR}
-%   The \opt{BCOR=}\meta{dim} option allows you to define a custom binding-correction.
+%   The \opt{BCOR=\meta{dim}} option allows you to define a custom binding-correction.
 %   Any valid length can be put here, but to large of a value will shrink the outer
 %   margin to a not-desirable level.
 %
-%
 % \subsection{Standalone specific options}
 %   The \cls{standalone} utillity class has some special options which are documented
 %   here.
@@ -640,6 +649,47 @@ http://www.latex-project.org/lppl.txt
 %    \end{macrocode}
 %   \end{option}
 %
+%   \begin{option}{abstract}
+%     The \opt{abstract} option sets multiple different switches and configureations.
+%     We first define the needed macros:
+%    \begin{macrocode}
+\newif\if@HsH@option@abstract@show@keywords
+\def\HsH@abstract@chap{\addchap*}
+%    \end{macrocode}
+%     Now the actuall option can be defiend to handle all the cases.
+%    \begin{macrocode}
+\DefineFamilyKey{HsH}{abstract}{%
+  \begingroup
+  \FamilySetNumerical{HsH}{abstract}{@tempa}{%
+    {keywords}{0},%
+    {nokeywords}{1},%
+    {totoc}{2},{toc}{2},%
+    {notoc}{3},{nottotoc}{3},%
+  }{#1}
+  \ifx\FamilyKeyState\FamilyKeyStateProcessed
+    \aftergroup\FamilyKeyStateProcessed
+    \ifcase\@tempa% 0
+      \endgroup
+      \@HsH@option@abstract@show@keywordstrue
+    \or% 1
+      \endgroup
+      \@HsH@option@abstract@show@keywordsfalse
+    \or% 2
+      \endgroup
+      \def\HsH@abstract@chap{\addchap}
+    \or% 3
+      \endgroup
+      \def\HsH@abstract@chap{\addchap*}
+    \else% should never be
+      \endgroup
+    \fi
+  \else
+    \endgroup
+  \fi
+}
+%    \end{macrocode}
+%   \end{option}
+%
 %   For the \opt{twoside} option we only redefine the default, everyting else is
 %   handled by the parrent class.
 %    \begin{macrocode}
@@ -769,6 +819,7 @@ http://www.latex-project.org/lppl.txt
 %<*article|report>
   toc=listof,
   toc=bibliography,
+  abstract=keywords,
 %</article|report>
   faculty=none,
 %<*standalone>
@@ -1296,7 +1347,8 @@ http://www.latex-project.org/lppl.txt
 %
 %   \subsubsection{Styling \LaTeX{} default constucts}
 %
-%     \paragraph{Floats}\vspace*{-1\baselineskip}
+%     \vspace{-1\baselineskip}
+%     \paragraph{Floats}\vspace{-1\baselineskip}
 %    \begin{macrocode}
 %<*!standalone>
 %    \end{macrocode}
@@ -1345,6 +1397,25 @@ http://www.latex-project.org/lppl.txt
 \renewcommand{\labelitemiv}{\raisebox{-.1ex}{\scalebox{1.3}{$\cdot$}}}
 %    \end{macrocode}
 %
+%     \paragraph{Abstract}
+%     We define some custom behavior for the abstract.
+%    \begin{macrocode}
+\defcaptionname{german,ngerman}\abstractname{Abstract}
+\newcaptionname{english}\keywordsname{Keywords}
+\newcaptionname{german,ngerman}\keywordsname{Schl{\"u}sselw{\"o}rter}
+\renewenvironment{abstract}{
+  \quotation
+  \setparsizes{\z@}{\z@}{.25\linewidth \@plus 1fil}\selectfont
+  \HsH@abstract@chap{\abstractname}
+}{%
+  \ifx\@keywords\@empty\else\if@HsH@option@abstract@show@keywords
+    \par\bigskip
+    \noindent\textbf{\keywordsname}\hskip 2em\@keywords
+  \fi\fi\par
+  \endquotation
+}
+%    \end{macrocode}
+%
 %     \paragraph{Misc}
 %     We activae one of the commands defined above to make math-indices upright by
 %     default.
diff --git a/src/HsH-classes.pdf b/src/HsH-classes.pdf
index 766e891..62c6ae4 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:fe71a12b048b772016e65a50bd8c0fc733747ae5928542a5d8b35c9bd0baebf9
-size 313062
+oid sha256:7489922caaea27cbd74442ffe49cb6998c4e1d6a43ea1cedde8f00e0f938e1ca
+size 313847
diff --git a/src/HsH-report.cls b/src/HsH-report.cls
index eb222b8..9048096 100644
--- a/src/HsH-report.cls
+++ b/src/HsH-report.cls
@@ -17,7 +17,7 @@
 %% 
 \NeedsTeXFormat{LaTeX2e}[2022-06-01]
 \ProvidesClass{HsH-report}
-  [2024-04-25 3.01 HsH-class based on KOMA]
+  [2024-04-26 3.01 HsH-class based on KOMA]
 \let\HsHClassName\@currname
 \def\HsHClassName@ParrentClass{%
   scrreprt%
@@ -122,6 +122,37 @@
 \AtEndOfClass{%
   \headheight=\HsH@opt@headheight%
 }
+\newif\if@HsH@option@abstract@show@keywords
+\def\HsH@abstract@chap{\addchap*}
+\DefineFamilyKey{HsH}{abstract}{%
+  \begingroup
+  \FamilySetNumerical{HsH}{abstract}{@tempa}{%
+    {keywords}{0},%
+    {nokeywords}{1},%
+    {totoc}{2},{toc}{2},%
+    {notoc}{3},{nottotoc}{3},%
+  }{#1}
+  \ifx\FamilyKeyState\FamilyKeyStateProcessed
+    \aftergroup\FamilyKeyStateProcessed
+    \ifcase\@tempa% 0
+      \endgroup
+      \@HsH@option@abstract@show@keywordstrue
+    \or% 1
+      \endgroup
+      \@HsH@option@abstract@show@keywordsfalse
+    \or% 2
+      \endgroup
+      \def\HsH@abstract@chap{\addchap}
+    \or% 3
+      \endgroup
+      \def\HsH@abstract@chap{\addchap*}
+    \else% should never be
+      \endgroup
+    \fi
+  \else
+    \endgroup
+  \fi
+}
 \DefineFamilyKey{HsH}{twoside}[semi]{%
   \HsH@Options@PassToParrent{twoside=#1,BCOR=1cm}
   \FamilyKeyStateProcessed
@@ -162,6 +193,7 @@
   headheight=2.15\baselineskip,
   toc=listof,
   toc=bibliography,
+  abstract=keywords,
   faculty=none,
 }
 \FamilyProcessOptions{HsH}\relax
@@ -374,6 +406,20 @@
 \renewcommand{\labelitemii}{\raisebox{.3ex}{\scalebox{0.7}{$\circ$}}}
 \renewcommand{\labelitemiii}{\raisebox{.1ex}{-}}
 \renewcommand{\labelitemiv}{\raisebox{-.1ex}{\scalebox{1.3}{$\cdot$}}}
+\defcaptionname{german,ngerman}\abstractname{Abstract}
+\newcaptionname{english}\keywordsname{Keywords}
+\newcaptionname{german,ngerman}\keywordsname{Schl{\"u}sselw{\"o}rter}
+\renewenvironment{abstract}{
+  \quotation
+  \setparsizes{\z@}{\z@}{.25\linewidth \@plus 1fil}\selectfont
+  \HsH@abstract@chap{\abstractname}
+}{%
+  \ifx\@keywords\@empty\else\if@HsH@option@abstract@show@keywords
+    \par\bigskip
+    \noindent\textbf{\keywordsname}\hskip 2em\@keywords
+  \fi\fi\par
+  \endquotation
+}
 \upsubscripts
 \raggedbottom
 \let\layercontentsmeasure\relax
@@ -621,7 +667,7 @@
     \global\let\@lowertitleback\@empty
     \global\let\@dedication\@empty
     \global\let\@matrikelnr\@empty
-    \global\let\@prof\@empty
+    \global\let\@professor\@empty
     \global\let\author\relax
     \global\let\title\relax
     \global\let\extratitle\relax
diff --git a/src/HsH-standalone.cls b/src/HsH-standalone.cls
index 3db593b..f23662b 100644
--- a/src/HsH-standalone.cls
+++ b/src/HsH-standalone.cls
@@ -17,7 +17,7 @@
 %% 
 \NeedsTeXFormat{LaTeX2e}[2022-06-01]
 \ProvidesClass{HsH-standalone}
-  [2024-04-25 3.01 HsH-class based on KOMA]
+  [2024-04-26 3.01 HsH-class based on KOMA]
 \let\HsHClassName\@currname
 \def\HsHClassName@ParrentClass{%
   standalone%
@@ -240,6 +240,20 @@
 \renewcommand{\labelitemii}{\raisebox{.3ex}{\scalebox{0.7}{$\circ$}}}
 \renewcommand{\labelitemiii}{\raisebox{.1ex}{-}}
 \renewcommand{\labelitemiv}{\raisebox{-.1ex}{\scalebox{1.3}{$\cdot$}}}
+\defcaptionname{german,ngerman}\abstractname{Abstract}
+\newcaptionname{english}\keywordsname{Keywords}
+\newcaptionname{german,ngerman}\keywordsname{Schl{\"u}sselw{\"o}rter}
+\renewenvironment{abstract}{
+  \quotation
+  \setparsizes{\z@}{\z@}{.25\linewidth \@plus 1fil}\selectfont
+  \HsH@abstract@chap{\abstractname}
+}{%
+  \ifx\@keywords\@empty\else\if@HsH@option@abstract@show@keywords
+    \par\bigskip
+    \noindent\textbf{\keywordsname}\hskip 2em\@keywords
+  \fi\fi\par
+  \endquotation
+}
 \upsubscripts
 \raggedbottom
 \let\layercontentsmeasure\relax
diff --git a/test.pdf b/test.pdf
index e1ad9a6..3efce7b 100644
--- a/test.pdf
+++ b/test.pdf
@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:697cde1b3d66de24e095f4012517853073de0c96678299349ecf1bd8eaaecbd9
-size 233995
+oid sha256:17bbf4cd7770bfaf405d98c35e4735830d2b0fb2bddfdae14e3498c10b7596b8
+size 239627
diff --git a/test.tex b/test.tex
index cb21113..f728529 100644
--- a/test.tex
+++ b/test.tex
@@ -14,9 +14,8 @@
 \title{long and elaborate title that just goes on and on without stopping}
 \subtitle{Subtitle}
 \date{\today}
-\keywords{test, wow}
+\keywords{test, hello, world}
 
-\defcaptionname{german,ngerman}\abstractname{Abstract}
 
 
 \begin{document}
-- 
GitLab