aboutsummaryrefslogtreecommitdiff
path: root/latex/common.tex
blob: 105902e5aabce4d046320e36253644ca7e67ee5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
\newcommand{\Signatur}{fis}
\newcommand{\Schule}{Gymnasium Riem}
\newcommand{\LogoSchule}{images/logos/gymriem.png}

\newtcolorbox{wiederholung}[1]{colback=orange!5!white,colframe=orange!75!black,fonttitle=\bfseries,title=Wiederholung: #1}

\newcommand\kariert[2][0.5cm]{% 
   \begin{tikzpicture}[gray,step=#1]
     \pgfmathtruncatemacro\anzahl{(\linewidth-\pgflinewidth)/#1} % maximale Anzahl Kästchen pro Zeile
     \draw (0,0) rectangle (\anzahl*#1,#2*#1) (0,0) grid (\anzahl*#1,#2*#1);
   \end{tikzpicture}%
}

\newcommand{\liniert}[2][9mm]{% 
  \begin{tikzpicture}[gray]
  \path[use as bounding box](0,0)rectangle(\linewidth,-#2*#1-0.5\pgflinewidth); 
   \foreach \n in {1,...,#2}\draw(0 ,-#1*\n )--(\linewidth,-#1*\n ); 
  \end{tikzpicture}%
}

% Shortcut for \iftoggle{lehrerversion}
\newcommand{\iflehrer}[2]{\iftoggle{lehrerversion}{#1}{#2}}
% Expands to its argument if the lehrerversion toggle is set
\newcommand{\ifschueler}[1]{\iftoggle{lehrerversion}{}{#1}}

\newcommand{\solution}[1]{\iftoggle{lehrerversion}{#1}{\textcolor{white}{#1}}}
\newcommand{\psolution}[1]{\iftoggle{lehrerversion}{#1}{\phantom{#1}}}

\ifluatex
  \newcommand{\gap}[1]{\underLine{\solution{#1}}}
  \newcommand{\pgap}[1]{\underLine{\psolution{#1}}}
\else
  \newcommand{\gap}[1]{\uline{\solution{#1}}}
  \newcommand{\pgap}[1]{\uline{\psolution{#1}}}
\fi

\newtoggle{betable}

\newcommand{\beTabelle}[1][3cm]{%
\toggletrue{betable}
\ifschueler{%
  \centering
  \begin{tikzpicture}[cell/.style={draw, minimum height=1cm, minimum width=#1}]
    \node [cell] at (1,0) {Aufgabe};
    \node [cell] at (1,-1) {BEs};
    \node [cell] at (1,-2) {$\sum$\hspace{#1*2/3}~};
    \foreach \x [count=\xi] in {1,...,\theAufg}{%
      \node [cell] at ([shift={(1,0)}]\xi*#1,0) {\xi};
      \node [cell] at ([shift={(1,-1)}]\xi*#1,0) {\ref{a:\xi}};
      \node [cell] at ([shift={(1,-2)}]\xi*#1,0) {};
  }
  \end{tikzpicture}%
}
}

% Point distribution across subtasks
\newcommand{\Verteilung}{}

% Input an exercise an specify its version
\newcommand{\inputAufgVersion}[2]{%
  \setcounter{AufgVersion}{#1}%
  \input{#2}%
}

\newcounter{Aufg}
\newcounter{AufgVersion}
\newenvironment{Aufg}[1][]
{
\refstepcounter{Aufg}%
\noindent\textbf{Aufgabe \theAufg\ifstrempty{#1}{}{\ #1}:%
\ifdefempty{\Verteilung}{}{\  \Verteilung{} BE} \hfill \iftoggle{vaguebe}{ca. }{/}\ref{a:\theAufg} \ BE}%
\newline
}{%
  \ifdefempty{\Verteilung}%
    {\setcounter{distSum}{-1}}%
    {\setcounter{distSum}{\fpeval{\Verteilung}}}%
  \renewcommand{\Verteilung}{}% reset the distribution after each exercise
  \global\let\Verteilung\Verteilung%
  \setcounter{AufgVersion}{1}% Reset the exercise version
}

% Total amount of point * 2 in order to track half points in an integer counter
\newcounter{be} % Total amount of points in the document
\newcounter{beA}[Aufg] % Amount of point in the current exercise
\newcounter{beAManuell} % Counter to manually override the points in the current exercise
\setcounter{beAManuell}{-1}

\newcounter{distSum} % Counter to check the sum of the point distribution
\setcounter{distSum}{-1}

\newcommand{\BE}[1]{%
\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{\PointSymbol}{%
\iftoggle{erwartungshorizont}{% Typeset the checkmark only if we are creating a horizon of expectation
  \tikz[scale=0.23, overlay, remember picture] {
    \draw[line width=0.7, line cap=round] (0.25, 1) to [bend left=10] (1,2);
    \draw[line width=0.8, line cap=round] (0, 1.35) to [bend right=1] (0.23,1);
  }
}{}
}

\newcommand{\Point}{%
  \PointSymbol%
  \addtocounter{beA}{2}%
}

\newcommand{\HalfpointSymbol}{%
\iftoggle{erwartungshorizont}{% Typeset the checkmark only if we are creating a horizon of expectation
  \tikz[scale=0.23, overlay, remember picture] {
    \draw[line width=0.7, line cap=round] (0.25, 1) to [bend left=10] (1,2);
    \draw[line width=0.7, line cap=round] (0.5, 1.75) to (0.75,1.25);
    \draw[line width=0.8, line cap=round] (0, 1.35) to [bend right=1] (0.23,1);
  }
}{}
}

\newcommand{\Halfpoint}{%
  \HalfpointSymbol%
  \addtocounter{beA}{1}%
}

\newcommand{\AnzahlInsgesamtPunkte}{\fpeval{\value{be} / 2}}

% Manually override the points
\newcommand{\AnzahlPunkte}[1]{\setcounter{beAManuell}{\fpeval{#1*2}}}

\newenvironment{Lsg}[1][]
{%
\iftoggle{lehrerversion}{%
\noindent\textbf{Lösung:}\ \iftoggle{erwartungshorizont}{#1 \\}{}
}{%
\begin{adjustbox}{max height=0cm, minipage=[0pt]{\textwidth},frame,phantom}
}%
}%
{%end_def
\iftoggle{lehrerversion}{}{\end{adjustbox}\vspace{-0.5\baselineskip}}
% Overwrite the beA counter
\ifnumcomp{\arabic{beAManuell}}{>}{-1}%
{\setcounter{beA}{\value{beAManuell}}}%
{}
\setcounter{beAManuell}{-1}
% Sum up all points
\addtocounter{be}{\value{beA}}
% Persist the current exercise count
\setcounter{beA}{\fpeval{\value{beA} / 2}}%
\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
\ifnumgreater{\thedistSum}{-1}{%
  \ifnumequal{\thedistSum}{\thebeA}{}{%
    \errmessage{Aufg \theAufg: \noexpand\Verteilung (\thedistSum) and point count (\thebeA) are not equal}%
  }%ifnumequal
}{}%ifnumfreater
}

\newtheoremstyle{Bearbeitung}% name of the style to be used
{0pt}% measure of space to leave above the theorem. E.g.: 3pt
{25pt}% 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
{ }% space after theorem head; " " = normal interword space
{\thmname{#1}}

\theoremstyle{Bearbeitung}
\newtheorem{Bearbeitung}{}

% Hide the space to solve the exercise
\newcommand{\Lehrerversion}{\excludecomment{Bearbeitung}}
% Set the lehrerversion toggle to false
\newcommand{\Schuelerversion}{\togglefalse{lehrerversion}}

\iftoggle{lehrerversion}{
  \Lehrerversion%
}{}

% Add new paired delimiter 'abs' using mathtools
\DeclarePairedDelimiter\abs{\lvert}{\rvert}%
% Add new distance notation in mathmode
\newcommand{\dist}[1]{\abs{\overline{#1}}}

% Commands to determine the remaining hsize of a line
% See: https://tex.stackexchange.com/questions/17349/is-there-a-way-to-measure-the-remaining-space-of-a-line-of-text
\newcommand{\currentsidemargin}{%
  \ifodd\value{page}%
    \oddsidemargin%
  \else%
    \evensidemargin%
  \fi%
}

\newlength{\whatsleft}

\newcommand{\measureremainder}[1]{%
\begin{tikzpicture}[overlay,remember picture]
    % Helper nodes
    \path (current page.north west) ++(\hoffset, -\voffset)
        node[anchor=north west, shape=rectangle, inner sep=0, minimum width=\paperwidth, minimum height=\paperheight]
        (pagearea) {};


    \path (pagearea.north west) ++(1in+\currentsidemargin,-1in-\topmargin-\headheight-\headsep)
        node[anchor=north west, shape=rectangle, inner sep=0, minimum width=\textwidth, minimum height=\textheight]
        (textarea) {};

    % Measure distance to right text border
    \path let \p0 = (0,0), \p1 = (textarea.east) in
        [/utils/exec={\pgfmathsetlength#1{\x1-\x0}\global#1=#1}];

\end{tikzpicture}%
}

\newcommand{\ruletoend}[1]{\measureremainder{\whatsleft}\rule{\whatsleft}{#1}}

\newtcolorbox{defbox}[1]{breakable, enhanced, colback=orange!5!white,colframe=orange!75!black,title=#1}

\newtcolorbox{merke}{
  coltitle=white,
  colbacktitle=orange!80!black,
  colback=white,% TODO: support bg from beamer theme
  colframe=orange!80!black,
  enhanced,
  title=\bfseries {\large M}ERKE,
  attach boxed title to top right={yshift=-0.28cm, xshift=-5mm},
  frame code={
    \draw[
      decorate,
      decoration={random steps, segment length=5mm, amplitude=0.6pt},
      draw=orange!80!black,
    ] (frame.north east) rectangle (frame.south west);
  },
}

\newtcolorbox{pseudocode}{
  coltitle=white,
  colbacktitle=gray!30!black,
  colback=white,% TODO: support bg from beamer theme
  colframe=gray!30!black,
  enhanced,
  title=\bfseries {\large P}SEUDOCODE,
  attach boxed title to top right={yshift=-0.28cm, xshift=-5mm},
  frame code={
    \draw[
      decorate,
      decoration={random steps, segment length=5mm, amplitude=0.6pt},
      draw=gray!30!black,
    ] (frame.north east) rectangle (frame.south west);
  },
}


\newcommand{\boldred}[1]{\textcolor{red}{\textbf{#1}}}
\newcommand{\boldgreen}[1]{\textcolor{green!70!black}{\textbf{#1}}}