aboutsummaryrefslogtreecommitdiff
path: root/latex/common.tex
blob: 36e7e22dfc955ef35ccacf68fa96e2a4f531aa20 (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
\newcommand{\Signatur}{fis}
\newcommand{\Schule}{Gymnasium Münchberg}
\newcommand{\LogoSchule}{images/logos/gymMuenchberg.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][0.5cm]{% 
  \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}
}

\newcommand{\iflehrer}[2]{\iftoggle{lehrerversion}{#1}{#2}}

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

\newcommand{\gap}[1]{\underLine{\solution{#1}}}
\newcommand{\pgap}[1]{\underLine{\psolution{#1}}}

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

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

\newcounter{Aufg}
\newenvironment{Aufg}[1][]{
\refstepcounter{Aufg}%
\noindent\textbf{Aufgabe \theAufg\ifstrempty{#1}{}{\ #1}:%
\ifdefempty{\Verteilung}{}{\  \Verteilung{} BE} \hfill {/}\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%
}

% 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{\AnzahlInsgesamtPunkte}{\fpeval{\value{be} / 2}}

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

\newenvironment{Lsg}
{
\iftoggle{lehrerversion}{
\noindent\textbf{Lösung:}\newline
}{
\begin{adjustbox}{max height=0cm, minipage=[0pt]{\textwidth},frame,phantom}
}
}
{%end_def
\iftoggle{lehrerversion}{}{\end{adjustbox}\vspace{-0.5\baselineskip}}
% Overwrite the beA counter
\ifthenelse{\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}{}

\newcommand{\Lehrerversion}{\excludecomment{Bearbeitung}}
\newcommand{\Schuelerversion}{\togglefalse{lehrerversion}}

\iftoggle{lehrerversion}{
  \Lehrerversion
}{
}

% Add new paired delimiter 'abs' using mathtools
\DeclarePairedDelimiter\abs{\lvert}{\rvert}%

\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}