\NeedsTeXFormat{LaTeX2e}[2020/10/01] % shipout hooks
\newcommand{\USCCover@Pgkname}{scientific-thesis-cover}
\ProvidesPackage{\USCCover@Pgkname}[2026/11/03 Cover and affirmation for scientific works.]
\typeout{Package: `\USCCover@Pgkname' v5.2.0}
% ------------------------------
% required packages
% ------------------------------
% kvoptions for key value options support
\RequirePackage{kvoptions}
\RequirePackage{ifthen}
\RequirePackage{iftex}
\RequirePackage{ifluatex}
% csquotes provides \enquote, used in the affirmation text
\RequirePackage{csquotes}

% this package requires utf8 inputenc
\def\USCCover@utf8warning{\PackageWarningNoLine{\USCCover@Pgkname}
    {This package requires UTF-8 support.\MessageBreak
        If at pdflatex, load `inputenc' or `inputenx' with the `utf8' option}%
}

\newif\ifinputencloaded

\@ifpackageloaded{inputenx}
{\def\USCCover@tempa{inputenx}\inputencloadedtrue}
{\@ifpackageloaded{inputenc}{\def\USCCover@tempa{inputenc}\inputencloadedtrue}{\inputencloadedfalse}}
\ifinputencloaded
    \@ifpackagewith{\USCCover@tempa}{utf8}{}{\USCCover@utf8warning}
    %We also drop utf8x, as we believe that this is obsolete - see http://tex.stackexchange.com/questions/13067/utf8x-vs-utf8-inputenc
    \@ifpackagewith{\USCCover@tempa}{utf8x}{\USCCover@utf8warning}{}
\else
    \ifluatex
        %no warning required
    \else
        % UTF-8 is the default input encoding since LaTeX 2018-04-01, so inputenc is not needed anymore
        \@ifl@t@r\fmtversion{2018/04/01}{}{\USCCover@utf8warning}
    \fi
\fi

% ------------------------------
% options
% ------------------------------
\SetupKeyvalOptions{
    family=MCS,
    prefix=MCS@
}

% for possible option values see README.md
\DeclareStringOption[title not set]{title} % Title of the work
\DeclareStringOption[author not set]{author}
\DeclareStringOption[bachelor]{type}
\DeclareStringOption[fac]{institute}
\DeclareStringOption[]{department} % printed below the institute
\DeclareStringOption[]{number} % running number
\DeclareStringOption[cs]{studyprogram}
\define@key{MCS}{course}{\def\MCS@studyprogram{#1}} % old name of studyprogram, kept for backwards compatibility
\DeclareStringOption[examiner not set]{examiner}
\DeclareStringOption[advisor not set]{advisor}
\define@key{MCS}{supervisor}{\def\MCS@advisor{#1}} % old name of advisor, kept for backwards compatibility
\DeclareStringOption[startdate not set]{startdate}
\DeclareStringOption[enddate not set]{enddate}
\DeclareStringOption[]{logo}
\DeclareStringOption[standard]{covertype} % type of the coverpage: standard, ustuttdiss

\DeclareStringOption[german]{language}
\DeclareBoolOption[false]{setPageNumberToOne}
\DeclareBoolOption[false]{setCoverPageNumberToMinusOne}

% ------------------------------
% process options
% ------------------------------
\ProcessKeyvalOptions*

% ------------------------------
% define language specific labels:
% ------------------------------
% - labels are defined separate for each language
% - if language is not set, German is used
% ------------------------------
\def\labelsenglish{
    \gdef\@labelExaminer{Examiner}%
    %\gdef\@labelprueferin{Examiner}%
    \gdef\@labelAdvisor{Advisor}%
    \gdef\@labelCourse{Study program}%
    \gdef\@labelStartdate{Start date}%
    \gdef\@labelEnddate{End date}%
    \gdef\@labelUniversity{University of Stuttgart}%
    \gdef\@labelDept{Faculty of Computer Science}%

    %the labels are written in German, because these are the official terms given by the regulations ("Prüfungsordnung")
    %For a detailed discussion see https://github.com/latextemplates/uni-stuttgart-computer-science-cover/pull/10
    \gdef\@labelTypeStudy{Studienarbeit}%
    \gdef\@labelTypeDiplom{Diplomarbeit}%
    \gdef\@labelTypeBachelor{Bachelorarbeit}%
    \gdef\@labelTypeMaster{Masterarbeit}%
    \gdef\@labelTypeProjectINF{Projekt-INF}%
    \gdef\@labelTypeFachstudie{Fachstudie}%
    \gdef\@labelTypeProzessanalyse{Prozessanalyse}%
    % Project modules of the Bachelor programmes (Prüfungsordnung, Amtliche Bekanntmachung Nr. 26/2025)
    \gdef\@labelTypeForschungsprojekt{Bachelor-Forschungsprojekt Informatik}%
    \gdef\@labelTypeProjektAIDS{Projekt Artificial Intelligence and Data Science}%
    \gdef\@labelTypeStudienprojektMI{Studienprojekt Medieninformatik}%
    \gdef\@labelTypeStudienprojektSE{Studienprojekt Software Engineering}%

    \gdef\@labelCourseCS{Informatik}%
    \gdef\@labelCourseSE{Softwaretechnik}%
    \gdef\@labelCourseMCL{Computerlinguistik}%
    \gdef\@labelCourseTK{Technische Kybernetik}%
    \gdef\@labelCourseMSV{Maschinelle Sprachverarbeitung}%
    \gdef\@labelCourseBIS{Wirtschaftsinformatik}%
    \gdef\@labelCourseSimTech{Simulation Technology}%
    \gdef\@labelCourseMedInf{Medieninformatik}%
    \gdef\@labelCourseAIDS{Artificial Intelligence and Data Science}%
    \gdef\@labelCourseSWE{Software Engineering}%

    % institute names
    \gdef\@labeliaas{Institute of Architecture of Application Systems}%
    \gdef\@labelipvs{Institute for Parallel and Distributed Systems}%
    \gdef\@labelfmi{Institute of Formal Methods in Computer Science}%
    \gdef\@labelims{Institute for Natural Language Processing}%
    \gdef\@labeliste{Institute of Software Engineering}%
    \gdef\@labelDeptSQA{Software Quality and Architecture}%
    \gdef\@labelDeptAS{Application of Parallel and Distributed Systems}%
    \gdef\@labeliti{Institute of Computer Architecture and Computer Engineering}%
    \gdef\@labeliris{Institute of Computer-aided Product Development Systems}%
    \gdef\@labelvis{Institute for Visualization and Interactive Systems}%
    \gdef\@labelvisus{Visualization Research Center (VISUS)}%
    \gdef\@labelsec{Institute of Information Security}%

    \gdef\@labelAffirmation{Declaration}%
    \gdef\@AffirmationText{%
        I hereby declare that the work presented in this thesis is entirely my own.
        I did not use any other sources and aids than the listed ones.
        I have marked all direct or indirect transfers from other sources contained therein as referenced quotations.
        I assure that I have not used any aids that were explicitly ruled out by the examiner.\par\vspace{0.5em}
        In Appendix \enquote{Use of AI Tools} I have documented to what extent AI tools were used for generating any significant parts of this work.
        By submitting this work, I assume full responsibility for all content.
        I have taken notice of and I comply with the \textit{Principles for the Use of Artificial Intelligence by Students at the University of Stuttgart}.\par\vspace{0.5em}
        Neither this work nor significant parts of it were part of another examination procedure.
        I have not published this work in whole or in part before.
        The electronic copy is consistent with all submitted hard copies.
    }
    \gdef\@labelSignature{\ place, date, signature}
}

\def\labelsgerman{
    \gdef\@labelExaminer{Prüfer/in}%
    \gdef\@labelAdvisor{Betreuer/in}%
    \gdef\@labelCourse{Studiengang}%
    \gdef\@labelStartdate{Beginn am}%
    \gdef\@labelEnddate{Beendet am}%
    \gdef\@labelUniversity{Universität Stuttgart}%
    \gdef\@labelDept{Fakultät Informatik, Elektrotechnik und Informationstechnik}%

    \gdef\@labelTypeStudy{Studienarbeit}%
    \gdef\@labelTypeDiplom{Diplomarbeit}%
    \gdef\@labelTypeBachelor{Bachelorarbeit}%
    \gdef\@labelTypeMaster{Masterarbeit}%
    \gdef\@labelTypeProjectINF{Projekt-INF}%
    \gdef\@labelTypeFachstudie{Fachstudie}%
    \gdef\@labelTypeProzessanalyse{Prozessanalyse}%
    % Project modules of the Bachelor programmes (Prüfungsordnung, Amtliche Bekanntmachung Nr. 26/2025)
    \gdef\@labelTypeForschungsprojekt{Bachelor-Forschungsprojekt Informatik}%
    \gdef\@labelTypeProjektAIDS{Projekt Artificial Intelligence and Data Science}%
    \gdef\@labelTypeStudienprojektMI{Studienprojekt Medieninformatik}%
    \gdef\@labelTypeStudienprojektSE{Studienprojekt Software Engineering}%

    \gdef\@labelCourseCS{Informatik}%
    \gdef\@labelCourseSE{Softwaretechnik}%
    \gdef\@labelCourseMCL{Computerlinguistik}%
    \gdef\@labelCourseTK{Technische Kybernetik}%
    \gdef\@labelCourseMSV{Maschinelle Sprachverarbeitung}%
    \gdef\@labelCourseBIS{Wirtschaftsinformatik}%
    \gdef\@labelCourseSimTech{Simulation Technology}%
    \gdef\@labelCourseMedInf{Medieninformatik}%
    \gdef\@labelCourseAIDS{Artificial Intelligence and Data Science}%
    \gdef\@labelCourseSWE{Software Engineering}%

    % institute names
    \gdef\@labeliaas{Institut für Architektur von Anwendungssystemen}%
    \gdef\@labelipvs{Institut für Parallele und Verteilte Systeme}%
    \gdef\@labelfmi{Institut für Formale Methoden der Informatik}%
    \gdef\@labelims{Institut für Maschinelle Sprachverarbeitung}%
    \gdef\@labeliste{Institut für Software Engineering}%
    \gdef\@labelDeptSQA{Software Quality and Architecture}%
    \gdef\@labelDeptAS{Anwendersoftware}%
    \gdef\@labeliti{Institut für Technische Informatik}%
    \gdef\@labeliris{Institut für Rechnergestützte Ingenieursysteme}%
    \gdef\@labelvis{Institut für Visualisierung und Interaktive Systeme}%
    \gdef\@labelvisus{Visualisierungsinstitut der Universität Stuttgart (VISUS)}%
    \gdef\@labelsec{Institut für Informationssicherheit}%

    \gdef\@labelAffirmation{Erklärung}%
    \gdef\@AffirmationText{%
        Hiermit erkläre ich, dass ich die vorliegende Arbeit selbstständig verfasst und dabei keine anderen als die angegebenen Quellen und Hilfsmittel benutzt habe.
        Sämtliche wörtlichen oder sinngemäßen Übernahmen und Zitate aus anderen Werken sind kenntlich gemacht und nachgewiesen.
        Ich versichere, dass ich keine Hilfsmittel verwendet habe, deren Nutzung die Prüferin oder der Prüfer explizit ausgeschlossen hat.\par\vspace{0.5em}
        Im Anhang \enquote{Nutzung von KI-Tools} habe ich dokumentiert, inwiefern KI-Tools zur Erstellung wesentlicher Teile dieser Arbeit verwendet wurden.
        Mit Abgabe der Arbeit übernehme ich die volle Verantwortung für alle Inhalte.
        Die \textit{Grundsätze zur KI-Nutzung für Studierende an der Universität Stuttgart} habe ich zur Kenntnis genommen und befolgt.\par\vspace{0.5em}
        Weder diese Arbeit noch wesentliche Teile daraus waren bisher Gegenstand eines anderen Prüfungsverfahrens.
        Ich habe diese Arbeit bisher weder teilweise noch vollständig veröffentlicht.
        Das elektronische Exemplar stimmt mit allen eingereichten Exemplaren überein.
    }
    \gdef\@labelSignature{\ Ort, Datum, Unterschrift}
}

% set those labels according to the set language
\newcommand{\USCCover@setLanguage}{
    \def\0{english}
    \ifx\MCS@language\0
        \labelsenglish
    \else
        \labelsgerman
    \fi
}

% set \@labelType if matched
\newcommand{\USCCover@setType}{
    \gdef\@labelType{\MCS@type}
    \def\1{\MCS@type}
    % dont remove last two braces / empty else clause
    \def\0{diplom}\ifthenelse{\equal{\0}{\1}}{\gdef\@labelType{\@labelTypeDiplom}}{}
    \def\0{study}\ifthenelse{\equal{\0}{\1}}{\gdef\@labelType{\@labelTypeStudy}}{}
    \def\0{bachelor}\ifthenelse{\equal{\0}{\1}}{\gdef\@labelType{\@labelTypeBachelor}}{}
    \def\0{master}\ifthenelse{\equal{\0}{\1}}{\gdef\@labelType{\@labelTypeMaster}}{}
    \def\0{fachstudie}\ifthenelse{\equal{\0}{\1}}{\gdef\@labelType{\@labelTypeFachstudie}}{}
    \def\0{projectinf}\ifthenelse{\equal{\0}{\1}}{\gdef\@labelType{\@labelTypeProjectINF}}{}
    \def\0{prozessanalyse}\ifthenelse{\equal{\0}{\1}}{\gdef\@labelType{\@labelTypeProzessanalyse}}{}
    \def\0{forschungsprojekt}\ifthenelse{\equal{\0}{\1}}{\gdef\@labelType{\@labelTypeForschungsprojekt}}{}
    \def\0{projektaids}\ifthenelse{\equal{\0}{\1}}{\gdef\@labelType{\@labelTypeProjektAIDS}}{}
    \def\0{studienprojektmi}\ifthenelse{\equal{\0}{\1}}{\gdef\@labelType{\@labelTypeStudienprojektMI}}{}
    \def\0{studienprojektse}\ifthenelse{\equal{\0}{\1}}{\gdef\@labelType{\@labelTypeStudienprojektSE}}{}
}

% ------------------------------
% Institute addresses
% ------------------------------

% general university address
\gdef\@labelAddress{Universitätsstra{\ss}e 38\\70569 Stuttgart}

\newcommand{\USCCover@setInstitute}{
    % use specified text if institute does not match
    \gdef\@labelInstitute{\MCS@institute}
    \gdef\@labelInstituteAddress{}
    \gdef\@labelDepartment{}

    \def\1{\MCS@institute}
    % #1: key, #2: name, #3: address
    \def\2##1##2##3{\def\0{##1}\ifthenelse{\equal{\0}{\1}}{\gdef\@labelInstitute{##2}\gdef\@labelInstituteAddress{##3}}{}}
    \2{ipvs}{\@labelipvs}{\@labelAddress}
    \2{iaas}{\@labeliaas}{\@labelAddress}
    \2{fmi}{\@labelfmi}{\@labelAddress}
    \2{ims}{\@labelims}{Pfaffenwaldring 5B\\70569 Stuttgart}
    \2{iste}{\@labeliste}{\@labelAddress}
    % #1: key, #2: name, #3: address, #4: department
    \def\3##1##2##3##4{\2{##1}{##2}{##3}\def\0{##1}\ifthenelse{\equal{\0}{\1}}{\gdef\@labelDepartment{##4}}{}}
    \3{istesqa}{\@labeliste}{\@labelAddress}{\@labelDeptSQA}
    \3{ipvsas}{\@labelipvs}{\@labelAddress}{\@labelDeptAS}
    \2{iti}{\@labeliti}{Pfaffenwaldring 47\\70569 Stuttgart}
    \2{iris}{\@labeliris}{\@labelAddress}
    \2{vis}{\@labelvis}{\@labelAddress}
    \2{visus}{\@labelvisus}{Allmandring 19\\70569 Stuttgart}
    \2{sec}{\@labelsec}{\@labelAddress}
    \2{fac}{\@labelDept}{\@labelAddress}
    % the option department overrides the department of a predefined institute
    \ifx\MCS@department\empty\else\gdef\@labelDepartment{\MCS@department}\fi
}

% ------------------------------
% Evaluate studyprogram option and set study program
% ------------------------------
\newcommand{\USCCover@setCourse}{
    % use specified text if study program does not match
    \gdef\@labelCourseValue{\MCS@studyprogram}

    \def\1{\MCS@studyprogram}
    % dont remove last two braces / empty else clause
    \def\0{cs}\ifthenelse{\equal{\0}{\1}}{\gdef\@labelCourseValue{\@labelCourseCS}}{}
    \def\0{se}\ifthenelse{\equal{\0}{\1}}{\gdef\@labelCourseValue{\@labelCourseSE}}{}
    \def\0{mcl}\ifthenelse{\equal{\0}{\1}}{\gdef\@labelCourseValue{\@labelCourseMCL}}{}
    \def\0{msv}\ifthenelse{\equal{\0}{\1}}{\gdef\@labelCourseValue{\@labelCourseMSV}}{}
    \def\0{bis}\ifthenelse{\equal{\0}{\1}}{\gdef\@labelCourseValue{\@labelCourseBIS}}{}
    \def\0{simtech}\ifthenelse{\equal{\0}{\1}}{\gdef\@labelCourseValue{\@labelCourseSimTech}}{}
    \def\0{medinf}\ifthenelse{\equal{\0}{\1}}{\gdef\@labelCourseValue{\@labelCourseMedInf}}{}
    \def\0{aids}\ifthenelse{\equal{\0}{\1}}{\gdef\@labelCourseValue{\@labelCourseAIDS}}{}
    \def\0{swe}\ifthenelse{\equal{\0}{\1}}{\gdef\@labelCourseValue{\@labelCourseSWE}}{}

}

% ------------------------------
% evaluate options by calling those functions that set text accordingly
% ------------------------------
\USCCover@setLanguage
\USCCover@setType
\USCCover@setInstitute
\USCCover@setCourse

% ------------------------------
% helping commands
% ------------------------------
% - \USCCover@umrandet: frame the title box (for debugging the layout)
% - \USCCover@at: place content at an absolute position on the paper
% ------------------------------
\def\USCCover@umrandet{\global\let\@USCCover@umrandet=\fbox}
\let\@USCCover@umrandet\relax

% #1: distance from the top edge of the paper to the first baseline,
% #2: width, #3: content (centered horizontally on the paper)
% To be used inside \USCCover@page only.
\newcommand{\USCCover@at}[3]{%
    \put(\dimexpr(\paperwidth-#2)/2\relax,-#1){\parbox[t]{#2}{\centering #3}}}

% #1: distance from the top edge of the paper to the baseline, #2: label, #3: value
% The label column starts 50mm left of the middle of the paper, the value column 33mm after that.
\newcommand{\USCCover@field}[3]{%
    \put(\dimexpr\paperwidth/2-50mm\relax,-#1){\textbf{#2:}}%
    \put(\dimexpr\paperwidth/2-17mm\relax,-#1){\parbox[t]{85mm}{\raggedright #3}}}

% Only include package if a logo is provided, otherwise it is not needed.
\ifx\MCS@logo\empty
\else
    \RequirePackage{graphicx}
\fi

% The cover page is laid out at absolute positions on the paper,
% following the layout requirements of the Faculty of Computer Science.
% It does not depend on margins set by the document class or packages such as geometry.
\newsavebox{\USCCover@page}
\newcommand{\USCCover@typeset}{%
    \global\sbox{\USCCover@page}{%
        \sffamily\frenchspacing\fontsize{11pt}{13.6pt}\selectfont
        \begin{picture}(0,0)
            \ifx\MCS@logo\empty
                \USCCover@at{20mm}{100mm}{\fontsize{14pt}{17pt}\selectfont\textbf{\@labelUniversity}}
            \else
                \put(0,-26mm){\makebox[\paperwidth]{\includegraphics[height=14mm]{\MCS@logo}}}
            \fi
            \USCCover@at{33mm}{100mm}{\@labelInstitute\ifx\@labelDepartment\empty\else\\\@labelDepartment\fi}
            \USCCover@at{53mm}{100mm}{\@labelInstituteAddress}
            \USCCover@at{100mm}{100mm}{\fontsize{12pt}{14pt}\selectfont\textbf{%
                    \@labelType\ifx\MCS@number\empty\else\ Nr.\,\MCS@number\fi}}
            % title box: 104mm to 147mm from the top, title centered vertically
            \put(\dimexpr(\paperwidth-100mm)/2\relax,-147mm){\fboxsep=0pt\@USCCover@umrandet{%
                    \parbox[b][43mm][c]{100mm}{\centering\fontsize{17.28pt}{22pt}\selectfont\textbf{\MCS@title}}}}
            \USCCover@at{152mm}{100mm}{\fontsize{12pt}{14pt}\selectfont\MCS@author}
            \USCCover@field{224mm}{\@labelCourse}{\@labelCourseValue}
            \USCCover@field{232mm}{\@labelExaminer}{\MCS@examiner}
            \USCCover@field{247mm}{\@labelAdvisor}{\MCS@advisor}
            \USCCover@field{262mm}{\@labelStartdate}{\MCS@startdate}
            \USCCover@field{270mm}{\@labelEnddate}{\MCS@enddate}
        \end{picture}}}

% ------------------------------
% usable commands
% ------------------------------
% - \Titelblatt
% - \Versicherung
% ------------------------------
\newcommand{\Titelblatt}{%
    \cleardoublepage
    \ifthenelse{\boolean{MCS@setCoverPageNumberToMinusOne}}{\setcounter{page}{-1}}{}
    \begingroup
    \newcommand{\USCCover@isTwoColumn}{false}
    \if@twocolumn \renewcommand{\USCCover@isTwoColumn}{true} \onecolumn \fi
    \USCCover@typeset
    \AddToHookNext{shipout/foreground}{\put(0,0){\usebox{\USCCover@page}}}%
    \null
    \thispagestyle{empty}%
    \cleardoublepage % if twoside add a blank page after cover
    % set counter to start at 1 after the clear(double)page
    \ifthenelse{\boolean{MCS@setPageNumberToOne}}{\setcounter{page}{1}}{}
    \newcommand{\USCCover@true}{true}
    \ifthenelse{\equal{\USCCover@isTwoColumn}{\USCCover@true}}{\twocolumn}{}
    \endgroup
}
\newcommand{\Coverpage}{\Titelblatt}

\newcommand{\Versicherung}{
    \cleardoublepage
    \providecommand{\USCCover@isTwoColumn}{}
    \if@twocolumn \renewcommand{\USCCover@isTwoColumn}{true} \onecolumn
        \else \renewcommand{\USCCover@isTwoColumn}{false} \fi
    \null
    \vskip 5cm\relax
    \begin{center}
        \begin{minipage}[t]{10cm}
            \hbox{\textbf{\@labelAffirmation}}%
            \vskip 1cm\relax
            %\begin{flushleft}%
            \@AffirmationText
            %\end{flushleft}%
            \vskip 4cm\relax
            \hrulefill
            \vskip .4\baselineskip
            \hbox{\@labelSignature}
        \end{minipage}
    \end{center}
    \clearpage
    \providecommand{\USCCover@true}{true}
    \ifthenelse{\equal{\USCCover@isTwoColumn}{\USCCover@true}}{\twocolumn}{}
}
\newcommand{\Affirmation}{\Versicherung}
