| 1 |
%\iffalse |
| 2 |
%!TEX program = pdfLaTeX |
| 3 |
%<*internal> |
| 4 |
\iffalse |
| 5 |
%</internal> |
| 6 |
%<*license> |
| 7 |
MIT License |
| 8 |
|
| 9 |
Copyright (c) 2020 Fachschaftsrat Mathematik/Informatik der Studierendenschaft der Martin-Luther-Universität Halle-Wittenberg K.d.ö.R. |
| 10 |
|
| 11 |
Permission is hereby granted, free of charge, to any person obtaining a copy |
| 12 |
of this software and associated documentation files (the "Software"), to deal |
| 13 |
in the Software without restriction, including without limitation the rights |
| 14 |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 15 |
copies of the Software, and to permit persons to whom the Software is |
| 16 |
furnished to do so, subject to the following conditions: |
| 17 |
|
| 18 |
The above copyright notice and this permission notice shall be included in all |
| 19 |
copies or substantial portions of the Software. |
| 20 |
|
| 21 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 22 |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 23 |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 24 |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 25 |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 26 |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 27 |
SOFTWARE. |
| 28 |
%</license> |
| 29 |
%<*readme> |
| 30 |
# The `mluexercise` class |
| 31 |
|
| 32 |
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). |
| 33 |
|
| 34 |
## Contact |
| 35 |
|
| 36 |
We are happy to accept pull requests and feature requests on [GitHub](https://github.com/fsrmatheinfo/mluexercise). |
| 37 |
Alternatively, you can contact us via email: [[email protected]](mailto:[email protected]) |
| 38 |
|
| 39 |
## License |
| 40 |
|
| 41 |
The `mluexercise` LaTeX class is distributed under the [MIT license](https://ctan.org/license/mit). |
| 42 |
%</readme> |
| 43 |
%<*internal> |
| 44 |
\fi |
| 45 |
\def\nameofplainTeX{plain}\ifx\fmtname\nameofplainTeX\else\expandafter\begingroup\fi |
| 46 |
%</internal> |
| 47 |
%<*install> |
| 48 |
\input docstrip.tex |
| 49 |
\keepsilent |
| 50 |
\askforoverwritefalse |
| 51 |
\usedir{tex/latex/\jobname} |
| 52 |
\generate{ |
| 53 |
\file{\jobname.cls}{\from{\jobname.dtx}{class}} |
| 54 |
} |
| 55 |
%\endbatchfile |
| 56 |
%</install> |
| 57 |
%<*internal> |
| 58 |
\usedir{source/latex/\jobname} |
| 59 |
\generate{ |
| 60 |
\file{\jobname.ins}{\from{\jobname.dtx}{install}} |
| 61 |
} |
| 62 |
\nopreamble\nopostamble |
| 63 |
\usedir{doc/latex/\jobname} |
| 64 |
\generate{ |
| 65 |
\file{README.md}{\from{\jobname.dtx}{readme}} |
| 66 |
\file{LICENSE.txt}{\from{\jobname.dtx}{license}} |
| 67 |
} |
| 68 |
\ifx\fmtname\nameofplainTeX\expandafter\endbatchfile\else\expandafter\endgroup\fi |
| 69 |
%</internal> |
| 70 |
%<*driver> |
| 71 |
\documentclass[a4paper,english]{ltxdoc} |
| 72 |
\usepackage[utf8]{inputenc} |
| 73 |
\usepackage[T1]{fontenc} |
| 74 |
\usepackage{babel} |
| 75 |
\usepackage{libertine} |
| 76 |
\usepackage{eulervm} |
| 77 |
\usepackage[ttdefault]{sourcecodepro} |
| 78 |
\usepackage[colorlinks=false]{hyperref} |
| 79 |
\usepackage{relsize} |
| 80 |
\newcommand{\ttsmallfont}{\ttfamily\smaller} |
| 81 |
\renewcommand{\UrlFont}{\ttsmallfont} |
| 82 |
\renewcommand{\texttt}[1]{{\ttsmallfont #1}} |
| 83 |
\renewcommand{\MacroFont}{\ttfamily\footnotesize} |
| 84 |
\usepackage{listings} |
| 85 |
\usepackage{csquotes} |
| 86 |
\usepackage{booktabs} |
| 87 |
\usepackage[sf,bf]{titlesec} |
| 88 |
\lstset{ |
| 89 |
language=TeX, |
| 90 |
basicstyle=\ttfamily\footnotesize, |
| 91 |
breakatwhitespace=false, |
| 92 |
breaklines=true, |
| 93 |
prebreak={\mbox{\(\hookleftarrow\)}}, |
| 94 |
numbers=left, |
| 95 |
numberstyle=\scriptsize, |
| 96 |
numbersep=1pt, |
| 97 |
keepspaces=true, |
| 98 |
tabsize=4, |
| 99 |
xleftmargin=1em, |
| 100 |
} |
| 101 |
\EnableCrossrefs |
| 102 |
\CodelineIndex |
| 103 |
\RecordChanges |
| 104 |
^^A \OnlyDescription |
| 105 |
\begin{document} |
| 106 |
\DocInput{\jobname.dtx} |
| 107 |
\end{document} |
| 108 |
%</driver> |
| 109 |
%<*class> |
| 110 |
%\fi |
| 111 |
% |
| 112 |
%\renewcommand{\filedate}{2020/11/12} |
| 113 |
%\renewcommand{\fileversion}{v2.0} |
| 114 |
% |
| 115 |
%\title{\sffamily\bfseries The \texttt{\jobname} class\footnote{This document describes version \fileversion{}, last revised \filedate{}.}} |
| 116 |
%\author{\sffamily % |
| 117 |
% Jan Heinrich Reimer \\ |
| 118 |
% Fachschaftsrat Mathematik/Informatik% |
| 119 |
% \footnote{Fachschaftsrat Mathematik/Informatik der Studierendenschaft der Martin-Luther-Universität Halle-Wittenberg K.d.ö.R., Von-Seckendorff-Platz~1, 06120~Halle~ (Saale), Germany} \\ |
| 120 |
% \url{https://fachschaft.mathinf.uni-halle.de} \\ |
| 121 |
% \texttt{[email protected]} |
| 122 |
%} |
| 123 |
%\date{\sffamily Released \filedate{}} |
| 124 |
% |
| 125 |
%\maketitle |
| 126 |
%\tableofcontents |
| 127 |
% |
| 128 |
%\section{Introduction} |
| 129 |
% |
| 130 |
%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/}} |
| 131 |
%The class can be used by all students---especially first semesters---to typeset their exercises with a low-effort in beautiful \LaTeX{}. |
| 132 |
% We include a bunch of handy macros that are used throughout many lectures during the bachelor's degree program. |
| 133 |
% |
| 134 |
%\changes{v1.0}{2018/10/03}{Initial draft} |
| 135 |
%\changes{v2.0}{2020/11/12}{First public release} |
| 136 |
% |
| 137 |
%\section{Usage} |
| 138 |
% |
| 139 |
%\DescribeMacro{\documentclass} |
| 140 |
%Load the \texttt{mluexercise} class at the start of your preamble. |
| 141 |
% |
| 142 |
%\iffalse |
| 143 |
%<*example> |
| 144 |
%\fi |
| 145 |
\begin{lstlisting}[gobble=4] |
| 146 |
\documentclass{mluexercise} |
| 147 |
\end{lstlisting} |
| 148 |
%\iffalse |
| 149 |
%</example> |
| 150 |
%\fi |
| 151 |
% |
| 152 |
%\paragraph{Languages} |
| 153 |
% |
| 154 |
%As in many classes, you can define your main document language. |
| 155 |
%This will help \LaTeX{} in hyphenating words and structural texts (e.g.,~sections) are being translated automatically. |
| 156 |
% |
| 157 |
%\DescribeMacro{english} |
| 158 |
%The \texttt{english} option selects English language for texts and hyphenation. |
| 159 |
% |
| 160 |
%\DescribeMacro{ngerman} |
| 161 |
%The \texttt{ngerman} option selects German language (with new spelling) for texts and hyphenation. |
| 162 |
% |
| 163 |
%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. |
| 164 |
% |
| 165 |
%\paragraph{Styles} |
| 166 |
% |
| 167 |
%\DescribeMacro{dataminingstyle} |
| 168 |
%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. |
| 169 |
% |
| 170 |
%\subsection{Exercise Metadata} |
| 171 |
% |
| 172 |
%Define the exercise's metadata and your identity. The below macros should be used only in the preamble, that is before \lstinline|\begin{document}|. |
| 173 |
% |
| 174 |
%\DescribeMacro{\lecture} |
| 175 |
%The \cs{lecture}\marg{name} macro sets the name of the lecture you are writing exercises for. |
| 176 |
% |
| 177 |
%\DescribeMacro{\semester} |
| 178 |
%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. |
| 179 |
% |
| 180 |
%\DescribeMacro{\exercise} |
| 181 |
%The \cs{exercise}\marg{number} macro sets the number of the exercise you are working on. |
| 182 |
% |
| 183 |
%\DescribeMacro{\task} |
| 184 |
%The \cs{task}\marg{number} macro sets the number of the first task. |
| 185 |
%This is useful if you submit single PDF files for each task within the exercise. |
| 186 |
%If you omit this option, numbering starts at~1. |
| 187 |
% |
| 188 |
%\DescribeMacro{\group} |
| 189 |
%Sometimes tutors allow to submit exercises in groups. |
| 190 |
%You can use the optional \cs{group}\marg{number} macro to set the group number. |
| 191 |
%If no group number is given, the group number is not displayed. |
| 192 |
% |
| 193 |
%\DescribeMacro{\title} |
| 194 |
%The \cs{title}\marg{lecture name} macro is an alias for \cs{lecture}\marg{lecture name}. |
| 195 |
% |
| 196 |
%\DescribeMacro{\date} |
| 197 |
%The date is automatically set to the current date. |
| 198 |
%You can overwrite the default value with the \cs{date}\marg{date} macro. |
| 199 |
% |
| 200 |
%\subsection{Student Metadata} |
| 201 |
% |
| 202 |
%The following commands should be used to include identification in your exercise in order to assign your work. |
| 203 |
% |
| 204 |
%\DescribeMacro{\studentname} |
| 205 |
%You must define your full name with the \cs{studentname}\marg{full name} macro. |
| 206 |
%If you are working in a group, you can enter more names separated with commas and/or line breaks. |
| 207 |
% |
| 208 |
%\DescribeMacro{\studentnumber} |
| 209 |
%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. |
| 210 |
% |
| 211 |
%\DescribeMacro{\studentsymbol} |
| 212 |
%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. |
| 213 |
% |
| 214 |
%Both \cs{studentnumber} an \cs{studentsymbol} are optional. |
| 215 |
%Though, most tutors require specifying either student number or symbol. |
| 216 |
% |
| 217 |
%\paragraph{Multiple Students} |
| 218 |
% |
| 219 |
%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: |
| 220 |
%\begin{itemize} |
| 221 |
% \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}). |
| 222 |
% In this case you don't need to specify multiple names in the preamble, but just your own name. |
| 223 |
% \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. |
| 224 |
%\end{itemize} |
| 225 |
% |
| 226 |
%\subsection{Included Packages} |
| 227 |
% |
| 228 |
%The \texttt{\jobname} class loads a number of useful \LaTeX{} packages listed in Table~\ref{tab:packages}. |
| 229 |
%Those are needed to typeset exercises during the Computer Science bachelor's degree programme at Martin Luther University Halle-Wittenberg. |
| 230 |
%We recommend reading the introductions of each package's documentation on CTAN\footnote{\url{https://ctan.org/}}. |
| 231 |
%\begin{table} |
| 232 |
% \caption{Packages included in the class.} |
| 233 |
% \label{tab:packages} |
| 234 |
% \begin{tabular}{lll} |
| 235 |
% \toprule |
| 236 |
% \textbf{Package} & \textbf{Purpose} & \textbf{Link} \\ |
| 237 |
% \midrule |
| 238 |
% \texttt{babel} & hyphenation, localization & {\smaller\url{https://ctan.org/pkg/babel}} \\ |
| 239 |
% \texttt{amsmath} & mathematics & {\smaller\url{https://ctan.org/pkg/amsmath}} \\ |
| 240 |
% \texttt{amsthm} & & {\smaller\url{https://ctan.org/pkg/amsthm}} \\ |
| 241 |
% \texttt{amssymb} & & {\smaller\url{https://ctan.org/pkg/amssymb}} \\ |
| 242 |
% \texttt{amstext} & & {\smaller\url{https://ctan.org/pkg/amstext}} \\ |
| 243 |
% \texttt{array} & & {\smaller\url{https://ctan.org/pkg/array}} \\ |
| 244 |
% \texttt{cancel} & & {\smaller\url{https://ctan.org/pkg/cancel}} \\ |
| 245 |
% \texttt{inputenc} & UTF8 encoding & {\smaller\url{https://ctan.org/pkg/inputenc}} \\ |
| 246 |
% \texttt{fontenc} & T1 encoding & {\smaller\url{https://ctan.org/pkg/fontenc}} \\ |
| 247 |
% \texttt{booktabs} & tables & {\smaller\url{https://ctan.org/pkg/booktabs}} \\ |
| 248 |
% \texttt{graphicx} & images, graphics & {\smaller\url{https://ctan.org/pkg/graphicx}} \\ |
| 249 |
% \texttt{xcolor} & color definitions & {\smaller\url{https://ctan.org/pkg/xcolor}} \\ |
| 250 |
% \texttt{tikz} & drawing vector graphics & {\smaller\url{https://ctan.org/pkg/tikz}} \\ |
| 251 |
% \texttt{pgfplots} & plotting & {\smaller\url{https://ctan.org/pkg/pgfplots}} \\ |
| 252 |
% \texttt{algorithm2e} & pseudocode, algorithms & {\smaller\url{https://ctan.org/pkg/algorithm2e}} \\ |
| 253 |
% \texttt{listings} & code listings & {\smaller\url{https://ctan.org/pkg/listings}} \\ |
| 254 |
% \texttt{listingsutf8} & & {\smaller\url{https://ctan.org/pkg/listingsutf8}} \\ |
| 255 |
% \texttt{subcaption} & sub-figures & {\smaller\url{https://ctan.org/pkg/subcaption}} \\ |
| 256 |
% \texttt{csquotes} & quotation & {\smaller\url{https://ctan.org/pkg/csquotes}} \\ |
| 257 |
% \bottomrule |
| 258 |
% \end{tabular} |
| 259 |
%\end{table} |
| 260 |
% |
| 261 |
%\section{Design Goals} |
| 262 |
% |
| 263 |
%The \texttt{\jobname} class should: |
| 264 |
% |
| 265 |
%\begin{itemize} |
| 266 |
% \item be usable for first semester students with rather little LaTeX experience, |
| 267 |
% \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 |
| 268 |
% \item include packages frequently needed by students. |
| 269 |
%\end{itemize} |
| 270 |
% |
| 271 |
%\section{Implementation} |
| 272 |
% |
| 273 |
%\subsection{Setup} |
| 274 |
% |
| 275 |
%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. |
| 276 |
% |
| 277 |
% \begin{macrocode} |
| 278 |
\NeedsTeXFormat{LaTeX2e} |
| 279 |
\ProvidesPackage{mluexercise}[2020/11/12 v2.0] |
| 280 |
% \end{macrocode} |
| 281 |
% |
| 282 |
%\paragraph{Options} |
| 283 |
% |
| 284 |
% \begin{macrocode} |
| 285 |
\newif\ifdataminingstyle\dataminingstylefalse |
| 286 |
\DeclareOption{dataminingstyle}{% |
| 287 |
\dataminingstyletrue |
| 288 |
} |
| 289 |
% \end{macrocode} |
| 290 |
% |
| 291 |
%Process options and load base class with remaining options. |
| 292 |
% |
| 293 |
% \begin{macrocode} |
| 294 |
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{scrartcl}} |
| 295 |
\ProcessOptions* |
| 296 |
\LoadClass{scrartcl} |
| 297 |
% \end{macrocode} |
| 298 |
% |
| 299 |
%To enable support for UTF8 and some other useful basics, we load a bunch of packages. |
| 300 |
% |
| 301 |
% \begin{macrocode} |
| 302 |
\RequirePackage[utf8]{inputenc} |
| 303 |
\RequirePackage[T1]{fontenc} |
| 304 |
\RequirePackage{ifthen} % Conditional branches and loops. |
| 305 |
\RequirePackage{etoolbox} % Hooks for executing code. |
| 306 |
\RequirePackage{hyperref} % Hyperlinks. |
| 307 |
\RequirePackage{xcolor} % Color definitions. |
| 308 |
% \end{macrocode} |
| 309 |
% |
| 310 |
%As we'd like to be able to switch between English and German with proper hyphenation, load language support packages.% |
| 311 |
%\footnote{If you'd like to add a language, please contact us.} |
| 312 |
% |
| 313 |
% \begin{macrocode} |
| 314 |
\RequirePackage{babel} |
| 315 |
\RequirePackage{iflang} |
| 316 |
\newcommand{\IfGerman}[2]{\IfLanguagePatterns{german}{#1}{% |
| 317 |
\IfLanguagePatterns{ngerman}{#1}{#2}}} |
| 318 |
% \end{macrocode} |
| 319 |
% |
| 320 |
%\subsection{Global Variables} |
| 321 |
% |
| 322 |
%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. |
| 323 |
% |
| 324 |
% \begin{macrocode} |
| 325 |
\newcommand{\@checkoption}[3]{% |
| 326 |
\AtEndPreamble{% |
| 327 |
\ifthenelse{\equal{\the#1}{}}{% |
| 328 |
\ClassError{mluexercise}{Missing #2}{% |
| 329 |
Set #2 using the \protect#3 command.% |
| 330 |
}% |
| 331 |
}{}% |
| 332 |
}% |
| 333 |
} |
| 334 |
\newtoks\@lecture |
| 335 |
\newcommand{\lecture}[1]{\global\@lecture{#1}} |
| 336 |
\let\title\lecture % Redefine standard \title command. |
| 337 |
\@checkoption{\@lecture}{lecture name}{\lecture} |
| 338 |
\newtoks\@semester |
| 339 |
\newcommand{\semester}[1]{\global\@semester{#1}} |
| 340 |
\global\@semester{ % Automatically set semester based on current date. |
| 341 |
\ifnum\month<4 % Winter semester, including previous year. |
| 342 |
WS~{\advance\year by -1 \the\year\advance\year by 1}/\the\year% |
| 343 |
\else\ifnum\month<10 % Summer semester. |
| 344 |
SS~\the\year% |
| 345 |
\else % Winter semester, including next year. |
| 346 |
WS~\the\year/{\advance\year by 1 \the\year\advance\year by -1}% |
| 347 |
\fi\fi% |
| 348 |
} |
| 349 |
\newtoks\@exercise |
| 350 |
\newcommand{\exercise}[1]{\global\@exercise{#1}} |
| 351 |
\@checkoption{\@exercise}{exercise number}{\exercise} |
| 352 |
\newtoks\@task |
| 353 |
\newcommand{\task}[1]{\global\@task{#1}} |
| 354 |
\global\@task{1} |
| 355 |
\newtoks\@group |
| 356 |
\newcommand{\group}[1]{\global\@group{#1}} |
| 357 |
\global\@group{0} |
| 358 |
\newtoks\@studentname |
| 359 |
\newcommand{\studentname}[1]{\global\@studentname{#1}} |
| 360 |
\let\author\studentname % Redefine standard \title command. |
| 361 |
\@checkoption{\@studentname}{student name}{\studentname} |
| 362 |
\newtoks\@studentnumber |
| 363 |
\newcommand{\studentnumber}[1]{\global\@studentnumber{#1}} |
| 364 |
\newtoks\@studentsymbol |
| 365 |
\newcommand{\studentsymbol}[1]{\global\@studentsymbol{#1}} |
| 366 |
% \end{macrocode} |
| 367 |
% |
| 368 |
%\subsection{Layout, Text} |
| 369 |
% |
| 370 |
%Set up a reasonable page layout and define text styles that comply with Martin Luther University brand guidelines. |
| 371 |
% |
| 372 |
% \begin{macrocode} |
| 373 |
\RequirePackage{calc} |
| 374 |
\RequirePackage[ |
| 375 |
a4paper, |
| 376 |
inner=2cm, |
| 377 |
outer=2cm, |
| 378 |
top=3cm, |
| 379 |
bottom=3cm, |
| 380 |
head=0.75cm, |
| 381 |
headsep=0.25cm, |
| 382 |
foot=0.75cm, |
| 383 |
]{geometry} |
| 384 |
\renewcommand{\baselinestretch}{1.15} |
| 385 |
\setlength{\parindent}{0em} % Disable paragraph indentation. |
| 386 |
\setlength{\parskip}{1ex} % Instead enable paragraph margins. |
| 387 |
% \end{macrocode} |
| 388 |
% |
| 389 |
%\paragraph{Font Families} |
| 390 |
% |
| 391 |
%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. |
| 392 |
% |
| 393 |
% \begin{macrocode} |
| 394 |
\RequirePackage{libertine} |
| 395 |
\RequirePackage{eulervm} |
| 396 |
\RequirePackage[ttdefault]{sourcecodepro} |
| 397 |
\RequirePackage{microtype} |
| 398 |
\DisableLigatures{family=tt*} |
| 399 |
% \end{macrocode} |
| 400 |
% |
| 401 |
%\paragraph{Text Styles} |
| 402 |
% |
| 403 |
% \begin{macrocode} |
| 404 |
\newcommand{\strong}[1]{\textbf{#1}} |
| 405 |
\newcommand{\italic}[1]{\textit{#1}} |
| 406 |
\newcommand{\code}[1]{\texttt{#1}} |
| 407 |
% Double underline. |
| 408 |
\newcommand{\Underline}[1]{\underline{\underline{#1}}} |
| 409 |
% Abbreviated plural ("Lineare Algebra" lecture). |
| 410 |
\newcommand{\plural}[1]{\textsuperscript{\underline{#1}}} |
| 411 |
\newcommand{\pl}[1]{\plural{#1}} |
| 412 |
\RequirePackage[autostyle=true,german=quotes]{csquotes} |
| 413 |
% \end{macrocode} |
| 414 |
% |
| 415 |
%\paragraph{URL / Link Font} |
| 416 |
% |
| 417 |
% \begin{macrocode} |
| 418 |
\RequirePackage{relsize} |
| 419 |
\newcommand{\ttsmallfont}{\ttfamily\smaller} |
| 420 |
\renewcommand{\UrlFont}{\ttsmallfont} |
| 421 |
\newcommand{\textttsmall}[1]{{\ttsmallfont #1}} |
| 422 |
\newcommand{\query}[1]{{\ttsmallfont #1}} |
| 423 |
\newcommand{\domain}[1]{\href{http://#1}{\mbox{\ttsmallfont #1}}} |
| 424 |
\newcommand{\email}[1]{\href{mailto:#1}{\mbox{\ttsmallfont #1}}} |
| 425 |
% \end{macrocode} |
| 426 |
% |
| 427 |
%\paragraph{Headings} |
| 428 |
% |
| 429 |
% \begin{macrocode} |
| 430 |
\setkomafont{sectioning}{\sffamily\mdseries} |
| 431 |
\setkomafont{section}{\LARGE} |
| 432 |
\setkomafont{subsection}{\Large} |
| 433 |
\setkomafont{subsubsection}{\large} |
| 434 |
\setkomafont{paragraph}{\large} |
| 435 |
\setkomafont{subparagraph}{\normalsize} |
| 436 |
\renewcommand{\thesection}{% |
| 437 |
\bfseries\upshape \IfGerman{Aufgabe}{Task} \arabic{section}} |
| 438 |
\renewcommand{\thesubsection}{% |
| 439 |
\bfseries\upshape \alph{subsection})} |
| 440 |
\renewcommand{\thesubsubsection}{% |
| 441 |
\upshape (\roman{subsubsection})} |
| 442 |
\renewcommand{\autodot}{} |
| 443 |
% \end{macrocode} |
| 444 |
% |
| 445 |
%\paragraph{Title} |
| 446 |
% |
| 447 |
% \begin{macrocode} |
| 448 |
\newcommand{\Rom}[1]{\uppercase\expandafter{\romannumeral#1\relax}} |
| 449 |
\newcommand{\groupstring}{\ifnum\the\@group>0{, |
| 450 |
\IfGerman{Gruppe}{Group} \Rom{\the\@group}}\fi} |
| 451 |
\author{} |
| 452 |
\setkomafont{title}{\sffamily\bfseries\huge\centering} |
| 453 |
\setkomafont{date}{\sffamily\large\centering} |
| 454 |
\newlength{\approxtitlewidth} |
| 455 |
\renewcommand{\maketitle}{% |
| 456 |
\settowidth{\approxtitlewidth}{% |
| 457 |
\usefontofkomafont{title}\the\@lecture}% |
| 458 |
\ifthenelse{\lengthtest{\approxtitlewidth>\textwidth}}{% |
| 459 |
\addtokomafont{title}{\LARGE}}{}% |
| 460 |
\begin{center}% |
| 461 |
\usefontofkomafont{title}\the\@lecture \\ |
| 462 |
\usefontofkomafont{date}\@date, \the\@semester\groupstring |
| 463 |
\end{center} |
| 464 |
} |
| 465 |
% \end{macrocode} |
| 466 |
% |
| 467 |
%\paragraph{Head, Foot} |
| 468 |
% |
| 469 |
% \begin{macrocode} |
| 470 |
\RequirePackage[headsepline,footsepline]{scrlayer-scrpage} |
| 471 |
\RequirePackage{totpages} |
| 472 |
\pagestyle{scrheadings} |
| 473 |
\clearscrheadfoot |
| 474 |
\setkomafont{pageheadfoot}{\sffamily} |
| 475 |
\setkomafont{pagenumber}{\sffamily} |
| 476 |
\ofoot{\thepage~von~\ref{TotPages}} |
| 477 |
% \end{macrocode} |
| 478 |
% |
| 479 |
%\subsection{Mathematics} |
| 480 |
% |
| 481 |
%We rely on AMS packages for rendering mathematical equations, proofs, and symbols. |
| 482 |
%Additionally we load packages for arrays in math mode and cancellations |
| 483 |
% |
| 484 |
% \begin{macrocode} |
| 485 |
\RequirePackage{amsmath} |
| 486 |
\RequirePackage{amsthm} |
| 487 |
\RequirePackage{amssymb} |
| 488 |
\RequirePackage{amstext} |
| 489 |
\RequirePackage{array} |
| 490 |
\RequirePackage{cancel} |
| 491 |
% \end{macrocode} |
| 492 |
% |
| 493 |
%Now we define (more readable) macros for the mathematical symbols and functions most commonly used at Martin Luther University. |
| 494 |
% |
| 495 |
% \begin{macrocode} |
| 496 |
\newcommand{\union}{\cup} |
| 497 |
\newcommand{\disjunction}{\uplus} |
| 498 |
\newcommand{\intersection}{\cap} |
| 499 |
\newcommand{\intersect}{\cap} |
| 500 |
\newcommand{\infinity}{\infty} |
| 501 |
\newcommand{\corresponds}{\triangleq} |
| 502 |
% \end{macrocode} |
| 503 |
% |
| 504 |
% \begin{macrocode} |
| 505 |
\newcommand{\C}{\mathbb{C}} % Complex numbers. |
| 506 |
\newcommand{\complexnumbers}{\C} |
| 507 |
\newcommand{\R}{\mathbb{R}} % Real numbers. |
| 508 |
\newcommand{\realnumbers}{\R} |
| 509 |
\newcommand{\Q}{\mathbb{Q}} % Rational numbers. |
| 510 |
\newcommand{\rationalnumbers}{\Q} |
| 511 |
\newcommand{\Z}{\mathbb{Z}} % Whole numbers. |
| 512 |
\newcommand{\wholenumbers}{\Z} |
| 513 |
\newcommand{\N}{\mathbb{N}} % Natural numbers. |
| 514 |
\newcommand{\naturalnumbers}{\N} |
| 515 |
\newcommand{\B}{\mathbb{B}} % Binary numbers. |
| 516 |
\newcommand{\binarynumbers}{\B} |
| 517 |
% \end{macrocode} |
| 518 |
% |
| 519 |
% \begin{macrocode} |
| 520 |
% Equivalence transformation |
| 521 |
\newcommand{\eqtransform}{\ensuremath{\qquad\big|\,\,}} |
| 522 |
% "Ditto" sign |
| 523 |
\newcommand{\ditto}{\textquotedbl} \newcommand{\dito}{\ditto} |
| 524 |
% End of proof: "quod erat demonstrandum" |
| 525 |
\renewcommand{\qed}{\nopagebreak\hfill\ensuremath{\square}} |
| 526 |
% \end{macrocode} |
| 527 |
% |
| 528 |
% \begin{macrocode} |
| 529 |
\newcommand{\mland}{\(\land\)} % \land in text. |
| 530 |
\newcommand{\mlor}{\(\lor\)} % \lor in text. |
| 531 |
% \end{macrocode} |
| 532 |
% |
| 533 |
%Many maths symbols can have alternatives for stylistic choices. We enable the variants most liked by our tutors. |
| 534 |
% |
| 535 |
% \begin{macrocode} |
| 536 |
\let\tmp\mod \let\mod\bmod \let\bmod\tmp |
| 537 |
\let\varemptyset\emptyset \let\emptyset\varnothing |
| 538 |
\let\tmp\epsilon \let\epsilon\varepsilon \let\varepsilon\tmp |
| 539 |
\let\tmp\phi \let\phi\varphi \let\varphi\tmp |
| 540 |
% \end{macrocode} |
| 541 |
% |
| 542 |
%For some specific lectures we provide more detailed macros for symbols and functions. |
| 543 |
% |
| 544 |
%\paragraph{Lecture \textquote{Lineare Algebra}} |
| 545 |
% |
| 546 |
% \begin{macrocode} |
| 547 |
\newcommand{\base}[1]{\mathcal{#1}} % Base (caligraphic) |
| 548 |
\DeclareMathOperator{\im}{im} % Image |
| 549 |
\DeclareMathOperator{\id}{id} % Identity |
| 550 |
\DeclareMathOperator{\sel}{sel} % Selection |
| 551 |
\DeclareMathOperator{\dom}{dom} % Domain |
| 552 |
\DeclareMathOperator{\ran}{ran} % Range |
| 553 |
\DeclareMathOperator{\Hom}{Hom} % Homomorphism |
| 554 |
\DeclareMathOperator{\End}{End} % Endomorphism |
| 555 |
% \end{macrocode} |
| 556 |
% |
| 557 |
%\paragraph{Lecture \textquote{Datenstrukturen und effiziente Algorithmen}} |
| 558 |
% |
| 559 |
% \begin{macrocode} |
| 560 |
\renewcommand{\O}{\mathcal{O}} % asymptotic O-Notation (Landau) |
| 561 |
\DeclareMathOperator{\indeg}{indeg} % Indegree |
| 562 |
\DeclareMathOperator{\outdeg}{outdeg} % Outdegree |
| 563 |
% \end{macrocode} |
| 564 |
% |
| 565 |
%\paragraph{Lecture \textquote{Einführung in Data Science}} |
| 566 |
% |
| 567 |
% \begin{macrocode} |
| 568 |
\renewcommand{\P}{\ifdataminingstyle p\else\mathbf{P}\fi} |
| 569 |
\newcommand{\E}{\ifdataminingstyle\mathbb{E}\else\mathbf{E}\fi} |
| 570 |
\DeclareMathOperator{\var}{var} |
| 571 |
\DeclareMathOperator{\Var}{Var} |
| 572 |
\DeclareMathOperator{\cov}{cov} |
| 573 |
\DeclareMathOperator{\Cov}{Cov} |
| 574 |
\DeclareMathOperator{\Bin}{Bin} |
| 575 |
\DeclareMathOperator{\Exp}{Exp} |
| 576 |
\DeclareMathOperator{\Dir}{Dir} |
| 577 |
\DeclareMathOperator{\Mult}{Mult} |
| 578 |
\newcommand{\Normal}{\mathcal{N}} |
| 579 |
\newcommand{\Norm}{\Normal} |
| 580 |
% \end{macrocode} |
| 581 |
% |
| 582 |
%\paragraph{Table Columns} |
| 583 |
% |
| 584 |
%The handy \texttt{tabular} column definitions below can be used to typeset a whole column in math mode, to avoid repetetive opening/closing brackets. |
| 585 |
% |
| 586 |
% \begin{macrocode} |
| 587 |
\newcolumntype{L}{>{\(}l<{\)}} |
| 588 |
\newcolumntype{R}{>{\(}r<{\)}} |
| 589 |
\newcolumntype{C}{>{\(}c<{\)}} |
| 590 |
% \end{macrocode} |
| 591 |
% |
| 592 |
%\paragraph{Calculus Environments} |
| 593 |
% |
| 594 |
%Calculus environments are currently work in progress, subject to change, and may not work as expected. |
| 595 |
%However, they can simplify writing logical consequences in the \textquote{Mathematische Grundlagen der Informatik und Konzepte der Modellierung} lecture. |
| 596 |
% |
| 597 |
% \begin{macrocode} |
| 598 |
\newcounter{calculusRowCount} |
| 599 |
\RequirePackage{pgfkeys} |
| 600 |
\newenvironment{calculus}[1]{ |
| 601 |
\pgfkeys{/mlu/calculus/.cd,show index=false, |
| 602 |
context=\Gamma,context command=context,#1} |
| 603 |
\setcounter{calculusRowCount}{0} |
| 604 |
\newcommand{\calculusSymbol}{\text{ |
| 605 |
\sffamily\itshape\pgfkeysvalueof{/mlu/calculus/symbol}}} |
| 606 |
\newcommand{\calculusContext}{\ensuremath{ |
| 607 |
\pgfkeysvalueof{/mlu/calculus/context}}} |
| 608 |
\expandafter\let\csname \pgfkeysvalueof{/mlu/calculus/context command}% |
| 609 |
\endcsname\calculusContext |
| 610 |
\par\vspace{0.5em} |
| 611 |
\begin{minipage}{\textwidth}\begin{tabular}{ |
| 612 |
@{\stepcounter{calculusRowCount} |
| 613 |
(\arabic{calculusRowCount})\hspace{1em}} R |
| 614 |
@{\hspace{0.4em} |
| 615 |
\( |
| 616 |
\vdash_{% |
| 617 |
\ifthenelse{% |
| 618 |
\equal{\pgfkeysvalueof{/mlu/calculus/show index}}{true} |
| 619 |
}{ |
| 620 |
\ifthenelse{% |
| 621 |
\equal{\pgfkeysvalueof{/mlu/calculus/symbol}}{}% |
| 622 |
}{}{% |
| 623 |
\calculusSymbol% |
| 624 |
}% |
| 625 |
}{% |
| 626 |
\hspace{-0.1em}% |
| 627 |
}% |
| 628 |
}% |
| 629 |
\)\hspace{0.6em}} |
| 630 |
L l |
| 631 |
} |
| 632 |
}{ |
| 633 |
\end{tabular}\end{minipage}\vspace{0.5em} |
| 634 |
\let\calculusContext\undefined \let\calculusSymbol\undefined |
| 635 |
\expandafter\let\csname \pgfkeysvalueof{/mlu/calculus/context command}% |
| 636 |
\endcsname\undefined |
| 637 |
} |
| 638 |
\newenvironment{eqcalc}[1][]{\begin{calculus}[ |
| 639 |
symbol=E,show index=true,context={\calculusSymbol_{#1}}, |
| 640 |
context command=E]}{\end{calculus}} % Equation calculus |
| 641 |
\newenvironment{seqcalc}{\begin{calculus}[ |
| 642 |
symbol=S,show index=true, context={\calculusSymbol}, |
| 643 |
context command=seq]}{\end{calculus}} % Sequence calculus |
| 644 |
% \end{macrocode} |
| 645 |
% |
| 646 |
%\subsection{Algorithms, Pseudocode} |
| 647 |
%\label{sec:implementation-pseudocode} |
| 648 |
% |
| 649 |
% \begin{macrocode} |
| 650 |
\RequirePackage[vlined,linesnumbered]{algorithm2e} |
| 651 |
\DontPrintSemicolon % Hide semicolons. |
| 652 |
\SetKwProg{Function}{function}{\ is}{end function} |
| 653 |
\SetKwComment{Comment}{\quad\(\triangleright\)~}{} % Comment style. |
| 654 |
\SetCommentSty{itshape} % Comment font. |
| 655 |
\SetKw{Continue}{continue} |
| 656 |
\SetKwBlock{Repeat}{repeat}{} |
| 657 |
\SetNlSty{tiny}{}{} % Line number font. |
| 658 |
\SetNlSkip{0.5em} % Line number skip. |
| 659 |
\SetAlgoNlRelativeSize{0} |
| 660 |
\SetAlFnt{\footnotesize} |
| 661 |
% \end{macrocode} |
| 662 |
% |
| 663 |
%\subsection{Code Listings} |
| 664 |
% |
| 665 |
%For syntax highlighting and including source code listings, we use the \texttt{listings} package. |
| 666 |
%With \texttt{listingsutf8} we can include listings that contain Unicode characters. |
| 667 |
% |
| 668 |
% \begin{macrocode} |
| 669 |
\RequirePackage{listings} |
| 670 |
\RequirePackage{listingsutf8} % UTF8 support in included listings. |
| 671 |
% \end{macrocode} |
| 672 |
% |
| 673 |
%Define colors for syntax highlighting. |
| 674 |
% |
| 675 |
% \begin{macrocode} |
| 676 |
\definecolor{lsnumber}{rgb}{0,0,0} % Zeilennummerfarbe |
| 677 |
\definecolor{lscomment}{rgb}{0.25,0.5,0.35} % Kommentarfarbe |
| 678 |
\definecolor{lskeyword}{rgb}{0.5,0,0.35} % Schlüsselwörterfarbe |
| 679 |
\definecolor{lsstring}{rgb}{0.6,0,0} % Zeichenkettenfarbe |
| 680 |
% \end{macrocode} |
| 681 |
% |
| 682 |
%The default listing style below is enabled automatically and should guarantee consistency with the appearance of pseudocode (see Section~\ref{sec:implementation-pseudocode}). |
| 683 |
% |
| 684 |
% \begin{macrocode} |
| 685 |
\lstset{ |
| 686 |
language=C, |
| 687 |
basicstyle=\ttfamily, |
| 688 |
breakatwhitespace=false, |
| 689 |
breaklines=true, |
| 690 |
prebreak={\mbox{\footnotesize\(\hookleftarrow\)}}, |
| 691 |
numbers=left, |
| 692 |
numberstyle=\color{lsnumber}\tiny, |
| 693 |
numbersep=0.5em, |
| 694 |
stepnumber=1, |
| 695 |
commentstyle=\color{lscomment}, |
| 696 |
morecomment=[s][\color{lscomment}]{/**}{*/}, |
| 697 |
keepspaces=true, |
| 698 |
keywordstyle=\bfseries\color{lskeyword}, |
| 699 |
stringstyle=\color{lsstring}, |
| 700 |
showtabs=false, showspaces=false, |
| 701 |
showstringspaces=false, |
| 702 |
tabsize=2, |
| 703 |
} |
| 704 |
% \end{macrocode} |
| 705 |
% |
| 706 |
%\paragraph{Haskell Language Definition} |
| 707 |
% |
| 708 |
%Refine the Haskell language definition and code style for use in the \textquote{Konzepte der Programmierung} lecture. |
| 709 |
% |
| 710 |
% \begin{macrocode} |
| 711 |
\lstdefinelanguage[Zimmermann]{haskell}[]{haskell}{ |
| 712 |
escapeinside={*'}{'*}, |
| 713 |
showstringspaces=false, |
| 714 |
morecomment=[l]\%, |
| 715 |
captionpos=b, |
| 716 |
emphstyle={\bfseries}, |
| 717 |
} |
| 718 |
\lstalias[]{zhaskell}[Zimmermann]{haskell} |
| 719 |
% Deprecated. Use `language=zhaskell` instead of `style=haskell`. |
| 720 |
\lstdefinestyle{haskell}{language=zhaskell} |
| 721 |
% \end{macrocode} |
| 722 |
% |
| 723 |
%\paragraph{Assembler Language Definition} |
| 724 |
%Introduce a new language definition for Prof.~Molitor's Assembler dialect used in \textquote{Einführung in Rechnerarchitektur}. |
| 725 |
% |
| 726 |
% \begin{macrocode} |
| 727 |
\lstdefinelanguage[Molitor]{Assembler}[x86masm]{Assembler}{ |
| 728 |
morekeywords={ |
| 729 |
ldd,sto,shl,shr,rol,ror,sub,add,shli,shri,roli,rori, |
| 730 |
subi,addi,or,and,xor,xnor,jmp,beq,bneq,bgt,bo,ldpc,stpc |
| 731 |
}, |
| 732 |
comment=[l]{\#}, |
| 733 |
} |
| 734 |
\lstalias[]{massembler}[Molitor]{Assembler} |
| 735 |
% Deprecated. Use `language=massembler` instead of `style=massembler`. |
| 736 |
\lstdefinestyle{massembler}{language=massembler} |
| 737 |
% \end{macrocode} |
| 738 |
% |
| 739 |
%\subsection{Graphics, Drawing, Plots} |
| 740 |
% |
| 741 |
%We add packages for including images and graphics, for drawing vector graphics, and for plotting data or functions. |
| 742 |
% |
| 743 |
% \begin{macrocode} |
| 744 |
\RequirePackage{booktabs} |
| 745 |
\RequirePackage{graphicx} |
| 746 |
\RequirePackage{float} |
| 747 |
\RequirePackage{subcaption} |
| 748 |
\RequirePackage{tikz} |
| 749 |
\RequirePackage{pgfplots} |
| 750 |
\RequirePackage{rotating} |
| 751 |
\usetikzlibrary{positioning} |
| 752 |
\usetikzlibrary{automata} |
| 753 |
\usetikzlibrary{trees} |
| 754 |
\tikzset{ |
| 755 |
>=latex, |
| 756 |
font=\sffamily, |
| 757 |
} |
| 758 |
\pgfplotsset{compat=1.16} |
| 759 |
% \end{macrocode} |
| 760 |
% |
| 761 |
%\subsection{Document Hooks} |
| 762 |
% |
| 763 |
%The following \LaTeX{} code should be inserted just before \lstinline|\begin{document}|. |
| 764 |
% |
| 765 |
% \begin{macrocode} |
| 766 |
\AtEndPreamble{ |
| 767 |
% \end{macrocode} |
| 768 |
% |
| 769 |
%Update exercise and task number as specified in the preamble. (Set first section number to task number.) |
| 770 |
% |
| 771 |
% \begin{macrocode} |
| 772 |
\setcounter{section}{\the\@task} \addtocounter{section}{-1} |
| 773 |
\newcommand{\@exercisestring}{\IfGerman{% |
| 774 |
\the\@exercise.~Übungsserie}{Exercise~\the\@exercise}} |
| 775 |
% \end{macrocode} |
| 776 |
% |
| 777 |
%Set up page head/foot with metadata. |
| 778 |
% |
| 779 |
% \begin{macrocode} |
| 780 |
\ihead{\the\@studentname} |
| 781 |
\chead{\textbf{\@exercisestring}} |
| 782 |
\ohead{ |
| 783 |
\the\@studentnumber% |
| 784 |
\ifthenelse{\equal{\the\@studentnumber}{} \OR |
| 785 |
\equal{\the\@studentsymbol}{}}{}{\ /\,}% |
| 786 |
\the\@studentsymbol% |
| 787 |
} |
| 788 |
% \end{macrocode} |
| 789 |
% |
| 790 |
%Set up PDF metadata. |
| 791 |
% |
| 792 |
% \begin{macrocode} |
| 793 |
\hypersetup{ |
| 794 |
pdfauthor={\the\@studentname}, |
| 795 |
pdftitle={\@exercisestring - \the\@lecture} |
| 796 |
} |
| 797 |
% \end{macrocode} |
| 798 |
% |
| 799 |
% |
| 800 |
% \begin{macrocode} |
| 801 |
} |
| 802 |
% \end{macrocode} |
| 803 |
% |
| 804 |
%\iffalse |
| 805 |
%</class> |
| 806 |
%\fi |
| 807 |
% |
| 808 |
%\StopEventually{ |
| 809 |
% \PrintChanges |
| 810 |
%} |
| 811 |
% |
| 812 |
%\Finale |
| 813 |
\endinput |