From afeb87fd80ff85bfb27484afe944f6115ffb8863 Mon Sep 17 00:00:00 2001 From: Jan Wille <jan.wille@stud.hs-hannover.de> Date: Fri, 14 Jun 2024 12:01:04 +0200 Subject: [PATCH] rework `\ifsingleauthor` to avoid it gobbeling up spaces also makes it significantly easier to use. fixes missing spaces in `\declarationofauthorship` --- CHANGELOG.md | 8 ++++++ src/HsH-article.cls | 39 ++++++++++++++-------------- src/HsH-classes.dtx | 58 +++++++++++++++++++++++++++--------------- src/HsH-classes.pdf | 4 +-- src/HsH-report.cls | 39 ++++++++++++++-------------- src/HsH-standalone.cls | 39 ++++++++++++++-------------- test.pdf | 4 +-- test.tex | 3 +++ 8 files changed, 109 insertions(+), 85 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb92ea0..0223257 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file. ## [Current] +### Breaking + +- Changed `\ifsingleauthor` to directly accept two arguments: `\ifsingleauthor{true}{false}` + This makes usage much easyser and ensures that spaces will not be gobbled up. + + Here is a regex to fix existing code: `(?<=\\ifsingleauthor)(\{.*?\})\\else(\{.*?\})\\fi(\\space)?` + which you can replace with `$1$2`. + ## [3.2] ### Fixed diff --git a/src/HsH-article.cls b/src/HsH-article.cls index dcbc0d8..a694c7f 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-26 3.01 HsH-class based on KOMA] + [2024-06-14 3.03.pre0 HsH-class based on KOMA] \let\HsHClassName\@currname \def\HsHClassName@ParrentClass{% scrartcl% @@ -358,15 +358,16 @@ }\par \endgroup } -\newif\ifsingleauthor +\newif\if@singleauthor \AtBeginDocument{ \begingroup \newcount\count@ \count@=\z@ \@for\tmp@:=\@author\do{\advance\count@\@ne} - \ifnum\count@>\@ne\global\singleauthorfalse\else\global\singleauthortrue\fi + \ifnum\count@>\@ne\global\@singleauthorfalse\else\global\@singleauthortrue\fi \endgroup } +\newcommand{\ifsingleauthor}[2]{\if@singleauthor#1\else#2\fi} \def\declarationAuthorship{% \ClassWarning{\HsHClassName}{% Command \string\declarationAuthorship\space is deprecate.\MessageBreak @@ -621,25 +622,23 @@ \newcaptionname{english}\decofauthname{Declaration of Authorship} \newcaptionname{german,ngerman}\decofauthname{Selbstst{\"a}ndigkeitserkl{\"a}rung} \newcaptionname{english}\decofauthtext{% - \ifsingleauthor{I}\else{We}\fi\space hereby certify that the work - \ifsingleauthor{I}\else{we}\fi\space \ifsingleauthor am\else are\fi - submitting is entirely of \ifsingleauthor{my}\else{our}\fi own making - except where otherwise indicated. \ifsingleauthor{I}\else{We}\fi - \ifsingleauthor{am}\else{are}\fi\space aware of regulations concerning - plagiarism, including disciplinary actions that may result from it. Any - use of the works of any other author, in any form, is properly - acknowledged at their point of use. + \ifsingleauthor{I}{We} hereby certify that the work \ifsingleauthor{I}{we} + \ifsingleauthor{am}{are} submitting is entirely of \ifsingleauthor{my}{our} + own making except where otherwise indicated. \ifsingleauthor{I}{We} + \ifsingleauthor{am}{are} aware of regulations concerning plagiarism, + including disciplinary actions that may result from it. Any use of the + works of any other author, in any form, is properly acknowledged at + their point of use. } \newcaptionname{german,ngerman}\decofauthtext{% - Hiermit best{\"a}tige\ifsingleauthor\else{n}\fi - \ifsingleauthor{ich}\else{wir}\fi, dass die folgende Arbeit eigenst{\"a}ndig - von \ifsingleauthor{mir}\else{uns}\fi\space allein erstellt und unter - Ber{\"u}cksichtigung der zur Verf{\"u}gung gestellten Aufgabenstellung sowie - dem Arbeitsmaterial unter Angabe aller verwendeten Quellen erarbeitet wurde. - Die Regelungen und Konsequenzen eines Plagiats, inklusive disziplinarischer - Ma{\ss}nahmen, sind \ifsingleauthor{mir}\else{uns}\fi\space bewusst. - Insbesondere wurden alle Zitate und gedanklichen {\"U}bernahmen als - solche kenntlich gemacht. + Hiermit best{\"a}tige\ifsingleauthor{}{n} \ifsingleauthor{ich}{wir}, + dass die folgende Arbeit eigenst{\"a}ndig von \ifsingleauthor{mir}{uns} + allein erstellt und unter Ber{\"u}cksichtigung der zur Verf{\"u}gung + gestellten Aufgabenstellung sowie dem Arbeitsmaterial unter Angabe aller + verwendeten Quellen erarbeitet wurde. Die Regelungen und Konsequenzen + eines Plagiats, inklusive disziplinarischer Ma{\ss}nahmen, sind + \ifsingleauthor{mir}{uns} bewusst. Insbesondere wurden alle Zitate und + gedanklichen {\"U}bernahmen als solche kenntlich gemacht. } \newcaptionname{english}\keywordsname{Keywords} \newcaptionname{german,ngerman}\keywordsname{Schl{\"u}sselw{\"o}rter} diff --git a/src/HsH-classes.dtx b/src/HsH-classes.dtx index 2359eb9..6d1a34e 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-05-02 3.02 HsH-class based on KOMA] + [2024-06-14 3.03.pre0 HsH-class based on KOMA] %</article|report|standalone> %<*driver> ^^A ---------- documentation driver ----------------------------------------- \documentclass{ltxdoc} @@ -395,6 +395,16 @@ http://www.latex-project.org/lppl.txt % |\maketitle|\oarg{align}. You can pass \opt{l\OR c\OR r} to get \emph{left}, % \emph{center} or \emph{right} alignment. % +% \subsection{Micalanious commands} +% The following commands are mostly for internal use, but are parte of the interface +% and might be usefull in some cases. +% \medskip +% +% \DescribeMacro{\ifsingleauthor} +% This allows you to check if |\author| holds one or multiple entries. Using this +% allows the user to display differernt things for these cases, for example switch +% words to pural, like this: +% |\ifsingleauthor{one}{multiple} person\ifsingleauthor{}{s}| % %\section{Package laoding} % The classes load some packges for internal use as well as loading and configuring @@ -1269,23 +1279,31 @@ http://www.latex-project.org/lppl.txt % \end{macrocode} % \end{macro} % -% \begin{macro}{\ifsingleauthor} +% \begin{macro}{\if@singleauthor} % To ensure |\decofauthtext| is preperly spelled for one or multiple authors, we % define a conditional that holds this information. Additionally we check the % number of authors |\AtBeginDocument| and store it. % \begin{macrocode} -\newif\ifsingleauthor +\newif\if@singleauthor \AtBeginDocument{ \begingroup \newcount\count@ \count@=\z@ \@for\tmp@:=\@author\do{\advance\count@\@ne} - \ifnum\count@>\@ne\global\singleauthorfalse\else\global\singleauthortrue\fi + \ifnum\count@>\@ne\global\@singleauthorfalse\else\global\@singleauthortrue\fi \endgroup } % \end{macrocode} % \end{macro} % +% \begin{macro}{\ifsingleauthor} +% A macro to simply act on this condition is also provided. It will be used in +% text-definitions later on. +% \begin{macrocode} +\newcommand{\ifsingleauthor}[2]{\if@singleauthor#1\else#2\fi} +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\declarationAuthorship} % \begin{macrocode} \def\declarationAuthorship{% @@ -1820,25 +1838,23 @@ http://www.latex-project.org/lppl.txt % Define the german translations for the command. % \begin{macrocode} \newcaptionname{english}\decofauthtext{% - \ifsingleauthor{I}\else{We}\fi\space hereby certify that the work - \ifsingleauthor{I}\else{we}\fi\space \ifsingleauthor am\else are\fi - submitting is entirely of \ifsingleauthor{my}\else{our}\fi own making - except where otherwise indicated. \ifsingleauthor{I}\else{We}\fi - \ifsingleauthor{am}\else{are}\fi\space aware of regulations concerning - plagiarism, including disciplinary actions that may result from it. Any - use of the works of any other author, in any form, is properly - acknowledged at their point of use. + \ifsingleauthor{I}{We} hereby certify that the work \ifsingleauthor{I}{we} + \ifsingleauthor{am}{are} submitting is entirely of \ifsingleauthor{my}{our} + own making except where otherwise indicated. \ifsingleauthor{I}{We} + \ifsingleauthor{am}{are} aware of regulations concerning plagiarism, + including disciplinary actions that may result from it. Any use of the + works of any other author, in any form, is properly acknowledged at + their point of use. } \newcaptionname{german,ngerman}\decofauthtext{% - Hiermit best{\"a}tige\ifsingleauthor\else{n}\fi - \ifsingleauthor{ich}\else{wir}\fi, dass die folgende Arbeit eigenst{\"a}ndig - von \ifsingleauthor{mir}\else{uns}\fi\space allein erstellt und unter - Ber{\"u}cksichtigung der zur Verf{\"u}gung gestellten Aufgabenstellung sowie - dem Arbeitsmaterial unter Angabe aller verwendeten Quellen erarbeitet wurde. - Die Regelungen und Konsequenzen eines Plagiats, inklusive disziplinarischer - Ma{\ss}nahmen, sind \ifsingleauthor{mir}\else{uns}\fi\space bewusst. - Insbesondere wurden alle Zitate und gedanklichen {\"U}bernahmen als - solche kenntlich gemacht. + Hiermit best{\"a}tige\ifsingleauthor{}{n} \ifsingleauthor{ich}{wir}, + dass die folgende Arbeit eigenst{\"a}ndig von \ifsingleauthor{mir}{uns} + allein erstellt und unter Ber{\"u}cksichtigung der zur Verf{\"u}gung + gestellten Aufgabenstellung sowie dem Arbeitsmaterial unter Angabe aller + verwendeten Quellen erarbeitet wurde. Die Regelungen und Konsequenzen + eines Plagiats, inklusive disziplinarischer Ma{\ss}nahmen, sind + \ifsingleauthor{mir}{uns} bewusst. Insbesondere wurden alle Zitate und + gedanklichen {\"U}bernahmen als solche kenntlich gemacht. } % \end{macrocode} % \end{macro} diff --git a/src/HsH-classes.pdf b/src/HsH-classes.pdf index e838e9f..01b6cce 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:fb61ed5a06123e4c93a0d6e2cc52c0db4cb3bacbf4ac7dcd32ec0f789a613b68 -size 312304 +oid sha256:46d26e61a39a7109757c570977c1019156b479faab5ad405ca842a0b4d455fff +size 313899 diff --git a/src/HsH-report.cls b/src/HsH-report.cls index 9e54599..82b5dc4 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-26 3.01 HsH-class based on KOMA] + [2024-06-14 3.03.pre0 HsH-class based on KOMA] \let\HsHClassName\@currname \def\HsHClassName@ParrentClass{% scrreprt% @@ -371,15 +371,16 @@ }\par \endgroup } -\newif\ifsingleauthor +\newif\if@singleauthor \AtBeginDocument{ \begingroup \newcount\count@ \count@=\z@ \@for\tmp@:=\@author\do{\advance\count@\@ne} - \ifnum\count@>\@ne\global\singleauthorfalse\else\global\singleauthortrue\fi + \ifnum\count@>\@ne\global\@singleauthorfalse\else\global\@singleauthortrue\fi \endgroup } +\newcommand{\ifsingleauthor}[2]{\if@singleauthor#1\else#2\fi} \def\declarationAuthorship{% \ClassWarning{\HsHClassName}{% Command \string\declarationAuthorship\space is deprecate.\MessageBreak @@ -691,25 +692,23 @@ \newcaptionname{english}\decofauthname{Declaration of Authorship} \newcaptionname{german,ngerman}\decofauthname{Selbstst{\"a}ndigkeitserkl{\"a}rung} \newcaptionname{english}\decofauthtext{% - \ifsingleauthor{I}\else{We}\fi\space hereby certify that the work - \ifsingleauthor{I}\else{we}\fi\space \ifsingleauthor am\else are\fi - submitting is entirely of \ifsingleauthor{my}\else{our}\fi own making - except where otherwise indicated. \ifsingleauthor{I}\else{We}\fi - \ifsingleauthor{am}\else{are}\fi\space aware of regulations concerning - plagiarism, including disciplinary actions that may result from it. Any - use of the works of any other author, in any form, is properly - acknowledged at their point of use. + \ifsingleauthor{I}{We} hereby certify that the work \ifsingleauthor{I}{we} + \ifsingleauthor{am}{are} submitting is entirely of \ifsingleauthor{my}{our} + own making except where otherwise indicated. \ifsingleauthor{I}{We} + \ifsingleauthor{am}{are} aware of regulations concerning plagiarism, + including disciplinary actions that may result from it. Any use of the + works of any other author, in any form, is properly acknowledged at + their point of use. } \newcaptionname{german,ngerman}\decofauthtext{% - Hiermit best{\"a}tige\ifsingleauthor\else{n}\fi - \ifsingleauthor{ich}\else{wir}\fi, dass die folgende Arbeit eigenst{\"a}ndig - von \ifsingleauthor{mir}\else{uns}\fi\space allein erstellt und unter - Ber{\"u}cksichtigung der zur Verf{\"u}gung gestellten Aufgabenstellung sowie - dem Arbeitsmaterial unter Angabe aller verwendeten Quellen erarbeitet wurde. - Die Regelungen und Konsequenzen eines Plagiats, inklusive disziplinarischer - Ma{\ss}nahmen, sind \ifsingleauthor{mir}\else{uns}\fi\space bewusst. - Insbesondere wurden alle Zitate und gedanklichen {\"U}bernahmen als - solche kenntlich gemacht. + Hiermit best{\"a}tige\ifsingleauthor{}{n} \ifsingleauthor{ich}{wir}, + dass die folgende Arbeit eigenst{\"a}ndig von \ifsingleauthor{mir}{uns} + allein erstellt und unter Ber{\"u}cksichtigung der zur Verf{\"u}gung + gestellten Aufgabenstellung sowie dem Arbeitsmaterial unter Angabe aller + verwendeten Quellen erarbeitet wurde. Die Regelungen und Konsequenzen + eines Plagiats, inklusive disziplinarischer Ma{\ss}nahmen, sind + \ifsingleauthor{mir}{uns} bewusst. Insbesondere wurden alle Zitate und + gedanklichen {\"U}bernahmen als solche kenntlich gemacht. } \newcaptionname{english}\keywordsname{Keywords} \newcaptionname{german,ngerman}\keywordsname{Schl{\"u}sselw{\"o}rter} diff --git a/src/HsH-standalone.cls b/src/HsH-standalone.cls index d7b88ee..b2a0019 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-26 3.01 HsH-class based on KOMA] + [2024-06-14 3.03.pre0 HsH-class based on KOMA] \let\HsHClassName\@currname \def\HsHClassName@ParrentClass{% standalone% @@ -194,15 +194,16 @@ }\par \endgroup } -\newif\ifsingleauthor +\newif\if@singleauthor \AtBeginDocument{ \begingroup \newcount\count@ \count@=\z@ \@for\tmp@:=\@author\do{\advance\count@\@ne} - \ifnum\count@>\@ne\global\singleauthorfalse\else\global\singleauthortrue\fi + \ifnum\count@>\@ne\global\@singleauthorfalse\else\global\@singleauthortrue\fi \endgroup } +\newcommand{\ifsingleauthor}[2]{\if@singleauthor#1\else#2\fi} \def\declarationAuthorship{% \ClassWarning{\HsHClassName}{% Command \string\declarationAuthorship\space is deprecate.\MessageBreak @@ -243,25 +244,23 @@ \newcaptionname{english}\decofauthname{Declaration of Authorship} \newcaptionname{german,ngerman}\decofauthname{Selbstst{\"a}ndigkeitserkl{\"a}rung} \newcaptionname{english}\decofauthtext{% - \ifsingleauthor{I}\else{We}\fi\space hereby certify that the work - \ifsingleauthor{I}\else{we}\fi\space \ifsingleauthor am\else are\fi - submitting is entirely of \ifsingleauthor{my}\else{our}\fi own making - except where otherwise indicated. \ifsingleauthor{I}\else{We}\fi - \ifsingleauthor{am}\else{are}\fi\space aware of regulations concerning - plagiarism, including disciplinary actions that may result from it. Any - use of the works of any other author, in any form, is properly - acknowledged at their point of use. + \ifsingleauthor{I}{We} hereby certify that the work \ifsingleauthor{I}{we} + \ifsingleauthor{am}{are} submitting is entirely of \ifsingleauthor{my}{our} + own making except where otherwise indicated. \ifsingleauthor{I}{We} + \ifsingleauthor{am}{are} aware of regulations concerning plagiarism, + including disciplinary actions that may result from it. Any use of the + works of any other author, in any form, is properly acknowledged at + their point of use. } \newcaptionname{german,ngerman}\decofauthtext{% - Hiermit best{\"a}tige\ifsingleauthor\else{n}\fi - \ifsingleauthor{ich}\else{wir}\fi, dass die folgende Arbeit eigenst{\"a}ndig - von \ifsingleauthor{mir}\else{uns}\fi\space allein erstellt und unter - Ber{\"u}cksichtigung der zur Verf{\"u}gung gestellten Aufgabenstellung sowie - dem Arbeitsmaterial unter Angabe aller verwendeten Quellen erarbeitet wurde. - Die Regelungen und Konsequenzen eines Plagiats, inklusive disziplinarischer - Ma{\ss}nahmen, sind \ifsingleauthor{mir}\else{uns}\fi\space bewusst. - Insbesondere wurden alle Zitate und gedanklichen {\"U}bernahmen als - solche kenntlich gemacht. + Hiermit best{\"a}tige\ifsingleauthor{}{n} \ifsingleauthor{ich}{wir}, + dass die folgende Arbeit eigenst{\"a}ndig von \ifsingleauthor{mir}{uns} + allein erstellt und unter Ber{\"u}cksichtigung der zur Verf{\"u}gung + gestellten Aufgabenstellung sowie dem Arbeitsmaterial unter Angabe aller + verwendeten Quellen erarbeitet wurde. Die Regelungen und Konsequenzen + eines Plagiats, inklusive disziplinarischer Ma{\ss}nahmen, sind + \ifsingleauthor{mir}{uns} bewusst. Insbesondere wurden alle Zitate und + gedanklichen {\"U}bernahmen als solche kenntlich gemacht. } \newcaptionname{english}\keywordsname{Keywords} \newcaptionname{german,ngerman}\keywordsname{Schl{\"u}sselw{\"o}rter} diff --git a/test.pdf b/test.pdf index a115d65..57c05de 100644 --- a/test.pdf +++ b/test.pdf @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fda71a675427ab94927a6d89d295f3b24ef41c2196653f1d63e903304b616962 -size 238691 +oid sha256:9b6b7de03c45c0bbfb574163244db23a16043865028914163b61f57542abb078 +size 239184 diff --git a/test.tex b/test.tex index 9d2cc06..e1e9850 100644 --- a/test.tex +++ b/test.tex @@ -37,6 +37,9 @@ Hällo\todo{drop the Ä?} "Welt", ist daß nicht schön? $3.1$ oder $3,2$ + This paper was written by \ifsingleauthor{one}{many} person\ifsingleauthor{}{s}. + Isn't it great that \ifsingleauthor{he}{they} did that? + \begin{equation} A_1 = \sum_{i=0}^{10} B_i + \abs{\frac{x}{2}} \end{equation} -- GitLab