%% LyX 2.4.4 created this file.  For more info, see https://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[12pt,ngerman]{book}
\usepackage{amsmath}
\usepackage{amsthm}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\pagestyle{headings}

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
\newlength{\lyxlabelwidth}      % auxiliary length 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
% -*- coding: utf-8 -*-
% Test-Dokument für alle definierten Umgebungen und Funktionen



% ===============================
% Präambel aus dem Setup
% ===============================

\nonstopmode

\usepackage{atbegshi}

% 1. DATEI-HANDLING & BASIS
\usepackage{zref-user,zref-abspage}
\newsavebox{\tsmSilentBox}
\newwrite\tsmidxfile
\immediate\openout\tsmidxfile=\jobname.idx
\newwrite\tsmtestfile
\immediate\openout\tsmtestfile=\jobname.test

\usepackage{pdflscape}
\usepackage{longtable}
\usepackage{booktabs} % Für professionelle Tabellenlinien
\usepackage{array, booktabs}
\usepackage[table]{xcolor}

% 2. LUA-WÄCHTER (Blacklist-Logik)
\directlua{
    blacklist = {}
    local f = io.open("blacklist.txt", "r")
    if f then
        for line in f:lines() do
            if line ~= "" then table.insert(blacklist, line) end
        end
        f:close()
    end
    function is_blacklisted(label)
        for _, word in ipairs(blacklist) do
            if label:find(word) then return true end
        end
        return false
    end
}

% 3. DIE LOGIK-MASCHINE
\makeatletter
\newcommand{\tsmGoto}[1]{\hyperlink{page.#1}{#1}}

\makeatletter
\newcommand{\tsmWriteToIndex}[2]{%
    \sbox{\tsmSilentBox}{%
        \cleanLyXTitleTSM{#2}%
        \cleanLyXTitleTSMA{#2}%
    }%
    % Wir setzen den Anker VOR dem Schreiben
    \zlabel{idx-#2}%
    %
    % Wir prüfen, ob der Wert überhaupt schon existiert (Schutz vor Absturz)
    \edef\tsm@currentAbsPage{\zref@extractdefault{idx-#2}{abspage}{0}}%
    %
    \immediate\write\tsmidxfile{%
        \string\indexentry{\tsm@cleanOutputA @ \string\textbf{#1}: \tsm@cleanOutput | \string\tsmGoto}{\tsm@currentAbsPage}%
    }%
    \immediate\write\tsmtestfile{Typ: #1 | ID: #2 | Seite: \tsm@currentAbsPage}%
}
\makeatother

\newcommand{\tsmInstallLabelTrap}[1]{%
    \let\oldlabel\label
    \renewcommand{\label}[2][]{%
        \oldlabel{##2}%
        \zlabel{idx-##2}%
        \begingroup%
            \directlua{
                if not is_blacklisted("\luaescapestring{##2}") then
                    tex.sprint("\string\\tsmWriteToIndex{#1}{##2}")
                else
                    tex.sprint("\string\\immediate\string\\write\string\\tsmtestfile{FILTERED: ##2}")
                end
            }
        \endgroup%
        \ignorespaces%
    }%
}
\makeatother


% ===== Structurbaume =====
\usepackage{tikz}
\usepackage{graphicx}

\usetikzlibrary{shapes.geometric, arrows, positioning, calc}
\usepackage{forest}
\usepackage{stmaryrd}

% ===== Grundschrift und Typografie =====
\usepackage{newpxtext,newpxmath}   % Palatino + passende Mathematik
\usepackage{microtype}             % optischer Randausgleich, bessere Umbrüche
\usepackage{setspace}              % Zeilenabstände ggf. einstellbar
\usepackage{csquotes}              % für Zitate

% ===== Wichtige Begriffe =====
\newcommand{\important}[1]{\textbf{\textit{#1}}}

% ===== Silbentrennung / schwierige Wörter =====
\hyphenation{Ab-neh-men-den Nah-me Fle-der-mau-se Band-wurm Web-adress}

\newif\ifreview
\reviewfalse

% Farben und Boxen
\usepackage{xcolor}
% \usepackage[most]{tcolorbox}



\tcbset{
  colback=blue!5,
  colframe=blue!50!black,
  boxrule=0.5pt,
  arc=2mm,
  left=2mm,
  right=2mm,
  top=1mm,
  bottom=1mm,
  fonttitle=\bfseries
}
% --- Pakete ---
\usepackage{amsthm}     % für Definitionen, Sätze, Lemmas
\usepackage{xcolor}     % Farben
\usepackage{mdframed}   % Boxen
\usepackage{etoolbox}   % für Patchen / neue Umgebung

% --- Standard-Theorem-Umgebungen ---
\newtheorem{definition}{Definition}[chapter]
\newtheorem{satz}{Satz}[chapter]
\newtheorem{lemma}{Lemma}[chapter]
\newtheorem{korollar}{Korollar}[chapter]
\newtheorem{remark}{Remark}[chapter]
\newtheorem*{beweis}{Beweis}

% --- mdframed Styles ---
\mdfdefinestyle{definitionstyle}{
  linecolor=blue, linewidth=1pt, backgroundcolor=blue!10,
  roundcorner=5pt, innertopmargin=2mm, innerbottommargin=2mm,
  skipabove=5pt, skipbelow=5pt
  nobreak=true  % <--- Dies verhindert den Seitenumbruch innerhalb der Box
}

\mdfdefinestyle{satzstyle}{
  linecolor=red, linewidth=1pt, backgroundcolor=red!10,
  roundcorner=5pt, innertopmargin=2mm, innerbottommargin=2mm,
  skipabove=5pt, skipbelow=5pt
  nobreak=true  % <--- Dies verhindert den Seitenumbruch innerhalb der Box
}

\mdfdefinestyle{lemmastyle}{
  linecolor=orange, linewidth=1pt, backgroundcolor=orange!10,
  roundcorner=5pt, innertopmargin=2mm, innerbottommargin=2mm,
  skipabove=5pt, skipbelow=5pt
  nobreak=true  % <--- Dies verhindert den Seitenumbruch innerhalb der Box
}

\mdfdefinestyle{korollarstyle}{
  linecolor=green!50!black, linewidth=1pt, backgroundcolor=green!10,
  roundcorner=5pt, innertopmargin=2mm, innerbottommargin=2mm,
  skipabove=5pt, skipbelow=5pt
  nobreak=true  % <--- Dies verhindert den Seitenumbruch innerhalb der Box
}

\mdfdefinestyle{remarkstyle}{
  linecolor=gray, linewidth=1pt, backgroundcolor=gray!10,
  roundcorner=5pt, innertopmargin=2mm, innerbottommargin=2mm,
  skipabove=5pt, skipbelow=5pt
  nobreak=true  % <--- Dies verhindert den Seitenumbruch innerhalb der Box
}


%++++++++++++++++++++++
\makeatletter


% Die Reinigungs-Maschine für LyX-Labels
\newcommand{\cleanLyXTitleTSM}[1]{%
    % 1. Präfix entfernen
    \StrSubstitute{#1}{satz:}{}[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{lem:}{ }[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{def:}{ }[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{cor:}{ }[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{rem:}{ }[\tsm@temp]%
    % --- Mathematische & Physikalische Konstanten (TSM-Kern) ---
    \StrSubstitute{\tsm@temp}{=000394}{Δ}[\tsm@temp]% Großes Delta (Differenz/Abweichung)
    \StrSubstitute{\tsm@temp}{=0003C4}{τ}[\tsm@temp]% Tau (Resonanzzeit / Rückholterm)
     % --- Griechische Buchstaben (Unicode-Ebene) ---
    \StrSubstitute{\tsm@temp}{=0003B1}{α}[\tsm@temp]% alpha
    \StrSubstitute{\tsm@temp}{=0003B2}{β}[\tsm@temp]% beta
    \StrSubstitute{\tsm@temp}{=0003B3}{γ}[\tsm@temp]% gamma
    \StrSubstitute{\tsm@temp}{=0003B4}{δ}[\tsm@temp]% delta
    \StrSubstitute{\tsm@temp}{=0003BC}{μ}[\tsm@temp]% mu
    \StrSubstitute{\tsm@temp}{=0003C0}{π}[\tsm@temp]% pi
    \StrSubstitute{\tsm@temp}{=0003C3}{σ}[\tsm@temp]% sigma
    \StrSubstitute{\tsm@temp}{=0003C9}{ω}[\tsm@temp]% omega

    % --- Mathematische Operatoren & Symbole ---
    \StrSubstitute{\tsm@temp}{=002206}{Δ}[\tsm@temp]% Delta (Differenz)
    \StrSubstitute{\tsm@temp}{=00221E}{∞}[\tsm@temp]% Unendlich
    \StrSubstitute{\tsm@temp}{=002248}{≈}[\tsm@temp]% Ungefähr

    % 2. Umlaute & Scharfes S (Hex-Verschlüsselung)
    \StrSubstitute{\tsm@temp}{=0000E4}{ä}[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=0000F6}{ö}[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=0000FC}{ü}[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=0000C4}{Ä}[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=0000D6}{Ö}[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=0000DC}{Ü}[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=0000DF}{ß}[\tsm@temp]%

    % 3. Sonderzeichen & Interpunktion
    \StrSubstitute{\tsm@temp}{=000021}{!}[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=00003F}{?}[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=00002E}{.}[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=00002C}{,}[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=00003A}{:}[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=00003B}{;}[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=000028}{(}[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=000029}{)}[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=00002D}{-}[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=00002F}{/}[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=000022}{"}[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=000027}{'}[\tsm@temp]%

    % 4. Formatierungs-Relikte & Leerzeichen
    \StrSubstitute{\tsm@temp}{_}{ }[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=000020}{ }[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=}{}[\tsm@temp]% (Restliche Gleichheitszeichen entfernen)

    % 5. Globale Manifestation
    \global\let\tsm@cleanOutput\tsm@temp
}



\newcommand{\cleanLyXTitleTSMA}[1]{%
    % Wir nutzen \StrSubstitute direkt für die Zuweisung.
    % Wichtig: Jedes Mal das vierte Argument (die Variable) nutzen!
    \StrSubstitute{#1}{satz:}{ }[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{lem:}{ }[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{def:}{ }[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{cor:}{ }[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{rem:}{ }[\tsm@temp]%
    % --- Mathematische & Physikalische Konstanten (TSM-Kern) ---
    \StrSubstitute{\tsm@temp}{=000394}{Δ}[\tsm@temp]% Großes Delta (Differenz/Abweichung)
    \StrSubstitute{\tsm@temp}{=0003C4}{τ}[\tsm@temp]% Tau (Resonanzzeit / Rückholterm)
    % --- Griechische Buchstaben (Unicode-Ebene) ---
    \StrSubstitute{\tsm@temp}{=0003B1}{α}[\tsm@temp]% alpha
    \StrSubstitute{\tsm@temp}{=0003B2}{β}[\tsm@temp]% beta
    \StrSubstitute{\tsm@temp}{=0003B3}{γ}[\tsm@temp]% gamma
    \StrSubstitute{\tsm@temp}{=0003B4}{δ}[\tsm@temp]% delta
    \StrSubstitute{\tsm@temp}{=0003BC}{μ}[\tsm@temp]% mu
    \StrSubstitute{\tsm@temp}{=0003C0}{π}[\tsm@temp]% pi
    \StrSubstitute{\tsm@temp}{=0003C3}{σ}[\tsm@temp]% sigma
    \StrSubstitute{\tsm@temp}{=0003C9}{ω}[\tsm@temp]% omega

    % --- Mathematische Operatoren & Symbole ---
    \StrSubstitute{\tsm@temp}{=002206}{Δ}[\tsm@temp]% Delta (Differenz)
    \StrSubstitute{\tsm@temp}{=00221E}{∞}[\tsm@temp]% Unendlich
    \StrSubstitute{\tsm@temp}{=002248}{≈}[\tsm@temp]% Ungefähr
    % 2. Umlaute & Scharfes S (Hex-Verschlüsselung)
    \StrSubstitute{\tsm@temp}{=0000E4}{ä}[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=0000F6}{ö}[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=0000FC}{ü}[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=0000C4}{Ä}[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=0000D6}{Ö}[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=0000DC}{Ü}[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=0000DF}{ß}[\tsm@temp]%

    % 3. Sonderzeichen & Interpunktion
    \StrSubstitute{\tsm@temp}{=000021}{!}[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=00003F}{?}[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=00002E}{.}[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=00002C}{,}[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=00003A}{:}[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=00003B}{;}[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=000028}{(}[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=000029}{)}[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=00002D}{-}[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=00002F}{/}[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=000022}{"}[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=000027}{'}[\tsm@temp]%

    % 4. Formatierungs-Relikte & Leerzeichen
    \StrSubstitute{\tsm@temp}{_}{ }[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=000020}{ }[\tsm@temp]%
    \StrSubstitute{\tsm@temp}{=}{}[\tsm@temp]% (Restliche Gleichheitszeichen entfernen)
    % 3. ELIMINIERUNG VON FÜLLWÖRTERN (Scharfe Analyse)
    % Wir setzen Leerzeichen um die Wörter, um Teilwort-Fehler zu vermeiden
    % (z.B. damit "Der" in "Dermatologie" nicht gelöscht wird).
    \StrSubstitute{ \tsm@temp\space}{ Der }{ }[\tsm@temp]%
    \StrSubstitute{ \tsm@temp\space}{ Die }{ }[\tsm@temp]%
    \StrSubstitute{ \tsm@temp\space}{ Das }{ }[\tsm@temp]%
    \StrSubstitute{ \tsm@temp\space}{ Ein }{ }[\tsm@temp]%
    \StrSubstitute{ \tsm@temp\space}{ Eine }{ }[\tsm@temp]%
    \StrSubstitute{ \tsm@temp\space}{ Einer }{ }[\tsm@temp]%
    \StrSubstitute{ \tsm@temp\space}{ eines }{ }[\tsm@temp]%
    \StrSubstitute{ \tsm@temp\space}{ einer }{ }[\tsm@temp]%
    \StrSubstitute{ \tsm@temp\space}{ der }{ }[\tsm@temp]%
    \StrSubstitute{ \tsm@temp\space}{ die }{ }[\tsm@temp]%
    \StrSubstitute{ \tsm@temp\space}{ das }{ }[\tsm@temp]%

    % 4. Bereinigung von Doppel-Leerzeichen, die durch das Löschen entstanden sind
    \StrSubstitute{\tsm@temp}{ }{}[\tsm@temp]%
    % Führende/anhängende Leerzeichen entfernen (Trim)
    \StrSubstitute{\tsm@temp}{  }{}[\tsm@temp]% (Doppelte Leerzeichen zu einem)
    % 5. Globale Manifestation der Erkenntnis
    \global\let\tsm@cleanOutputA\tsm@temp
}

\makeatother
% --- Neue Umgebungen, die mdframed + Theorem kombinieren ---
\makeatletter
% BEISPIEL FÜR EINE BOX (Wiederhole dies für Lemma, Korollar, etc.)
\renewenvironment{SatzBox}[1][]{%
    \begin{mdframed}[style=satzstyle]%
    \begin{satz}[#1]%
    \tsmInstallLabelTrap{Satz}% <-- Die Falle für den Index
}{%
    \end{satz}%
    \end{mdframed}%
}

% BEISPIEL FÜR EINE BOX (Wiederhole dies für Lemma, Korollar, etc.)
\renewenvironment{DefinitionBox}[1][]{%
    \begin{mdframed}[style=definitionstyle]%
    \begin{definition}[#1]%
    \tsmInstallLabelTrap{Definition}% <-- Die Falle für den Index
}{%
    \end{definition}%
    \end{mdframed}%
}

% BEISPIEL FÜR EINE BOX (Wiederhole dies für Lemma, Korollar, etc.)
\renewenvironment{LemmaBox}[1][]{%
    \begin{mdframed}[style=lemmastyle]%
    \begin{lemma}[#1]%
    \tsmInstallLabelTrap{Lemma}% <-- Die Falle für den Index
}{%
    \end{lemma}%
    \end{mdframed}%
}

% BEISPIEL FÜR EINE BOX (Wiederhole dies für Lemma, Korollar, etc.)
\renewenvironment{KorollarBox}[1][]{%
    \begin{mdframed}[style=korollarstyle]%
    \begin{korollar}[#1]%
    \tsmInstallLabelTrap{Korollar}% <-- Die Falle für den Index
}{%
    \end{korollar}%
    \end{mdframed}%
}

% BEISPIEL FÜR EINE BOX (Wiederhole dies für Lemma, Korollar, etc.)
\renewenvironment{RemarkBox}[1][]{%
    \begin{mdframed}[style=remarkstyle]%
    \begin{remark}[#1]%
    \tsmInstallLabelTrap{Anmerkung}% <-- Die Falle für den Index
}{%
    \end{remark}%
    \end{mdframed}%
}

\newenvironment{RemarkBox}[1][]{
  \begin{mdframed}[style=remarkstyle]
  \begin{remark}[#1]
}{
  \end{remark}
  \end{mdframed}
}
\makeatletter

\makeatother

%--------------------

% Box-Umgebung (mybox)
\newtcolorbox{mybox}[1][]{title=#1}
\tcbuselibrary{breakable}

% Todos
\ifreview
  \usepackage{pdfcomment}
\newcommand{\todo}[1]{\pdfcomment{#1}}
\else
  \usepackage[color=yellow!40]{todonotes}

  %======= Todos richtige Breite ====
\setlength{\marginparwidth}{2cm}
\setlength{\marginparsep}{0.5cm}

\fi

% Sprache & Encoding
\usepackage[ngerman]{babel}


% Kopf- und Fußzeilen
\usepackage{fancyhdr}

\fancyhf{}
\fancyhead[L]{\leftmark}
\fancyhead[R]{\thepage}
\renewcommand{\headrulewidth}{0.4pt}

\usepackage{listings}
\usepackage{xcolor}  % für Farben

% Farben
\definecolor{bgcolor}{RGB}{248,248,248}       % Hintergrund hellgrau
\definecolor{keywordblue}{RGB}{0,0,180}       % Keywords
\definecolor{stringred}{RGB}{163,21,21}       % Strings
\definecolor{commentgreen}{RGB}{0,128,0}      % Kommentare
\definecolor{numberpurple}{RGB}{128,0,128}    % Zahlen

% --------------------- Python ---------------------
\lstdefinestyle{PythonStyle}{
    language=Python,
    backgroundcolor=\color{bgcolor},
    keywordstyle=\color{keywordblue}\bfseries,
    stringstyle=\color{stringred},
    commentstyle=\color{commentgreen}\itshape,
    numberstyle=\tiny\color{numberpurple},
    numbers=left, numbersep=5pt,
    showstringspaces=false, tabsize=4, breaklines=true,
    frame=single, basicstyle=\ttfamily\footnotesize
}

% --------------------- C/C++ ---------------------
\lstdefinestyle{CppStyle}{
    language=C++, backgroundcolor=\color{bgcolor},
    keywordstyle=\color{keywordblue}\bfseries,
    stringstyle=\color{stringred}, commentstyle=\color{commentgreen}\itshape,
    numberstyle=\tiny\color{numberpurple}, numbers=left, numbersep=5pt,
    showstringspaces=false, tabsize=4, breaklines=true,
    frame=single, basicstyle=\ttfamily\footnotesize
}

% --------------------- Java ---------------------
\lstdefinestyle{JavaStyle}{
    language=Java, backgroundcolor=\color{bgcolor},
    keywordstyle=\color{keywordblue}\bfseries,
    stringstyle=\color{stringred}, commentstyle=\color{commentgreen}\itshape,
    numberstyle=\tiny\color{numberpurple}, numbers=left, numbersep=5pt,
    showstringspaces=false, tabsize=4, breaklines=true,
    frame=single, basicstyle=\ttfamily\footnotesize
}

% --------------------- SQL ---------------------
\lstdefinestyle{SQLStyle}{
    language=SQL, backgroundcolor=\color{bgcolor},
    keywordstyle=\color{keywordblue}\bfseries,
    stringstyle=\color{stringred}, commentstyle=\color{commentgreen}\itshape,
    numberstyle=\tiny\color{numberpurple}, numbers=left, numbersep=5pt,
    showstringspaces=false, tabsize=4, breaklines=true,
    frame=single, basicstyle=\ttfamily\footnotesize
}

% --------------------- HTML ---------------------
\lstdefinestyle{HTMLStyle}{
    language=HTML, backgroundcolor=\color{bgcolor},
    keywordstyle=\color{keywordblue}\bfseries,
    stringstyle=\color{stringred}, commentstyle=\color{commentgreen}\itshape,
    numberstyle=\tiny\color{numberpurple}, numbers=left, numbersep=5pt,
    showstringspaces=false, tabsize=4, breaklines=true,
    frame=single, basicstyle=\ttfamily\footnotesize
}

% --------------------- XML (überarbeitet) ---------------------
\lstdefinelanguage{XML}{
    morestring=[b]",                     % Strings in Attributen
    morecomment=[s]{<!--}{-->},          % Kommentare
    stringstyle=\color{stringred},
    commentstyle=\color{commentgreen}\itshape,
    keywordstyle=\color{keywordblue}\bfseries,
    morekeywords={note,to,from,message,body,html,head,title,div,span,p,a}, % typische Tags
    sensitive=true
}

\lstdefinestyle{XMLStyle}{
    language=XML,
    backgroundcolor=\color{bgcolor},
    keywordstyle=\color{keywordblue}\bfseries,
    stringstyle=\color{stringred},
    commentstyle=\color{commentgreen}\itshape,
    numberstyle=\tiny\color{numberpurple},
    numbers=left,
    numbersep=5pt,
    showstringspaces=false,
    tabsize=4,
    breaklines=true,
    frame=single,
    basicstyle=\ttfamily\footnotesize
}


% --------------------- Ruby ---------------------
\lstdefinestyle{RubyStyle}{
    language=Ruby, backgroundcolor=\color{bgcolor},
    keywordstyle=\color{keywordblue}\bfseries,
    stringstyle=\color{stringred}, commentstyle=\color{commentgreen}\itshape,
    numberstyle=\tiny\color{numberpurple}, numbers=left, numbersep=5pt,
    showstringspaces=false, tabsize=4, breaklines=true,
    frame=single, basicstyle=\ttfamily\footnotesize
}

% --------------------- Perl ---------------------
\lstdefinestyle{PerlStyle}{
    language=Perl, backgroundcolor=\color{bgcolor},
    keywordstyle=\color{keywordblue}\bfseries,
    stringstyle=\color{stringred}, commentstyle=\color{commentgreen}\itshape,
    numberstyle=\tiny\color{numberpurple}, numbers=left, numbersep=5pt,
    showstringspaces=false, tabsize=4, breaklines=true,
    frame=single, basicstyle=\ttfamily\footnotesize
}

% --------------------- Go ---------------------
\lstdefinelanguage{Go}{
  keywords={func, package, import, var, const, if, else, for, return, struct, type, interface},
  sensitive=true, morecomment=[l]{//}, morecomment=[s]{/*}{*/}, morestring=[b]", morestring=[b]'
}
\lstdefinestyle{GoStyle}{language=Go, backgroundcolor=\color{bgcolor},
    keywordstyle=\color{keywordblue}\bfseries,
    stringstyle=\color{stringred}, commentstyle=\color{commentgreen}\itshape,
    numberstyle=\tiny\color{numberpurple}, numbers=left, numbersep=5pt,
    showstringspaces=false, tabsize=4, breaklines=true,
    frame=single, basicstyle=\ttfamily\footnotesize
}

% --------------------- Haskell (überarbeitet) ---------------------
\lstdefinelanguage{Haskell}{
  keywords={data, type, let, in, where, if, then, else, case, of, module, import, do, class, instance},
  sensitive=true,
  morecomment=[l]{--},          % einzeilige Kommentare
  morecomment=[s]{\{-}{-\}},    % mehrzeilige Kommentare
  morestring=[b]",              % Strings mit "
  morestring=[b]',
}

\lstdefinestyle{HaskellStyle}{
    language=Haskell,
    backgroundcolor=\color{bgcolor},
    keywordstyle=\color{keywordblue}\bfseries,
    stringstyle=\color{stringred},
    commentstyle=\color{commentgreen}\itshape,
    numberstyle=\tiny\color{numberpurple},
    numbers=left,
    numbersep=5pt,
    showstringspaces=false,
    tabsize=4,
    breaklines=true,
    frame=single,
    basicstyle=\ttfamily\footnotesize
}


% --------------------- Lua ---------------------
\lstdefinelanguage{Lua}{
  keywords={function, local, if, then, else, end, for, in, do, while, repeat, until, return},
  sensitive=true, morecomment=[l]{--}, morestring=[b]"
}
\lstdefinestyle{LuaStyle}{language=Lua, backgroundcolor=\color{bgcolor},
    keywordstyle=\color{keywordblue}\bfseries,
    stringstyle=\color{stringred}, commentstyle=\color{commentgreen}\itshape,
    numberstyle=\tiny\color{numberpurple}, numbers=left, numbersep=5pt,
    showstringspaces=false, tabsize=4, breaklines=true,
    frame=single, basicstyle=\ttfamily\footnotesize
}

% --------------------- Oz (überarbeitet) ---------------------
\lstdefinelanguage{Oz}{
  keywords={declare, fun, proc, local, if, then, else, case, of, end, import, for, in, do},
  sensitive=true,
  morecomment=[l]{%},          % einzeilige Kommentare
  morecomment=[s]{/*}{*/},     % mehrzeilige Kommentare
  morestring=[b]",             % Strings mit "
  morestring=[b]',
  morestring=[d]{`}{`},        % optionale Oz Backticks
  alsoletter={-}                % für Wörter mit Bindestrich
}

\lstdefinestyle{OzStyle}{
    language=Oz,
    backgroundcolor=\color{bgcolor},
    keywordstyle=\color{keywordblue}\bfseries,
    stringstyle=\color{stringred},
    commentstyle=\color{commentgreen}\itshape,
    numberstyle=\tiny\color{numberpurple},
    numbers=left,
    numbersep=5pt,
    showstringspaces=false,
    tabsize=4,
    breaklines=true,
    frame=single,
    basicstyle=\ttfamily\footnotesize
}


% --------------------- Prolog (überarbeitet) ---------------------
\lstdefinelanguage{Prolog}{
  keywords={:-, consult, assert, retract, is, write, read, if, then, else, true, false, fail},
  sensitive=true,
  morecomment=[l]{%},          % Kommentare mit %
  morestring=[b]",             % Strings in "
  morestring=[b]',
  alsoletter={-}                % für Atome mit Bindestrich
}

\lstdefinestyle{PrologStyle}{
    language=Prolog,
    backgroundcolor=\color{bgcolor},
    keywordstyle=\color{keywordblue}\bfseries,
    stringstyle=\color{stringred},
    commentstyle=\color{commentgreen}\itshape,
    numberstyle=\tiny\color{numberpurple},
    numbers=left,
    numbersep=5pt,
    showstringspaces=false,
    tabsize=4,
    breaklines=true,
    frame=single,
    basicstyle=\ttfamily\footnotesize
}


% --------------------- Scala ---------------------
\lstdefinelanguage{Scala}{
  keywords={object, class, def, val, var, if, else, for, while, yield, import},
  sensitive=true, morecomment=[l]{//}, morecomment=[s]{/*}{*/}, morestring=[b]"
}
\lstdefinestyle{ScalaStyle}{language=Scala, backgroundcolor=\color{bgcolor},
    keywordstyle=\color{keywordblue}\bfseries,
    stringstyle=\color{stringred}, commentstyle=\color{commentgreen}\itshape,
    numberstyle=\tiny\color{numberpurple}, numbers=left, numbersep=5pt,
    showstringspaces=false, tabsize=4, breaklines=true,
    frame=single, basicstyle=\ttfamily\footnotesize
}

% --------------------- Basic ---------------------
\lstdefinelanguage{Basic}{
  keywords={DIM, IF, THEN, ELSE, FOR, NEXT, WHILE, WEND, GOSUB, RETURN, FUNCTION, END},
  sensitive=false, morecomment=[l]{'}, morestring=[b]"
}
\lstdefinestyle{BasicStyle}{language=Basic, backgroundcolor=\color{bgcolor},
    keywordstyle=\color{keywordblue}\bfseries,
    stringstyle=\color{stringred}, commentstyle=\color{commentgreen}\itshape,
    numberstyle=\tiny\color{numberpurple}, numbers=left, numbersep=5pt,
    showstringspaces=false, tabsize=4, breaklines=true,
    frame=single, basicstyle=\ttfamily\footnotesize
}

% --------------------- Delphi ---------------------
\lstdefinelanguage{Delphi}{
  keywords={begin, end, var, const, type, procedure, function, if, then, else, for, while, do},
  sensitive=false, morecomment=[l]{//}, morecomment=[s]{(*}{*)}, morestring=[b]'
}
\lstdefinestyle{DelphiStyle}{language=Delphi, backgroundcolor=\color{bgcolor},
    keywordstyle=\color{keywordblue}\bfseries,
    stringstyle=\color{stringred}, commentstyle=\color{commentgreen}\itshape,
    numberstyle=\tiny\color{numberpurple}, numbers=left, numbersep=5pt,
    showstringspaces=false, tabsize=4, breaklines=true,
    frame=single, basicstyle=\ttfamily\footnotesize
}

% --------------------- Pascal ---------------------
\lstdefinestyle{PascalStyle}{
    language=Pascal, backgroundcolor=\color{bgcolor},
    keywordstyle=\color{keywordblue}\bfseries,
    stringstyle=\color{stringred}, commentstyle=\color{commentgreen}\itshape,
    numberstyle=\tiny\color{numberpurple}, numbers=left, numbersep=5pt,
    showstringspaces=false, tabsize=4, breaklines=true,
    frame=single, basicstyle=\ttfamily\footnotesize
}

% --------------------- JavaScript (überarbeitet) ---------------------
\lstdefinelanguage{JavaScript}{
  keywords={break, case, catch, class, const, continue, debugger, default, delete,
            do, else, export, extends, finally, for, function, if, import, in,
            instanceof, let, new, return, super, switch, this, throw, try, typeof,
            var, void, while, with, yield},
  sensitive=true,
  morecomment=[l]{//},         % einzeilige Kommentare
  morecomment=[s]{/*}{*/},     % mehrzeilige Kommentare
  morestring=[b]",             % Strings mit "
  morestring=[b]'              % Strings mit '
}

\lstdefinestyle{JsStyle}{
    language=JavaScript,
    backgroundcolor=\color{bgcolor},
    keywordstyle=\color{keywordblue}\bfseries,
    stringstyle=\color{stringred},
    commentstyle=\color{commentgreen}\itshape,
    numberstyle=\tiny\color{numberpurple},
    numbers=left,
    numbersep=5pt,
    showstringspaces=false,
    tabsize=4,
    breaklines=true,
    frame=single,
    basicstyle=\ttfamily\footnotesize
}

% ===== Zitation & Bibliographie =====
\usepackage[backend=biber,
            style=authoryear,
            url=true,
            doi=true,
            hyperref=true]{biblatex}
\addbibresource{LiteraturBeispiel.bib}

% URLs und DOIs sauber umbrechen
\usepackage{url}
\def\UrlBreaks{\do\/\do-\do.}     % erlaubt Umbruch an / - .
\usepackage[hidelinks]{hyperref}  % klickbare Links ohne sichtbare Boxen/Farben

% Feldformatierungen für BibLaTeX
\DeclareFieldFormat{url}{\url{#1}}
\DeclareFieldFormat{doi}{\url{https://doi.org/#1}}

% ===== Seitenlayout & Ränder =====
\usepackage[inner=3.5cm,outer=2.5cm,top=3cm,bottom=3cm]{geometry}

% ===== Farbige Kopf- und Fußzeilen =====
\usepackage{fancyhdr}
\usepackage{xcolor}
\usepackage{ifthen}

\pagestyle{fancy}
\fancyhf{} % alles leeren

% ===== Kopfzeilen =====
\fancyhead[LE]{\textcolor{blue}{\TitelName}}
\fancyhead[RO]{\textcolor{purple}{%
    \ifthenelse{\isundefined{\rightmark}}{Abschnitt}{\rightmark}%
}}
\fancyhead[C]{\textcolor{gray}{\DatumHeute}}

% ===== Fußzeilen =====
\fancyfoot[LE]{\textcolor{brown}{\AutorName}}
\fancyfoot[RE]{\textcolor{black}{\thepage}}
\fancyfoot[C]{}

% ===== Linien =====
\renewcommand{\headrulewidth}{0.6pt}
\renewcommand{\footrulewidth}{0.4pt}

\newcommand{\important}[1]{\textbf{\textit{#1}}}

% =========== Tabellen =====
\usepackage{rotating} % Dies muss in die Präambel deines Dokuments!
\usepackage{tabularx}

\AtEndDocument{
    \immediate\closeout\tsmidxfile
    \immediate\closeout\tsmtestfile
    \clearpage % Erzwingt das Herausschreiben aller restlichen Seiten
    \IfFileExists{\jobname.ind}{%
        \begin{center}
            \rule{0.5\textwidth}{0.4pt} % Eine feine Trennlinie (Säulen-Metapher)
        \end{center}
        \input{\jobname.ind}
    }{}
}

\usepackage[ngerman]{babel}

% ===============================
% Dokument
% ===============================

\makeatother

\usepackage{babel}
\usepackage[style=authoryear]{biblatex}
\begin{document}
\begin{table}[h] \centering \small \begin{tabularx}{\textwidth}{|p{2.5cm}|c|c|X|} \hline \textbf{Akteur} & \textbf{VUI-Wert} & \textbf{Dämpfung (d)} & \textbf{TSM-Klassifizierung} \ \hline \textbf{R. Habeck} & 0.85 & Hoch (integral) & \textit{Deliberative Resonanz} – Sucht vertikale Bindung, oft diagonal gebremst. \ \hline \textbf{O. Scholz} & 0.32 & Maximal (ext.) & \textit{Technokratische Latenz} – Horizontale Verzögerung ohne τ-Gewinn. \ \hline \textbf{D. Trump} & 0.04 & ≈0 & \textit{Resonanzkatastrophe} – Maximale horizontale Amplitude, τ-Kollaps. \ \hline \textbf{KI (GPT/Gemini)} & 0.00 & Simulation & \textit{Interpolations-Maschine} – Systemischer Ausschluss von τ und Anti-Zone. \ \hline \end{tabularx} \caption{Vergleichende Souveränitäts-Matrix im META-01-System} \end{table}
\end{document}
