\ProvidesClass{lecture}
\LoadClass[a4paper, titlepage]{article}

\RequirePackage[utf8]{inputenc}
\RequirePackage[T1]{fontenc}
\RequirePackage{textcomp}
\RequirePackage[german]{babel}
\RequirePackage{amsmath, amssymb, amsthm}
\RequirePackage{mdframed}
\RequirePackage{fancyhdr}
\RequirePackage{geometry}
\RequirePackage{import}
\RequirePackage{pdfpages}
\RequirePackage{transparent}
\RequirePackage{xcolor}
\RequirePackage{array}
\RequirePackage[shortlabels]{enumitem}
\RequirePackage{tikz}
\RequirePackage{pgfplots}
\RequirePackage[nobottomtitles]{titlesec}
\RequirePackage{listings}
\RequirePackage{mathtools}
\RequirePackage{forloop}
\RequirePackage{totcount}

\usetikzlibrary{quotes, angles}

\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\DeclareOption{uebung}{
    \makeatletter
    \lhead{\@title}
    \rhead{\@author}
    \makeatother
}
\ProcessOptions\relax

% PAGE GEOMETRY
\geometry{
    left=15mm,
    right=40mm,
    top=20mm,
    bottom=20mm
}

% PARAGRAPH no indent but skip
\setlength{\parskip}{3mm}
\setlength{\parindent}{0mm}

\theoremstyle{definition}
\newmdtheoremenv{satz}{Satz}[section]
\newmdtheoremenv{lemma}[satz]{Lemma}
\newmdtheoremenv{korrolar}[satz]{Korrolar}
\newmdtheoremenv{definition}[satz]{Definition}

\newtheorem{bsp}[satz]{Beispiel}
\newtheorem{bem}[satz]{Bemerkung}
\newtheorem{aufgabe}{Aufgabe}

% enable aufgaben counting
\regtotcounter{aufgabe}

\newcommand{\N}{\mathbb{N}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\C}{\mathbb{C}}

% HEADERS

\pagestyle{fancy}

\newcommand{\incfig}[1]{%
    \def\svgwidth{\columnwidth}
    \import{./figures/}{#1.pdf_tex}
}
\pdfsuppresswarningpagegroup=1

% horizontal rule
\newcommand\hr{
    \noindent\rule[0.5ex]{\linewidth}{0.5pt}
}

% punkte tabelle
\newcommand{\punkte}{
    \@punkten{\totvalue{aufgabe}}
}

\def\@punkten#1{
    \newcounter{n}
    \begin{tabular}{|c|*{#1}{m{1cm}|}m{1cm}|@{}m{0cm}@{}}
        \hline
        Aufgabe
        \forloop{n}{1}{\not{\value{n} > #1}}{
            & \centering A\then
        }
        & \centering $\sum$ & \\[5mm] \hline
        Punkte
        \forloop{n}{1}{\not{\value{n} > #1}}{
            &
        }
        & & \\[5mm] \hline
    \end{tabular}
}

% code listings, define style
\lstdefinestyle{mystyle}{
    commentstyle=\color{gray},
    keywordstyle=\color{blue},
    numberstyle=\tiny\color{gray},
    stringstyle=\color{black},
    basicstyle=\ttfamily\footnotesize,
    breakatwhitespace=false,         
    breaklines=true,                 
    captionpos=b,                    
    keepspaces=true,                 
    numbers=left,                    
    numbersep=5pt,                  
    showspaces=false,                
    showstringspaces=false,
    showtabs=false,                  
    tabsize=2
}

% activate my colour style
\lstset{style=mystyle}

% better stackrel
\let\oldstackrel\stackrel
\renewcommand{\stackrel}[2]{%
    \oldstackrel{\mathclap{#1}}{#2}
}%

% integral d sign
\makeatletter \renewcommand\d[1]{\ensuremath{%
  \;\mathrm{d}#1\@ifnextchar\d{\!}{}}}
\makeatother
