define algorithm environment, redefine tasks

This commit is contained in:
Never Gude 2026-05-01 16:56:26 +02:00
parent 051cb68d48
commit 712d63ee33
3 changed files with 100 additions and 58 deletions

View file

@ -15,15 +15,9 @@
\recalctypearea \recalctypearea
\RequirePackage{ngutils} \RequirePackage{ngutils}
\RequirePackage{enumitem}
\setlist{leftmargin=*}
% define fonts % define fonts
\RequirePackage{fontspec} \RequirePackage{fontspec}
%\RequirePackage{tgpagella}
%\RequirePackage{tgheros}
%\RequirePackage{euler-math}
\RequirePackage[math-style=upright]{unicode-math} \RequirePackage[math-style=upright]{unicode-math}
\setmainfont{TeX Gyre Pagella} \setmainfont{TeX Gyre Pagella}
\setsansfont{TeX Gyre Heros} \setsansfont{TeX Gyre Heros}
@ -33,18 +27,6 @@
\setlength{\marginparwidth}{1.5\marginparwidth} \setlength{\marginparwidth}{1.5\marginparwidth}
\setlength{\fboxrule}{\heavyrulewidth} \setlength{\fboxrule}{\heavyrulewidth}
%
\renewcommand\theenumi{\@alph\c@enumi}
\renewcommand\theenumii{\@arabic\c@enumii}
%\renewcommand\theenumiii{\@roman\c@enumiii}
%\renewcommand\theenumiv{\@Alph\c@enumiv}
\renewcommand\labelenumi{\theenumi)}
\renewcommand\labelenumii{\theenumii.}
%\renewcommand\labelenumiii{\theenumiii.}
%\renewcommand\labelenumiv{\theenumiv.}
% Use sansfont for all title elements % Use sansfont for all title elements
\addtokomafont{titlehead}{\sffamily} \addtokomafont{titlehead}{\sffamily}
\addtokomafont{subject}{\normalfont \sffamily \itshape} \addtokomafont{subject}{\normalfont \sffamily \itshape}
@ -64,3 +46,26 @@
\newkomafont{points}{\sffamily} \newkomafont{points}{\sffamily}
\newcommand\points[2][\quad]{\marginline{\framebox{{\usekomafont{points}#1 \textbf{/} #2}}}} \newcommand\points[2][\quad]{\marginline{\framebox{{\usekomafont{points}#1 \textbf{/} #2}}}}
\newcounter{task}
\renewcommand{\thetask}{\@alph\c@task)}
\newenvironment{tasks}
{
\begin{list}{\thetask}
{
\usecounter{task}
\setlength{\leftmargin}{1.6em}
}
}{%
\end{list}
}
\DeclareNewTOC
[
type=algorithm,
types=algorithms,
float,
floattype=4,
name=Algorithmus,
listname={Algorithmenverzeichnis}
]
{loa}

View file

@ -9,7 +9,7 @@
\ProcessOptions\relax \ProcessOptions\relax
% More declarations % % More declarations %
\LoadClass{scrartcl} \LoadClass[sfdefaults=false, parskip=half]{scrartcl}
%\KOMAoptions{mpinclude=true} %\KOMAoptions{mpinclude=true}
%\recalctypearea %\recalctypearea
@ -18,9 +18,6 @@
% define fonts % define fonts
\RequirePackage{fontspec} \RequirePackage{fontspec}
%\RequirePackage{tgpagella}
%\RequirePackage{tgheros}
%\RequirePackage{euler-math}
\RequirePackage[math-style=upright]{unicode-math} \RequirePackage[math-style=upright]{unicode-math}
\setmainfont{TeX Gyre Pagella} \setmainfont{TeX Gyre Pagella}
\setsansfont{TeX Gyre Heros} \setsansfont{TeX Gyre Heros}
@ -30,18 +27,6 @@
\setlength{\marginparwidth}{1.5\marginparwidth} \setlength{\marginparwidth}{1.5\marginparwidth}
\setlength{\fboxrule}{\heavyrulewidth} \setlength{\fboxrule}{\heavyrulewidth}
%
%\renewcommand\theenumi{\@alph\c@enumi}
%\renewcommand\theenumii{\@arabic\c@enumii}
%\renewcommand\theenumiii{\@roman\c@enumiii}
%\renewcommand\theenumiv{\@Alph\c@enumiv}
%\renewcommand\labelenumi{\theenumi)}
%\renewcommand\labelenumii{\theenumii.}
%\renewcommand\labelenumiii{\theenumiii.}
%\renewcommand\labelenumiv{\theenumiv.}
% Use sansfont for all title elements % Use sansfont for all title elements
\addtokomafont{titlehead}{\sffamily} \addtokomafont{titlehead}{\sffamily}
\addtokomafont{subject}{\normalfont \sffamily \itshape} \addtokomafont{subject}{\normalfont \sffamily \itshape}
@ -52,12 +37,18 @@
\addtokomafont{publishers}{\sffamily} \addtokomafont{publishers}{\sffamily}
% Use serif font for headings % Use serif font for headings
\addtokomafont{disposition}{\rmfamily} % \addtokomafont{disposition}{\rmfamily}
% Let sections be formated as in: Aufgabe 1 -- Section title % Use serif italic for description labels
%\renewcommand*{\sectionformat}{Aufgabe \thesection\autodot\enskip--\enskip} \addtokomafont{descriptionlabel}{\normalfont \itshape}
% Let points of an exercise be printed as in: [__ / 2]
%\newkomafont{points}{\sffamily}
%\newcommand\points[2][\quad]{\marginline{\framebox{{\usekomafont{points}#1 \textbf{/} #2}}}}
\DeclareNewTOC
[
type=algorithm,
types=algorithms,
float,
floattype=4,
name=Algorithmus,
listname={Algorithmenverzeichnis}
]
{loa}

View file

@ -5,35 +5,61 @@
\RequirePackage{graphicx} \RequirePackage{graphicx}
\RequirePackage{tabularx} \RequirePackage{tabularx}
\RequirePackage{booktabs} \RequirePackage{booktabs}
\RequirePackage{listings}
\newcommand\Eh{\ensuremath{\mathrm{E}}}
\newcommand\Var{\ensuremath{\mathrm{Var}}} \lstnewenvironment{pseudocode}[1][] %defines the algorithm listing environment
{
\renewcommand{\lstlistingname}{Algorithmus}
\lstset{ %this is the stype
mathescape=true,
columns=fullflexible,
basicstyle=\normalfont,
identifierstyle=\scshape,
keywordstyle=\bfseries,
keywords={, new, if, then, else, while, for, in, to, up, down, foreach, do, return},
commentstyle=\itshape,
comment=[l]//,
delim=[is][\normalfont]{|}{|},
tabsize=3,
frame=tb,
framerule=1pt,
#1 % this is to add specific settings to an usage of this environment (for instnce, the caption and referable label)
}
}
{}
\newcommand{\seilpmi}{\ensuremath{\Longleftarrow}}
\newcommand\NN{\ensuremath{\mathbb{N}}} \newcommand\NN{\ensuremath{\mathbb{N}}}
\newcommand\ZZ{\ensuremath{\mathbb{Z}}} \newcommand\ZZ{\ensuremath{\mathbb{Z}}}
\newcommand\QQ{\ensuremath{\mathbb{Q}}} \newcommand\QQ{\ensuremath{\mathbb{Q}}}
\newcommand\RR{\ensuremath{\mathbb{R}}} \newcommand\RR{\ensuremath{\mathbb{R}}}
\newcommand\CC{\ensuremath{\mathbb{C}}} \newcommand\CC{\ensuremath{\mathbb{C}}}
\newcommand\PP{\ensuremath{\mathbb{P}}}
\newcommand\Oh{\ensuremath{\mathcal{O}}} \newcommand\Oh{\ensuremath{\mathcal{O}}}
\newcommand\oh{\ensuremath{\scriptstyle{\mathcal{O}}}} \newcommand\oh{\ensuremath{\scriptstyle{\mathcal{O}}}}
\newcommand\Eh{\ensuremath{\mathrm{E}}}
\newcommand\Var{\ensuremath{\mathrm{Var}}}
\newcommand\parens[1]{\ensuremath{\left(#1\right)}} \newcommand\parens[1]{\ensuremath{\left(#1\right)}}
\newcommand\brackets[1]{\ensuremath{\left[#1\right]}} \newcommand\brackets[1]{\ensuremath{\left[#1\right]}}
\newcommand\braces[1]{\ensuremath{\left\{#1\right\}}} \newcommand\braces[1]{\ensuremath{\left\{#1\right\}}}
\newcommand\angles[1]{\ensuremath{\langle#1\rangle}} \newcommand\angled[1]{\ensuremath{\left\langle#1\right\rangle}}
\newcommand\tup[1]{\parens{#1}} \newcommand\tup[1]{\parens{#1}}
\newcommand\ivl[1]{\brackets{#1}} \newcommand\ivl[1]{\brackets{#1}}
\newcommand\set[1]{\braces{#1}} \newcommand\set[1]{\braces{#1}}
\newcommand\arr[1]{\angles{#1}} \newcommand\arr[1]{\angled{#1}}
\newcommand\abs[1]{\ensuremath{\lvert#1\rvert}} \newcommand\abs[1]{\ensuremath{\lvert#1\rvert}}
\newcommand\norm[1]{\ensuremath{\lVert#1\rVert}} \newcommand\norm[1]{\ensuremath{\lVert#1\rVert}}
\newcommand\ceil[1]{\ensuremath{\lceil#1\rceil}} \newcommand\ceil[1]{\ensuremath{\lceil#1\rceil}}
\newcommand\floor[1]{\ensuremath{\lfloor#1\rfloor}} \newcommand\floor[1]{\ensuremath{\lfloor#1\rfloor}}
\newcommand\alg[1]{\normalfont\scshape#1\normalfont} \newcommand\alg[2]{{\normalfont\scshape#1}{\normalfont(#2)}}
\newcommand\com[1]{\normalfont\itshape/\!\!/ #1\normalfont} \newcommand\algt[1]{{\normalfont\scshape#1}}
\newcommand\com[1]{{\normalfont\itshape/\!\!/ #1}}
\newenvironment{algorithmic}[1][1em]{ \newenvironment{algorithmic}[1][1em]{
\begin{minipage}[t]{\dimexpr\linewidth} \begin{minipage}[t]{\dimexpr\linewidth}
@ -45,18 +71,38 @@
\end{minipage} \end{minipage}
} }
\newenvironment{algorithm}[1][1em]{ % \newenvironment{algorithm}[1][1em]{
\begin{center} % \begin{center}
\begin{minipage}[t]{\dimexpr\linewidth} % \begin{minipage}[t]{\dimexpr\linewidth}
\bfseries % \bfseries
\begin{tabbing} % \begin{tabbing}
\hspace{#1}\=\hspace{#1}\=\hspace{#1}\=\hspace{#1}\=\hspace{#1}\=\hspace{#1}\=\hspace{#1}\=\hspace{#1}\=\kill % \hspace{#1}\=\hspace{#1}\=\hspace{#1}\=\hspace{#1}\=\hspace{#1}\=\hspace{#1}\=\hspace{#1}\=\hspace{#1}\=\kill
}{% % }{%
\end{tabbing} % \end{tabbing}
\end{minipage} % \end{minipage}
\end{center} % \end{center}
} % }
% \makeatletter
% \newcounter{algorithm}% the counter
% \renewcommand*\thealgorithm{\arabic{algorithm}}% the default format for the counter
% \newcommand*\fps@algorithm{tbp}% default floating options
% \newcommand*\ftype@algorithm{4}% float type number, needs to be a power of 2; % \ftype@figure=1, \ftype@table=2
% \newcommand*\ext@algorithm{loa}% extension of file for the list of schemes
% \newcommand*\fnum@algorithm{\algorithmname\nobreakspace\thealgorithm}% used in caption
% \newcommand*\algorithmname{Algorithmus}% the name
% \newcommand*\listalgorithmname{Algorithmenverzeichnis}% the name of the list
% \newenvironment{algorithm}{\@float{algorithm}}{\end@float}% the environment
% \newenvironment{algorithm*}{\@dblfloat{algorithm}}{\end@dblfloat}% the starred % version for twocolumn documents
% \newcommand*\listofalgorithms{% the list of schemes
% \section*{\listalgorithmname}
% \@mkboth
% {\MakeUppercase\listalgorithmname}
% {\MakeUppercase\listalgorithmname}
% \@starttoc{\ext@algorithm} }
% \let\l@algorithm\l@figure % layout of list is the same as for figures
% \makeatother
%
\newlength{\theoremskip} \newlength{\theoremskip}
\setlength{\theoremskip}{6em} \setlength{\theoremskip}{6em}