From fb9d39e846a03ec7611c6ce7952c6de5d409dc4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Sun, 19 Sep 2021 20:32:02 +0200 Subject: [PATCH] more optional arguments for \lecture command The signature is now \lecture[keywords]{date}[number (overwriting the counter)]{title}[margin note] and provides more flexibility --- lecture-notes/mkessler-lectures.sty | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lecture-notes/mkessler-lectures.sty b/lecture-notes/mkessler-lectures.sty index 2313700..f78c677 100644 --- a/lecture-notes/mkessler-lectures.sty +++ b/lecture-notes/mkessler-lectures.sty @@ -61,15 +61,19 @@ %Define the main lecture command to start a new lecture \def\@lectureprefix{\ifenglish Lecture\else Vorlesung\fi} \def\@lecture{}% -\newcommand{\lecture}[3][]{ - \refstepcounter{lecture} + +\RequirePackage{xparse} + +% \lecture[keywords]{date}[number]{title}[margin note] +\NewDocumentCommand{\lecture}{ O{} m O{} m O{}}{ + \ifthenelse{\isempty{#3}}{\refstepcounter{lecture}}{\setcounter{lecture}{#3}} %Store lecture name in the macro \@lecture - \ifthenelse{\isempty{#3}}{% + \ifthenelse{\isempty{#4}}{% \def\@lecture{\@lectureprefix\, \thelecture}% }{% - \def\@lecture{\@lectureprefix\, \thelecture: #3}% + \def\@lecture{\@lectureprefix\, \thelecture: #4}% }% - \marginpar{\small\textsf{\parbox{10em}{\@lectureprefix\, \thelecture \\#2}}} + \marginpar{\small\textsf{\parbox{10em}{\@lectureprefix\, \thelecture \\#2 \ifthenelse{\isempty{#5}}{}{\\#5}}}} %Add lecture as an entry to the lectures file \addcontentsline{lec}{lecture}{\@lectureprefix\,\thelecture\,(#2)} %If key words are provided, add the key words of the lecture below the entry