\documentclass[%
    12pt,
    a4paper,
    ngerman,
    headheight=29.1pt,
]{scrartcl}

\usepackage[a4paper, left=2.5cm, right=2.5cm, top=3.0cm, bottom=2.5cm]{geometry}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage[ngerman]{babel}
\usepackage[headsepline]{scrlayer-scrpage}
\usepackage[active]{srcltx}
\usepackage{algorithm}
\usepackage[noend]{algorithmic}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{enumerate}
\usepackage{graphicx}
\usepackage{ifthen}
\usepackage{listings}
\usepackage{struktex}
\usepackage[dvipsnames]{xcolor}
\usepackage{tabularx}
\usepackage{eurosym}

\usepackage{hyperref} % <-- ALWAYS include me last!

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%% EDIT THIS PART %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\Fach}{Programmierung und Algorithmen}
\newcommand{\Name}{Erik(a) Mustermensch}
\newcommand{\Seminargruppe}{4}
\newcommand{\Matrikelnummer}{01337}
\newcommand{\Semester}{WS\,24/25}
\newcommand{\Uebungsblatt}{0} %  <-- UPDATE ME FOR EACH SHEET

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\setlength{\parindent}{0em}

%%%%%%%%%%%%%%%
%% Aufgaben-COMMAND
\newcommand{\Aufgabe}[1]{
  {
  \vspace*{0.5cm}
  \textsf{\textbf{Aufgabe #1}}
  \vspace*{0.2cm}
  }
}
%%%%%%%%%%%%%%
\hypersetup{
    pdftitle={\Fach{}: Übungsblatt \Uebungsblatt{}},
    pdfauthor={\Name},
    pdfborder={0 0 0}
}

% see also: https://en.wikibooks.org/wiki/LaTeX/Source_Code_Listings#Style_definition
\lstset{ %
language=java,
basicstyle=\footnotesize\ttfamily,
showtabs=false,
tabsize=2,
captionpos=b,
breaklines=true,
extendedchars=true,
showstringspaces=false,
flexiblecolumns=true,
keywordstyle=\color{RoyalBlue},
commentstyle=\color{OliveGreen},
stringstyle=\color{BrickRed},
% The section below defines how to handle special characters in
% source code. The standard template only handles specific german
% characters (e.g. umlauts and ß). You can add additional rules
% if needed.
literate=%
    {Ö}{{\"O}}1
    {Ä}{{\"A}}1
    {Ü}{{\"U}}1
    {ß}{{\ss}}1
    {ü}{{\"u}}1
    {ä}{{\"a}}1
    {ö}{{\"o}}1
    {ß}{\ss}1
    {€}{\euro}1
}

\title{Übungsblatt \Uebungsblatt{}}
\author{\Name{}}

\begin{document}
\pagestyle{scrheadings}
\lohead{\sffamily \Fach{} \\ \small \Name{} - \Matrikelnummer{}}
\rohead{\sffamily \Semester{} \\  Seminargruppe \Seminargruppe{}}
\pagestyle{plain}
\thispagestyle{scrheadings}
\addtokomafont{pagehead}{\normalfont}
\vspace*{0.2cm}
\begin{center}
\LARGE \sffamily \textbf{Übungsblatt \Uebungsblatt{}}
\end{center}
\vspace*{0.2cm}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Insert your solutions here %%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\Aufgabe{1}

Eine Einführung in \LaTeX{} (Installation, erste Schritte) finden Sie zum Beispiel hier:

\url{https://www.latex-tutorial.com/tutorials/}

\Aufgabe{2}

\begin{enumerate}[a)]
    \item Formeln lassen sich einfach mit zwei \$-Zeichen den Text integrieren: $\frac{a + b}{c} = 1$.
        Für eine längere Formel, die in einer eigenen Zeile stehen soll können doppelte \$-Zeichen verwendet werden:
        %
        $$ \frac{a + b}{c} = 1 \Rightarrow a + b = c $$
        %
    \item Nummerierte Formeln bietet die \emph{equation}-Umgebung:
        \begin{equation}
            (x+y)^n=\sum_{k=0}^n\binom{n}{k}x^ky^{n-k}
            \label{myequation}
        \end{equation}
        Später kann Formel \ref{myequation} referenziert werden.
    \item Mehrzeilige Formeln können durch die \emph{align}-Umgebung realisiert werden:
        \begin{align*}
            ggT(15, 12) &= ggT(3, 12) \\
                        &= ggT(3, 9) \\
                        &= ggT(3, 6) \\
                        &= ggT(3, 3) \\
                        &= 3
        \end{align*}
    Eine sehr umfangreiche Hilfe zu Formeln in \LaTeX{} findet sich unter:
    \url{http://de.wikipedia.org/wiki/Hilfe:TeX}.
\end{enumerate}

\Aufgabe{3}

Quelltexte lassen sich ebenfalls einfach in \LaTeX{} einbetten:
\begin{lstlisting}
public class ForLoop {
  public static void main(String[] args) {
    int factorial = 1;
    for (int count=1; count < 11; count++) {
       System.out.println(factorial *= count);
    }
  }
}
\end{lstlisting}

Auch direkt von einer Datei mit:
\begin{lstlisting}
\lstinputlisting{ForLoop.java}
\end{lstlisting}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}
