aboutsummaryrefslogtreecommitdiff
path: root/latex/common.tex
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2023-08-01 14:59:56 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2023-08-01 14:59:56 +0200
commit56c60918d71a2e4e8ee558fd0d1fcd77ad3bdac9 (patch)
tree51e111ae1e13c56fb414ecf106f5e0e047a6c424 /latex/common.tex
parent008cb1ac27362595db832ab5b2386d0d8dd2a814 (diff)
downloadunterricht-56c60918d71a2e4e8ee558fd0d1fcd77ad3bdac9.tar.gz
unterricht-56c60918d71a2e4e8ee558fd0d1fcd77ad3bdac9.zip
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.
Diffstat (limited to 'latex/common.tex')
-rw-r--r--latex/common.tex32
1 files changed, 15 insertions, 17 deletions
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
}