summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/mluexercise/mluexercise.dtx
blob: f7ad37f781a321c548bf4d58c08880cbc374ab6a (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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
%\iffalse
%!TEX program  = pdfLaTeX
%<*internal>
\iffalse
%</internal>
%<*license>
MIT License

Copyright (c) 2020 Fachschaftsrat Mathematik/Informatik der Studierendenschaft der Martin-Luther-Universität Halle-Wittenberg K.d.ö.R.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
%</license>
%<*readme>
# The `mluexercise` class

Template class for exercises/homework, maintained by the [Computer Science Student's Council](https://fachschaft.mathinf.uni-halle.de) at [Martin Luther University Halle-Wittenberg](https://uni-halle.de).

## Contact

We are happy to accept pull requests and feature requests on [GitHub](https://github.com/fsrmatheinfo/mluexercise).
Alternatively, you can contact us via email: [fachschaft@mathinf.uni-halle.de](mailto:fachschaft@mathinf.uni-halle.de)

## License

The `mluexercise` LaTeX class is distributed under the [MIT license](https://ctan.org/license/mit).
%</readme>
%<*internal>
\fi
\def\nameofplainTeX{plain}\ifx\fmtname\nameofplainTeX\else\expandafter\begingroup\fi
%</internal>
%<*install>
\input docstrip.tex
\keepsilent
\askforoverwritefalse
\usedir{tex/latex/\jobname}
\generate{
    \file{\jobname.cls}{\from{\jobname.dtx}{class}}
}
%\endbatchfile
%</install>
%<*internal>
\usedir{source/latex/\jobname}
\generate{
    \file{\jobname.ins}{\from{\jobname.dtx}{install}}
}
\nopreamble\nopostamble
\usedir{doc/latex/\jobname}
\generate{
    \file{README.md}{\from{\jobname.dtx}{readme}}
    \file{LICENSE.txt}{\from{\jobname.dtx}{license}}
}
\ifx\fmtname\nameofplainTeX\expandafter\endbatchfile\else\expandafter\endgroup\fi
%</internal>
%<*driver>
\documentclass[a4paper,english]{ltxdoc}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{libertine}
\usepackage{eulervm}
\usepackage[ttdefault]{sourcecodepro}
\usepackage[colorlinks=false]{hyperref}
\usepackage{relsize}
\newcommand{\ttsmallfont}{\ttfamily\smaller}
\renewcommand{\UrlFont}{\ttsmallfont}
\renewcommand{\texttt}[1]{{\ttsmallfont #1}}
\renewcommand{\MacroFont}{\ttfamily\footnotesize}
\usepackage{listings}
\usepackage{csquotes}
\usepackage{booktabs}
\usepackage[sf,bf]{titlesec}
\lstset{
    language=TeX,
    basicstyle=\ttfamily\footnotesize,
    breakatwhitespace=false,
    breaklines=true,
    prebreak={\mbox{\(\hookleftarrow\)}},
    numbers=left,
    numberstyle=\scriptsize,
    numbersep=1pt,
    keepspaces=true,
    tabsize=4,
    xleftmargin=1em,
}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
^^A \OnlyDescription
\begin{document}
    \DocInput{\jobname.dtx}
\end{document}
%</driver>
%<*class>
%\fi
%
%\renewcommand{\filedate}{2020/11/12}
%\renewcommand{\fileversion}{v2.0}
%
%\title{\sffamily\bfseries The \texttt{\jobname} class\footnote{This document describes version \fileversion{}, last revised \filedate{}.}}
%\author{\sffamily %
%    Jan Heinrich Reimer \\
%    Fachschaftsrat Mathematik/Informatik%
%    \footnote{Fachschaftsrat Mathematik/Informatik der Studierendenschaft der Martin-Luther-Universität Halle-Wittenberg K.d.ö.R., Von-Seckendorff-Platz~1, 06120~Halle~ (Saale), Germany} \\
%    \url{https://fachschaft.mathinf.uni-halle.de} \\
%    \texttt{fachschaft@mathinf.uni-halle.de}
%}
%\date{\sffamily Released \filedate{}}
%
%\maketitle
%\tableofcontents
%
%\section{Introduction}
%
%The \texttt{mluexercise} class is a template class for solving weekly exercises at the Institute for Computer Science of Martin Luther University Halle-Wittenberg.\footnote{\url{https://uni-halle.de/}}
%The class can be used by all students---especially first semesters---to typeset their exercises with a low-effort in beautiful \LaTeX{}.
% We include a bunch of handy macros that are used throughout many lectures during the bachelor's degree program.
%
%\changes{v1.0}{2018/10/03}{Initial draft}
%\changes{v2.0}{2020/11/12}{First public release}
%
%\section{Usage}
%
%\DescribeMacro{\documentclass}
%Load the \texttt{mluexercise} class at the start of your preamble.
%
%\iffalse
%<*example>
%\fi
\begin{lstlisting}[gobble=4]
    \documentclass{mluexercise}
\end{lstlisting}
%\iffalse
%</example>
%\fi
%
%\paragraph{Languages}
%
%As in many classes, you can define your main document language.
%This will help \LaTeX{} in hyphenating words and structural texts (e.g.,~sections) are being translated automatically.
%
%\DescribeMacro{english}
%The \texttt{english} option selects English language for texts and hyphenation.
%
%\DescribeMacro{ngerman}
%The \texttt{ngerman} option selects German language (with new spelling) for texts and hyphenation.
%
%While you do not have to specify a language, it is a meaningful information for writers (including yourself) to explicitly state the desired language that should be used consistently throughout the whole document. If no language is specified, English language is used.
%
%\paragraph{Styles}
%
%\DescribeMacro{dataminingstyle}
%The \texttt{dataminingstyle} option may be used for the \textquote{Data Mining} lecture and overwrites some mathematical symbols to match the lecture's definition's.
%
%\subsection{Exercise Metadata}
%
%Define the exercise's metadata and your identity. The below macros should be used only in the preamble, that is before \lstinline|\begin{document}|.
%
%\DescribeMacro{\lecture}
%The \cs{lecture}\marg{name} macro sets the name of the lecture you are writing exercises for.
%
%\DescribeMacro{\semester}
%The semester is automatically set to the current semester. You can overwrite the default value with the \cs{semester}\marg{semester} macro if you are compiling exercises for another semester.
%
%\DescribeMacro{\exercise}
%The \cs{exercise}\marg{number} macro sets the number of the exercise you are working on.
%
%\DescribeMacro{\task}
%The \cs{task}\marg{number} macro sets the number of the first task.
%This is useful if you submit single PDF files for each task within the exercise.
%If you omit this option, numbering starts at~1.
%
%\DescribeMacro{\group}
%Sometimes tutors allow to submit exercises in groups.
%You can use the optional \cs{group}\marg{number} macro to set the group number.
%If no group number is given, the group number is not displayed.
%
%\DescribeMacro{\title}
%The \cs{title}\marg{lecture name} macro is an alias for \cs{lecture}\marg{lecture name}.
%
%\DescribeMacro{\date}
%The date is automatically set to the current date.
%You can overwrite the default value with the \cs{date}\marg{date} macro.
%
%\subsection{Student Metadata}
%
%The following commands should be used to include identification in your exercise in order to assign your work.
%
%\DescribeMacro{\studentname}
%You must define your full name with the \cs{studentname}\marg{full name} macro.
%If you are working in a group, you can enter more names separated with commas and/or line breaks.
%
%\DescribeMacro{\studentnumber}
%The \cs{studentnumber}\marg{matriculation number} macro specifies your student matriculation number (e.g.,~234\,567\,890). This is the same number as on your student ID card.
%
%\DescribeMacro{\studentsymbol}
%The \cs{studentsymbol}\marg{shorthand symbol} macro specifies your shorthand symbol used for university IT services (e.g.,~abcde). This is the same username used for Stud.IP, university mail etc.
%
%Both \cs{studentnumber} an \cs{studentsymbol} are optional.
%Though, most tutors require specifying either student number or symbol.
%
%\paragraph{Multiple Students}
%
%While you can use commas and line breaks in the above macros, we would suggest one of the following two options to submit work in groups with multiple students:
%\begin{itemize}
%    \item Either use the services offered by the university to check-in your group members online~(e.g.,~in the Institute for Computer Science's \textquote{Übungsportal}).
%        In this case you don't need to specify multiple names in the preamble, but just your own name.
%    \item Or, if you cannot specify group members elsewhere, we recommend to add a footnote on the first page. That way you can list all other students but do not waste too much paper.
%\end{itemize}
%
%\subsection{Included Packages}
%
%The \texttt{\jobname} class loads a number of useful \LaTeX{} packages listed in Table~\ref{tab:packages}.
%Those are needed to typeset exercises during the Computer Science bachelor's degree programme at Martin Luther University Halle-Wittenberg.
%We recommend reading the introductions of each package's documentation on CTAN\footnote{\url{https://ctan.org/}}.
%\begin{table}
%    \caption{Packages included in the class.}
%    \label{tab:packages}
%    \begin{tabular}{lll}
%        \toprule
%        \textbf{Package} & \textbf{Purpose} & \textbf{Link} \\
%        \midrule
%        \texttt{babel} & hyphenation, localization & {\smaller\url{https://ctan.org/pkg/babel}} \\
%        \texttt{amsmath} & mathematics & {\smaller\url{https://ctan.org/pkg/amsmath}} \\
%        \texttt{amsthm} & & {\smaller\url{https://ctan.org/pkg/amsthm}} \\
%        \texttt{amssymb} & & {\smaller\url{https://ctan.org/pkg/amssymb}} \\
%        \texttt{amstext} & & {\smaller\url{https://ctan.org/pkg/amstext}} \\
%        \texttt{array} & & {\smaller\url{https://ctan.org/pkg/array}} \\
%        \texttt{cancel} & & {\smaller\url{https://ctan.org/pkg/cancel}} \\
%        \texttt{inputenc} & UTF8 encoding & {\smaller\url{https://ctan.org/pkg/inputenc}} \\
%        \texttt{fontenc} & T1 encoding & {\smaller\url{https://ctan.org/pkg/fontenc}} \\
%        \texttt{booktabs} & tables & {\smaller\url{https://ctan.org/pkg/booktabs}} \\
%        \texttt{graphicx} & images, graphics & {\smaller\url{https://ctan.org/pkg/graphicx}} \\
%        \texttt{xcolor} & color definitions & {\smaller\url{https://ctan.org/pkg/xcolor}} \\
%        \texttt{tikz} & drawing vector graphics & {\smaller\url{https://ctan.org/pkg/tikz}} \\
%        \texttt{pgfplots} & plotting & {\smaller\url{https://ctan.org/pkg/pgfplots}} \\
%        \texttt{algorithm2e} & pseudocode, algorithms & {\smaller\url{https://ctan.org/pkg/algorithm2e}} \\
%        \texttt{listings} & code listings & {\smaller\url{https://ctan.org/pkg/listings}} \\
%        \texttt{listingsutf8} & & {\smaller\url{https://ctan.org/pkg/listingsutf8}} \\
%        \texttt{subcaption} & sub-figures & {\smaller\url{https://ctan.org/pkg/subcaption}} \\
%        \texttt{csquotes} & quotation & {\smaller\url{https://ctan.org/pkg/csquotes}} \\
%        \bottomrule
%    \end{tabular}
%\end{table}
%
%\section{Design Goals}
%
%The \texttt{\jobname} class should:
%
%\begin{itemize}
%    \item be usable for first semester students with rather little LaTeX experience,
%    \item be consistent with Martin Luther University brand guidelines\footnote{\url{https://www.pr.uni-halle.de/download/logo/}}, especially with respect to font families and colors, and
%    \item include packages frequently needed by students.
%\end{itemize}
%
%\section{Implementation}
%
%\subsection{Setup}
%
%We specify the \LaTeX{} version, define and parse options and then load the base class \texttt{scrartcl}\footnote{\url{https://ctan.org/pkg/scrartcl}} with all remaining options.
%
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mluexercise}[2020/11/12 v2.0]
%    \end{macrocode}
%
%\paragraph{Options}
%
%    \begin{macrocode}
\newif\ifdataminingstyle\dataminingstylefalse
\DeclareOption{dataminingstyle}{%
  \dataminingstyletrue
}
%    \end{macrocode}
%
%Process options and load base class with remaining options.
%
%    \begin{macrocode}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{scrartcl}}
\ProcessOptions*
\LoadClass{scrartcl}
%    \end{macrocode}
%
%To enable support for UTF8 and some other useful basics, we load a bunch of packages.
%
%    \begin{macrocode}
\RequirePackage[utf8]{inputenc}
\RequirePackage[T1]{fontenc}
\RequirePackage{ifthen} % Conditional branches and loops.
\RequirePackage{etoolbox} % Hooks for executing code.
\RequirePackage{hyperref} % Hyperlinks.
\RequirePackage{xcolor} % Color definitions.
%    \end{macrocode}
%
%As we'd like to be able to switch between English and German with proper hyphenation, load language support packages.%
%\footnote{If you'd like to add a language, please contact us.}
%
%    \begin{macrocode}
\RequirePackage{babel}
\RequirePackage{iflang}
\newcommand{\IfGerman}[2]{\IfLanguagePatterns{german}{#1}{%
    \IfLanguagePatterns{ngerman}{#1}{#2}}}
%    \end{macrocode}
%
%\subsection{Global Variables}
%
%The class can be configured with the lecture's and student's details. We define global variables for that and redefine some built in \LaTeX{} commands to ease the migration from standard classes.
%
%    \begin{macrocode}
\newcommand{\@checkoption}[3]{%
    \AtEndPreamble{%
        \ifthenelse{\equal{\the#1}{}}{%
            \ClassError{mluexercise}{Missing #2}{%
                Set #2 using the \protect#3 command.%
            }%
        }{}%
    }%
}
\newtoks\@lecture
\newcommand{\lecture}[1]{\global\@lecture{#1}}
\let\title\lecture % Redefine standard \title command.
\@checkoption{\@lecture}{lecture name}{\lecture}
\newtoks\@semester
\newcommand{\semester}[1]{\global\@semester{#1}}
\global\@semester{ % Automatically set semester based on current date.
    \ifnum\month<4 % Winter semester, including previous year.
    WS~{\advance\year by -1 \the\year\advance\year by 1}/\the\year%
    \else\ifnum\month<10 % Summer semester.
    SS~\the\year%
    \else % Winter semester, including next year.
    WS~\the\year/{\advance\year by 1 \the\year\advance\year by -1}%
    \fi\fi%
}
\newtoks\@exercise
\newcommand{\exercise}[1]{\global\@exercise{#1}}
\@checkoption{\@exercise}{exercise number}{\exercise}
\newtoks\@task
\newcommand{\task}[1]{\global\@task{#1}}
\global\@task{1}
\newtoks\@group
\newcommand{\group}[1]{\global\@group{#1}}
\global\@group{0}
\newtoks\@studentname
\newcommand{\studentname}[1]{\global\@studentname{#1}}
\let\author\studentname % Redefine standard \title command.
\@checkoption{\@studentname}{student name}{\studentname}
\newtoks\@studentnumber
\newcommand{\studentnumber}[1]{\global\@studentnumber{#1}}
\newtoks\@studentsymbol
\newcommand{\studentsymbol}[1]{\global\@studentsymbol{#1}}
%    \end{macrocode}
%
%\subsection{Layout, Text}
%
%Set up a reasonable page layout and define text styles that comply with Martin Luther University brand guidelines.
%
%    \begin{macrocode}
\RequirePackage{calc}
\RequirePackage[
    a4paper,
    inner=2cm,
    outer=2cm,
    top=3cm,
    bottom=3cm,
    head=0.75cm,
    headsep=0.25cm,
    foot=0.75cm,
]{geometry}
\renewcommand{\baselinestretch}{1.15}
\setlength{\parindent}{0em} % Disable paragraph indentation.
\setlength{\parskip}{1ex} % Instead enable paragraph margins.
%    \end{macrocode}
%
%\paragraph{Font Families}
%
%We use Libertine as main font as that is the closest free font to the proprietary URW~Classico font used by the university. For mathematics we use the more modern Euler~Maths font and for source code the \emph{true} monospace font Source~Code~Pro, as otherwise copying from the PDF is broken. For clarity reasons we do not want code ligatures.
%
%    \begin{macrocode}
\RequirePackage{libertine}
\RequirePackage{eulervm}
\RequirePackage[ttdefault]{sourcecodepro}
\RequirePackage{microtype}
\DisableLigatures{family=tt*}
%    \end{macrocode}
%
%\paragraph{Text Styles}
%
%    \begin{macrocode}
\newcommand{\strong}[1]{\textbf{#1}}
\newcommand{\italic}[1]{\textit{#1}}
\newcommand{\code}[1]{\texttt{#1}}
% Double underline.
\newcommand{\Underline}[1]{\underline{\underline{#1}}}
% Abbreviated plural ("Lineare Algebra" lecture).
\newcommand{\plural}[1]{\textsuperscript{\underline{#1}}}
\newcommand{\pl}[1]{\plural{#1}}
\RequirePackage[autostyle=true,german=quotes]{csquotes}
%    \end{macrocode}
%
%\paragraph{URL / Link Font}
%
%    \begin{macrocode}
\RequirePackage{relsize}
\newcommand{\ttsmallfont}{\ttfamily\smaller}
\renewcommand{\UrlFont}{\ttsmallfont}
\newcommand{\textttsmall}[1]{{\ttsmallfont #1}}
\newcommand{\query}[1]{{\ttsmallfont #1}}
\newcommand{\domain}[1]{\href{http://#1}{\mbox{\ttsmallfont #1}}}
\newcommand{\email}[1]{\href{mailto:#1}{\mbox{\ttsmallfont #1}}}
%    \end{macrocode}
%
%\paragraph{Headings}
%
%    \begin{macrocode}
\setkomafont{sectioning}{\sffamily\mdseries}
\setkomafont{section}{\LARGE}
\setkomafont{subsection}{\Large}
\setkomafont{subsubsection}{\large}
\setkomafont{paragraph}{\large}
\setkomafont{subparagraph}{\normalsize}
\renewcommand{\thesection}{%
    \bfseries\upshape \IfGerman{Aufgabe}{Task} \arabic{section}}
\renewcommand{\thesubsection}{%
    \bfseries\upshape \alph{subsection})}
\renewcommand{\thesubsubsection}{%
    \upshape (\roman{subsubsection})}
\renewcommand{\autodot}{}
%    \end{macrocode}
%
%\paragraph{Title}
%
%    \begin{macrocode}
\newcommand{\Rom}[1]{\uppercase\expandafter{\romannumeral#1\relax}}
\newcommand{\groupstring}{\ifnum\the\@group>0{, 
    \IfGerman{Gruppe}{Group} \Rom{\the\@group}}\fi}
\author{}
\setkomafont{title}{\sffamily\bfseries\huge\centering}
\setkomafont{date}{\sffamily\large\centering}
\newlength{\approxtitlewidth}
\renewcommand{\maketitle}{%
    \settowidth{\approxtitlewidth}{%
        \usefontofkomafont{title}\the\@lecture}%
    \ifthenelse{\lengthtest{\approxtitlewidth>\textwidth}}{%
        \addtokomafont{title}{\LARGE}}{}%
    \begin{center}%
        \usefontofkomafont{title}\the\@lecture \\
        \usefontofkomafont{date}\@date, \the\@semester\groupstring
    \end{center}
}
%    \end{macrocode}
%
%\paragraph{Head, Foot}
%
%    \begin{macrocode}
\RequirePackage[headsepline,footsepline]{scrlayer-scrpage}
\RequirePackage{totpages}
\pagestyle{scrheadings}
\clearscrheadfoot
\setkomafont{pageheadfoot}{\sffamily}
\setkomafont{pagenumber}{\sffamily}
\ofoot{\thepage~von~\ref{TotPages}}
%    \end{macrocode}
%
%\subsection{Mathematics}
%
%We rely on AMS packages for rendering mathematical equations, proofs, and symbols.
%Additionally we load packages for arrays in math mode and cancellations
%
%    \begin{macrocode}
\RequirePackage{amsmath}
\RequirePackage{amsthm}
\RequirePackage{amssymb}
\RequirePackage{amstext}
\RequirePackage{array}
\RequirePackage{cancel}
%    \end{macrocode}
%
%Now we define (more readable) macros for the mathematical symbols and functions most commonly used at Martin Luther University.
%
%    \begin{macrocode}
\newcommand{\union}{\cup}
\newcommand{\disjunction}{\uplus}
\newcommand{\intersection}{\cap}
\newcommand{\intersect}{\cap}
\newcommand{\infinity}{\infty}
\newcommand{\corresponds}{\triangleq}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand{\C}{\mathbb{C}} % Complex numbers.
\newcommand{\complexnumbers}{\C}
\newcommand{\R}{\mathbb{R}} % Real numbers.
\newcommand{\realnumbers}{\R}
\newcommand{\Q}{\mathbb{Q}} % Rational numbers.
\newcommand{\rationalnumbers}{\Q}
\newcommand{\Z}{\mathbb{Z}} % Whole numbers.
\newcommand{\wholenumbers}{\Z}
\newcommand{\N}{\mathbb{N}} % Natural numbers.
\newcommand{\naturalnumbers}{\N}
\newcommand{\B}{\mathbb{B}} % Binary numbers.
\newcommand{\binarynumbers}{\B}
%    \end{macrocode}
%
%    \begin{macrocode}
% Equivalence transformation
\newcommand{\eqtransform}{\ensuremath{\qquad\big|\,\,}}
% "Ditto" sign
\newcommand{\ditto}{\textquotedbl} \newcommand{\dito}{\ditto}
% End of proof: "quod erat demonstrandum"
\renewcommand{\qed}{\nopagebreak\hfill\ensuremath{\square}}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand{\mland}{\(\land\)} % \land in text.
\newcommand{\mlor}{\(\lor\)} % \lor in text.
%    \end{macrocode}
%
%Many maths symbols can have alternatives for stylistic choices. We enable the variants most liked by our tutors.
%
%    \begin{macrocode}
\let\tmp\mod \let\mod\bmod \let\bmod\tmp
\let\varemptyset\emptyset \let\emptyset\varnothing
\let\tmp\epsilon \let\epsilon\varepsilon \let\varepsilon\tmp
\let\tmp\phi \let\phi\varphi \let\varphi\tmp
%    \end{macrocode}
%
%For some specific lectures we provide more detailed macros for symbols and functions.
%
%\paragraph{Lecture \textquote{Lineare Algebra}}
%
%    \begin{macrocode}
\newcommand{\base}[1]{\mathcal{#1}} % Base (caligraphic)
\DeclareMathOperator{\im}{im} % Image
\DeclareMathOperator{\id}{id} % Identity
\DeclareMathOperator{\sel}{sel} % Selection
\DeclareMathOperator{\dom}{dom} % Domain
\DeclareMathOperator{\ran}{ran} % Range
\DeclareMathOperator{\Hom}{Hom} % Homomorphism
\DeclareMathOperator{\End}{End} % Endomorphism
%    \end{macrocode}
%
%\paragraph{Lecture \textquote{Datenstrukturen und effiziente Algorithmen}}
%
%    \begin{macrocode}
\renewcommand{\O}{\mathcal{O}} % asymptotic O-Notation (Landau)
\DeclareMathOperator{\indeg}{indeg} % Indegree
\DeclareMathOperator{\outdeg}{outdeg} % Outdegree
%    \end{macrocode}
%
%\paragraph{Lecture \textquote{Einführung in Data Science}}
%
%    \begin{macrocode}
\renewcommand{\P}{\ifdataminingstyle p\else\mathbf{P}\fi}
\newcommand{\E}{\ifdataminingstyle\mathbb{E}\else\mathbf{E}\fi}
\DeclareMathOperator{\var}{var}
\DeclareMathOperator{\Var}{Var}
\DeclareMathOperator{\cov}{cov}
\DeclareMathOperator{\Cov}{Cov}
\DeclareMathOperator{\Bin}{Bin}
\DeclareMathOperator{\Exp}{Exp}
\DeclareMathOperator{\Dir}{Dir}
\DeclareMathOperator{\Mult}{Mult}
\newcommand{\Normal}{\mathcal{N}}
\newcommand{\Norm}{\Normal}
%    \end{macrocode}
%
%\paragraph{Table Columns}
%
%The handy \texttt{tabular} column definitions below can be used to typeset a whole column in math mode, to avoid repetetive opening/closing brackets.
%
%    \begin{macrocode}
\newcolumntype{L}{>{\(}l<{\)}}
\newcolumntype{R}{>{\(}r<{\)}}
\newcolumntype{C}{>{\(}c<{\)}}
%    \end{macrocode}
%
%\paragraph{Calculus Environments}
%
%Calculus environments are currently work in progress, subject to change, and may not work as expected.
%However, they can simplify writing logical consequences in the \textquote{Mathematische Grundlagen der Informatik und Konzepte der Modellierung} lecture.
%
%    \begin{macrocode}
\newcounter{calculusRowCount}
\RequirePackage{pgfkeys}
\newenvironment{calculus}[1]{
\pgfkeys{/mlu/calculus/.cd,show index=false,
    context=\Gamma,context command=context,#1}
\setcounter{calculusRowCount}{0}
\newcommand{\calculusSymbol}{\text{
        \sffamily\itshape\pgfkeysvalueof{/mlu/calculus/symbol}}}
\newcommand{\calculusContext}{\ensuremath{
        \pgfkeysvalueof{/mlu/calculus/context}}}
\expandafter\let\csname \pgfkeysvalueof{/mlu/calculus/context command}%
    \endcsname\calculusContext
\par\vspace{0.5em}
\begin{minipage}{\textwidth}\begin{tabular}{
    @{\stepcounter{calculusRowCount}
    (\arabic{calculusRowCount})\hspace{1em}} R
    @{\hspace{0.4em}
    \(
        \vdash_{%
            \ifthenelse{%
                \equal{\pgfkeysvalueof{/mlu/calculus/show index}}{true}
            }{
                \ifthenelse{%
                    \equal{\pgfkeysvalueof{/mlu/calculus/symbol}}{}%
                }{}{%
                    \calculusSymbol%
                }%
            }{%
                \hspace{-0.1em}%
            }%
        }%
    \)\hspace{0.6em}}
        L l
    }
}{
\end{tabular}\end{minipage}\vspace{0.5em}
\let\calculusContext\undefined \let\calculusSymbol\undefined
\expandafter\let\csname \pgfkeysvalueof{/mlu/calculus/context command}%
    \endcsname\undefined
}
\newenvironment{eqcalc}[1][]{\begin{calculus}[
    symbol=E,show index=true,context={\calculusSymbol_{#1}},
    context command=E]}{\end{calculus}} % Equation calculus
\newenvironment{seqcalc}{\begin{calculus}[
    symbol=S,show index=true, context={\calculusSymbol},
    context command=seq]}{\end{calculus}} % Sequence calculus
%    \end{macrocode}
%
%\subsection{Algorithms, Pseudocode}
%\label{sec:implementation-pseudocode}
%
%    \begin{macrocode}
\RequirePackage[vlined,linesnumbered]{algorithm2e}
\DontPrintSemicolon % Hide semicolons.
\SetKwProg{Function}{function}{\ is}{end function}
\SetKwComment{Comment}{\quad\(\triangleright\)~}{} % Comment style.
\SetCommentSty{itshape} % Comment font.
\SetKw{Continue}{continue}
\SetKwBlock{Repeat}{repeat}{}
\SetNlSty{tiny}{}{} % Line number font.
\SetNlSkip{0.5em} % Line number skip.
\SetAlgoNlRelativeSize{0}
\SetAlFnt{\footnotesize}
%    \end{macrocode}
%
%\subsection{Code Listings}
%
%For syntax highlighting and including source code listings, we use the \texttt{listings} package.
%With \texttt{listingsutf8} we can include listings that contain Unicode characters.
%
%    \begin{macrocode}
\RequirePackage{listings}
\RequirePackage{listingsutf8} % UTF8 support in included listings.
%    \end{macrocode}
%
%Define colors for syntax highlighting.
%
%    \begin{macrocode}
\definecolor{lsnumber}{rgb}{0,0,0} % Zeilennummerfarbe
\definecolor{lscomment}{rgb}{0.25,0.5,0.35} % Kommentarfarbe
\definecolor{lskeyword}{rgb}{0.5,0,0.35} % Schlüsselwörterfarbe
\definecolor{lsstring}{rgb}{0.6,0,0} % Zeichenkettenfarbe
%    \end{macrocode}
%
%The default listing style below is enabled automatically and should guarantee consistency with the appearance of pseudocode (see Section~\ref{sec:implementation-pseudocode}).
%
%    \begin{macrocode}
\lstset{
    language=C,
    basicstyle=\ttfamily,
    breakatwhitespace=false,
    breaklines=true,
    prebreak={\mbox{\footnotesize\(\hookleftarrow\)}},
    numbers=left,
    numberstyle=\color{lsnumber}\tiny,
    numbersep=0.5em,
    stepnumber=1,
    commentstyle=\color{lscomment},
    morecomment=[s][\color{lscomment}]{/**}{*/},
    keepspaces=true,
    keywordstyle=\bfseries\color{lskeyword},
    stringstyle=\color{lsstring},
    showtabs=false, showspaces=false,
    showstringspaces=false,
    tabsize=2,
}
%    \end{macrocode}
%
%\paragraph{Haskell Language Definition}
%
%Refine the Haskell language definition and code style for use in the \textquote{Konzepte der Programmierung} lecture.
%
%    \begin{macrocode}
\lstdefinelanguage[Zimmermann]{haskell}[]{haskell}{
    escapeinside={*'}{'*},
    showstringspaces=false,
    morecomment=[l]\%,
    captionpos=b,
    emphstyle={\bfseries},
}
\lstalias[]{zhaskell}[Zimmermann]{haskell}
% Deprecated. Use `language=zhaskell` instead of `style=haskell`.
\lstdefinestyle{haskell}{language=zhaskell}
%    \end{macrocode}
%
%\paragraph{Assembler Language Definition}
%Introduce a new language definition for Prof.~Molitor's Assembler dialect used in \textquote{Einführung in Rechnerarchitektur}.
%
%    \begin{macrocode}
\lstdefinelanguage[Molitor]{Assembler}[x86masm]{Assembler}{
    morekeywords={
        ldd,sto,shl,shr,rol,ror,sub,add,shli,shri,roli,rori,
        subi,addi,or,and,xor,xnor,jmp,beq,bneq,bgt,bo,ldpc,stpc
    },
    comment=[l]{\#},
}
\lstalias[]{massembler}[Molitor]{Assembler}
% Deprecated. Use `language=massembler` instead of `style=massembler`.
\lstdefinestyle{massembler}{language=massembler}
%    \end{macrocode}
%
%\subsection{Graphics, Drawing, Plots}
%
%We add packages for including images and graphics, for drawing vector graphics, and for plotting data or functions.
%
%    \begin{macrocode}
\RequirePackage{booktabs}
\RequirePackage{graphicx}
\RequirePackage{float}
\RequirePackage{subcaption}
\RequirePackage{tikz}
\RequirePackage{pgfplots}
\RequirePackage{rotating}
\usetikzlibrary{positioning}
\usetikzlibrary{automata}
\usetikzlibrary{trees}
\tikzset{
    >=latex,
    font=\sffamily,
}
\pgfplotsset{compat=1.16}
%    \end{macrocode}
%
%\subsection{Document Hooks}
%
%The following \LaTeX{} code should be inserted just before \lstinline|\begin{document}|.
%
%    \begin{macrocode}
\AtEndPreamble{
%    \end{macrocode}
%
%Update exercise and task number as specified in the preamble. (Set first section number to task number.)
%
%    \begin{macrocode}
    \setcounter{section}{\the\@task} \addtocounter{section}{-1}
    \newcommand{\@exercisestring}{\IfGerman{%
        \the\@exercise.~Übungsserie}{Exercise~\the\@exercise}}
%    \end{macrocode}
%
%Set up page head/foot with metadata.
%
%    \begin{macrocode}
    \ihead{\the\@studentname}
    \chead{\textbf{\@exercisestring}}
    \ohead{
        \the\@studentnumber%
        \ifthenelse{\equal{\the\@studentnumber}{} \OR
            \equal{\the\@studentsymbol}{}}{}{\ /\,}%
        \the\@studentsymbol%
    }
%    \end{macrocode}
%
%Set up PDF metadata.
%
%    \begin{macrocode}
    \hypersetup{
        pdfauthor={\the\@studentname},
        pdftitle={\@exercisestring - \the\@lecture}
    }
%    \end{macrocode}
%
%
%    \begin{macrocode}
}
%    \end{macrocode}
%
%\iffalse
%</class>
%\fi
%
%\StopEventually{
%    \PrintChanges
%}
%
%\Finale
\endinput