more optional arguments for \lecture command

The signature is now \lecture[keywords]{date}[number (overwriting
the counter)]{title}[margin note] and provides more flexibility
This commit is contained in:
Maximilian Keßler 2021-09-19 20:32:02 +02:00
parent f5c3b1155a
commit fb9d39e846

View file

@ -61,15 +61,19 @@
%Define the main lecture command to start a new lecture %Define the main lecture command to start a new lecture
\def\@lectureprefix{\ifenglish Lecture\else Vorlesung\fi} \def\@lectureprefix{\ifenglish Lecture\else Vorlesung\fi}
\def\@lecture{}% \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 %Store lecture name in the macro \@lecture
\ifthenelse{\isempty{#3}}{% \ifthenelse{\isempty{#4}}{%
\def\@lecture{\@lectureprefix\, \thelecture}% \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 %Add lecture as an entry to the lectures file
\addcontentsline{lec}{lecture}{\@lectureprefix\,\thelecture\,(#2)} \addcontentsline{lec}{lecture}{\@lectureprefix\,\thelecture\,(#2)}
%If key words are provided, add the key words of the lecture below the entry %If key words are provided, add the key words of the lecture below the entry