From 56c60918d71a2e4e8ee558fd0d1fcd77ad3bdac9 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Tue, 1 Aug 2023 14:59:56 +0200 Subject: rework Aufg environment Define the Aufg environment using newenvironment allows us to reset the Verteilung macro after each exercise. Otherwise if an exercise has does nor redefine the Verteilung as empty it will be printed with a stale point distribution from a previous exercise. --- latex/common.tex | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'latex/common.tex') diff --git a/latex/common.tex b/latex/common.tex index f64f3e6c..87ede1c4 100644 --- a/latex/common.tex +++ b/latex/common.tex @@ -25,18 +25,19 @@ \newcommand{\gap}[1]{\underLine{\solution{#1}}} -\newtheoremstyle{Aufg}% name of the style to be used -{2pt}% measure of space to leave above the theorem. E.g.: 3pt -{}% measure of space to leave below the theorem. E.g.: 3pt -{}% name of font to use in the body of the theorem -{}% measure of space to indent -{}% name of head font -{}% punctuation between head and body -{\newline }% space after theorem head; " " = normal interword space -{\textbf{\thmname{#1} \thmnumber{#2}\thmnote{ (#3)}\ifdefined\Verteilung{}: \ \Verteilung \hfill {/}\ref{a:\thmnumber{#2}} \ BE\fi}} +% Point distribution across subtasks +\newcommand{\Verteilung}{} -\theoremstyle{Aufg} -\newtheorem{Aufg}{Aufgabe} +\newcounter{Aufg} +\newenvironment{Aufg}[1][]{ +\refstepcounter{Aufg}% +\noindent\textbf{Aufgabe \theAufg\ifstrempty{#1}{}{\ #1}:% +\ifdefempty{\Verteilung}{}{\ \Verteilung} \hfill {/}\ref{a:\theAufg} \ BE}% +\newline +}{% +\renewcommand{\Verteilung}{}% reset the distribution after each exercise +\global\let\Verteilung\Verteilung% +} % Total amount of point * 2 in order to track half points in an integer counter \newcounter{be} % Total amount of points in the document @@ -45,15 +46,12 @@ \setcounter{beAManuell}{-1} \newcommand{\BE}[1]{% -\iftoggle{erwartungshorizont}{% Typeset the points only if we are creating a horzon of expectation +\iftoggle{erwartungshorizont}{% Typeset the points only if we are creating a horizon of expectation #1 BE}{}% TODO: better typesetting \addtocounter{beA}{\fpeval{#1*2}}} \newcommand{\AnzahlInsgesamtPunkte}{\fpeval{\value{be} / 2}} -% Point distribution across subtasks -\newcommand{\Verteilung}{} - % Manually override the points \newcommand{\AnzahlPunkte}[1]{\setcounter{beAManuell}{\fpeval{#1*2}}} @@ -67,7 +65,7 @@ } } {%end_def -\iftoggle{lehrerversion}{}{\end{adjustbox}\vspace{-\baselineskip}} +\iftoggle{lehrerversion}{}{\end{adjustbox}\vspace{-0.5\baselineskip}} % Overwrite the beA counter \ifthenelse{\arabic{beAManuell} > -1}% {\setcounter{beA}{\value{beAManuell}}}% @@ -77,7 +75,7 @@ \addtocounter{be}{\value{beA}} % Persist the current exercise count \setcounter{beA}{\fpeval{\value{beA} / 2}}% -\addtocounter{beA}{-1}% decrement beA count because refstepcount will increment it +\addtocounter{beA}{-1}% decrement beA count because refstepcounter will increment it \refstepcounter{beA}% make the beA available for the ref and label mechanisms \expandafter\label{a:\theAufg}% create a label for this exercise } -- cgit v1.2.3