% \iffalse meta-comment
%
% File: rub-kunstgeschichte.dtx
% Copyright (C) 2024 by Joran Schneyer <joran.schneyer@ruhr-uni-bochum.de>
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
% of this license or (at your option) any later version.
% The latest version of this license is in
%   https://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2008 or later.
%
% This work has the LPPL maintenance status `maintained'.
% 
% The Current Maintainer of this work is Joran Schneyer <joran.schneyer@ruhr-uni-bochum.de>.
%
% This work consists of the files rub-kunstgeschichte.dtx
%                                 rub-kunstgeschichte.ins
%           and the derived files rub-kunstgeschichte.cls
%                                 rub-kunstgeschichte-example.tex
%
% \fi

% \iffalse
%<*driver>
\ProvidesFile{rub-kunstgeschichte.dtx}
%</driver>
%<class>\NeedsTeXFormat{LaTeX2e}[2022-06-01]
%<class>\ProvidesClass{rub-kunstgeschichte}
%<*class>
    [2024-12-11 v0.4.0 RUB Kunstgeschichte class]
%</class>
%<*driver>
\documentclass{ltxdoc}

%^^A Load packages needed for the documentation
\usepackage{dtxdescribe}
\fvset{commandchars={|()}}

\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
    \DocInput{\jobname.dtx}
    \PrintChanges
    \PrintIndex
\end{document}
%</driver>
% \fi
%
%^^A Document general changes here
% \changes{v0.1.0}{2024-05-26}{Initial version}
%
% \GetFileInfo{\jobname.dtx}
%
% \DoNotIndex{\newcommand,\newenvironment}
% \DoNotIndex{\begin,\end}
% \DoNotIndex{\fi}
% \DoNotIndex{\section,\subsection,\subsubsection}
% \DoNotIndex{\title,\author,\tableofcontents}
% \DoNotIndex{\LaTeX,\verb}
% \DoNotIndex{\texorpdfstring}
% \DoNotIndex{\@rubkgi@bibheading,\@rubkgi@bibheading@primary,\@rubkgi@bibheading@secondary}
% \DoNotIndex{\@rubkgi@maketitle}
% \DoNotIndex{\@rubkgi@titlepage@gradebox@width}
% \DoNotIndex{\@author,\@date,\@title}
% \DoNotIndex{\@rubkgi@titlepage@author@email,\@rubkgi@titlepage@author@matricnum,\@rubkgi@titlepage@author@semester,\@rubkgi@titlepage@seminar@semester,\@rubkgi@titlepage@seminar@lecturer,\@rubkgi@titlepage@seminar@name,\@rubkgi@titlepage@seminar@degree,\@rubkgi@titlepage@seminar@module,\@rubkgi@titlepage@seminar@creditpoints}
%
%^^A define helper commands for consistent typesetting in the documentation
% \DeclareDocumentCommand\email{m}{\href{mailto:#1}{\nolinkurl{#1}}}
%
% \title{The \pkg{\jobname} class^^A
%   \thanks{This document corresponds to \pkg{\jobname}~\fileversion,
%     dated \filedate.}}
% \author{\copyright{} Joran Schneyer^^A
%   \thanks{Released under the LaTeX Project Public License v1.3c or later.^^A
%   \\ See \url{https://www.latex-project.org/lppl.txt}}^^A
%   \\ \email{joran.schneyer@ruhr-uni-bochum.de}}
% \date{\filedate}
%
% \maketitle
% \tableofcontents
%
% \section{Introduction}\label{sec:introduction}
%
% This \LaTeX{} class aims to implement the guidelines on scientific writing of the art history institute (Kunstgeschichtliches Institut - short: KGI) at Ruhr University Bochum.^^A
% \footnote{Guidelines version July 2023 \url{https://kgi.ruhr-uni-bochum.de/wp-content/uploads/2023/04/Anleitung-zum-Erstellen-von-Hausarbeiten-im-Fach-Kunstgeschichte_Fassung-Juli-2023.pdf}}
%
% Note, that at this point this is not an official class made by anyone at the institute but rather a free-time hobby project of me, Joran, who knows \LaTeX{} from studying Electrical Engineering and just wants to help out some friends studying art history.
%
% You can find the latest releases and the development of this project at GitHub: \url{https://github.com/rub-kgi/rub-kunstgeschichte-latex}
%
% \section{Usage}\label{sec:usage}
%
% To use this class, simply specify it as the document class.^^A
% \footnote{You can also find a complete example usage of this class in \autoref{sec:example}.}
% \begin{sourceverb}
% \documentclass{rub-kunstgeschichte}
% \end{sourceverb}
%
% \subsection{Caveats}
% When using this class, some packages are loaded automatically with options (see also \autoref{sec:implementation:package-loading}).
% That means that you can't reload the same package with different options without risking an option clash error.
% The relevant packages offer other ways to change their options in the preamble:
%
% \DescribePackage{biblatex}
% Customize citations and bibliography.
%
% \verb|\ExecuteBibliographyOptions|\oarg{entrytype}\marg{options} can be used to set most options,
% but some can only be set at the time of loading the \pkg{biblatex} package.
% Those can be set in the class options using the \optn{biblatex} key (see also \autoref{sec:usage:class-options}).
%
% \DescribePackage{hyperref}
% Customize behavior of clickable elements and pdf meta-data.
%
% \verb|\hypersetup|\marg{options} should be used for nearly all options.
% The few options that can only be given at load time of the package have to be passed along using the \optn{hyperref} class option (see also \autoref{sec:usage:class-options}).
%
% \DescribePackage{setspace}
% Overwrite the 1.5 line-spacing setting.
%
% Either \verb|\singlespacing|,
% \verb|\doublespacing|
% or for custom spacing factors also
% \verb|\setstretch|\marg{baselinestretch}.
%
% \DescribePackage{geometry}
% Overwrite geometry options such as the page margin settings.
%
% \verb|\geometry|\marg{options}
%
% \subsection{Class options}\label{sec:usage:class-options}
% You can pass several \meta{options} to the class by using
% \begin{sourceverb}
% \documentclass|oarg(options){rub-kunstgeschichte}
% \end{sourceverb}
% The \meta{options} are key/value pairs that sometimes defer to a default value when only the key is given.
%
% \DescribeOption{biblatex}
% Pass along options to the \pkg{biblatex} package. They overwrite default options set by this class.
%
% \DescribeOption{hyperref}
% Pass along options to the \pkg{biblatex} package. They do \textbf{not} overwrite default options set by this class as they are set after loading the package using the \verb|\hypersetup| command.
% To overwrite them, use \verb|\hypersetup|\marg{options} in the preamble.
%
% \DescribeOption{parskip}
% \DescribeDefault{\optn{true}}
% Specify wether to load the \pkg{parskip} package to remove indentation at the start of paragraphs.
%
% \DescribeOption{noparskip}
% \DescribeDefault{\optn{true}}
% The complementary option to the \optn{parskip} option.
%
% If neither \optn{parksip} nor \optn{noparskip} are given, the \pkg{parskip} package is automatically loaded by default.
%
% \subsection{Macros}\label{sec:usage:macros}
%
% \DescribeMacro{\printbibliographies} \oarg{options}
%
% Prints the bibliography, divided into two subbibliographies.
% One for primary sources and one for secondary literature, as suggested in section 3.7.1 of the guidelines on page 14.
% It uses the keyword mechanism to distinguish primary sources i.e. in order for a bib entry to be sorted into the primary sources section, it needs the \texttt{source} keyword.
% E.g. the bible would be considered a primary source:
% \begin{sourceverb}
% @inbook{bible,
%     author    = {{The Bible}},
%     title     = {The Holy Bible: King James Version},
%     |ldots
%     keywords  = {source}
% }
% \end{sourceverb}
% All other entries which don't have the \texttt{source} keyword will be sorted into the secondary literature section of the bibliography.
%
% You can customize the behavior of the macro using key-value \meta{options}. The option keys that are currently available are \optn{heading}, \optn{heading-primary} and \optn{heading-secondary} to overwrite the headings of the bibliography and the two subbibliographies respectively.
%
% \DescribeMacro{\maketitle} \oarg{titlepage-info}
%
% The native command \cs{maketitle} is redefined to create the title page according to the template in the guidelines.
% The new title page needs more information than the standard one.
% Besides the name of the author and title it needs more details about the author such as the matriculation number as well as information about the seminar the work is associated with.
% The extra info can be passed as key-value pairs to the optional \meta{titlepage-info} argument of the redefined \cs{maketitle} macro
% \DescribeMacro{\configureTitlepage}
% or to the \cs{configureTitlepage} macro implemented for just this task.
% The following custom keys are implemented:
% \begin{description}
% \ItemDescribeOption[titlepage]{email} The email of the author.
% \ItemDescribeOption[titlepage]{matricnum} The matriculation number of the author.
% \ItemDescribeOption[titlepage]{author-semester} The number of semesters the author has studied the subject.
% \ItemDescribeOption[titlepage]{seminar-semester} The semester in which the seminar takes place in. E.g. \optn{Sommersemester 2024} or \optn{Wintersemester 2023/24}.
% \ItemDescribeOption[titlepage]{seminar-lecturer} The name of the lecturer of the seminar.
% \ItemDescribeOption[titlepage]{seminar-name} The name of the seminar itself.
% \ItemDescribeOption[titlepage]{seminar-degree} The degree in which the author has taken the seminar in.
% \ItemDescribeOption[titlepage]{seminar-module} The module in which the author has taken the seminar in.
% \ItemDescribeOption[titlepage]{seminar-cp} The credit points the author will be rewarded with when completing the seminar.
% \end{description}
% Additionally you should set the normal \cs{author}, \cs{date} and \cs{title} info in the preamble.
%
% Note, that in contrast to e.g. the headers of the bibliography, the title page is not translated into the document language.
% The guidleines specify that exactly this template should be used and to our understanding this means that it should always be written in german, regardless of the document language.
%
% \DescribeMacro{\appendix}
%
% To indicate the end of the main content and start of the appendix, the \cs{appendix} command is used in \LaTeX. Here, the command was redefined to automatically disable section numbering for the appendix as suggested in the guidelines. This means you can just use normal section commands such as
% \begin{sourceverb}
% \section{Figures}
% \end{sourceverb}
% after calling
% \begin{sourceverb}
% \appendix
% \end{sourceverb}
% and it will not have a section number.
%
% \subsection{Translations}\label{sec:usage:translations}
%
% The class uses the \pkg{translations} package to allow multi-lingual strings. The default language is english. To tell it which language it should use, you can load a package like \pkg{babel} with the corresponding language as the package option in the preamble. E.g. for german using the new spelling rules
% \begin{sourceverb}
% \usepackage[ngerman]{babel}
% \end{sourceverb}
%
% All pre-defined strings this class prints on the page of the document (such as the headings of the bibliographies when using \cs{printbibliographies}) are available in multiple languages.
% So far this package only defines its strings for english and german, but you can define them for other languages too.\footnote{E.g. using the \cs{declaretranslation} command. For more info, refer to the documentation of the \pkg{translations} package: \url{https://ctan.org/pkg/translations}}
%
% The translation string definitions can be found in \autoref{sec:implementation:translations}.
%
% \StopEventually{}
%
% \clearpage
% \appendix
%
% \section{Implementation}\label{sec:implementation}
%
% \iffalse
%<*class>
% \fi
%
% \subsection{Class options}\label{sec:implementation:class-options}
% \iffalse
%% Class options
% \fi
% The class options are defined as keyval options for great flexibility.
% They toggle some of the class features or customize their behavior.
%
% \begin{option}{biblatex}
% The \optn{biblatex} option stores its content in a macro until it is later passed along to the \pkg{biblatex} package after specifying the default options (see \autoref{sec:implementation:package-loading:bibliography}).
% Therefore, options provided with this key overwrite the ones set per default by this class.
%    \begin{macrocode}
\DeclareKeys[rubkgi]{
    biblatex.store = \@rubkgi@biblatexOptions,
    biblatex.usage = load
}
%    \end{macrocode}
% \end{option}
%
% \begin{option}{hyperref}
% The \optn{hyperref} option passes its content along immediately, to be used as options when the \pkg{hyperref} package is loaded.
% This will \textbf{not} overwrite default options set by this class as they are set after loading the package using \verb|\hypersetup|\marg{options} (see also \autoref{sec:implementation:package-loading:others}).
%    \begin{macrocode}
\DeclareKeys[rubkgi]{
    hyperref.code  = \PassOptionsToPackage{#1}{hyperref},
    hyperref.usage = load
}
%    \end{macrocode}
% \end{option}
%
% \paragraph{Paragraph indentation}
% First we define a TeX switch which is later used (see \autoref{sec:implementation:package-loading}) to check wether to load the \pkg{parskip} package to remove the indentation at the start of paragraphs.
% \iffalse
%% TeX switch to decide wether to load the parskip package
% \fi
%    \begin{macrocode}
\newif\if@rubkgi@parskip
%    \end{macrocode}
% By default we set the switch to true, so the parskip package is normally loaded when using this class.
%    \begin{macrocode}
\@rubkgi@parskiptrue
%    \end{macrocode}
% \begin{option}{parskip}
% Then we declare the key so the switch can be turned on and off by the user in the class options.
%    \begin{macrocode}
\DeclareKeys[rubkgi]{
    parskip.if      = @rubkgi@parskip,
    parskip.usage   = load,
%    \end{macrocode}
% \end{option}
% \begin{option}{noparskip}
% Finally we define the complementary key for easier disabling of the parskip feature.
%    \begin{macrocode}
    noparskip.ifnot = @rubkgi@parskip,
    noparskip.usage = load
}
%    \end{macrocode}
% \end{option}
%
% \paragraph{Process options}
% After defining the class options it is necessary to process them too in order to actually make use of them.
%    \begin{macrocode}
\ProcessKeyOptions[rubkgi]
%    \end{macrocode}
%
% \subsection{Base class}\label{sec:implementation:base-class}
% \DescribeClass{article}
% The \pkg{\jobname} class is based on the \pkg{article} class.
% When loading the class we specify \texttt{12pt} as the base font size, as required by the guidelines.
% \iffalse
%% Load base class with 12pt base font size
% \fi
%    \begin{macrocode}
\LoadClass[12pt]{article}
%    \end{macrocode}
%
% \subsection{Loading packages}\label{sec:implementation:package-loading}
%
% \subsubsection{Bibliography}\label{sec:implementation:package-loading:bibliography}
%
% \DescribePackage{biblatex}
% \changes{v0.2.0}{2024-09-06}{Use biblatex with authortitle-dw style from biblatex-dw package.}^^A
% \changes{v0.3.0}{2024-10-30}{Use arthistory-bonn biblatex style instead of authortitle-dw.}^^A
% To support bibliography facilities out of the box, the \pkg{biblatex} package is loaded. To customize the behavior, a few options are passed to the package.
% \iffalse
%% biblatex options
% \fi
%    \begin{macrocode}
\PassOptionsToPackage{
%    \end{macrocode}
%
% \DescribeOption[biblatex]{backend}
% Defines the backend program. To use all features of \pkg{biblatex}, the \prog{biber} backend must be used.
%    \begin{macrocode}
    backend=biber,
%    \end{macrocode}
%
% \DescribeOption[biblatex]{singletitle}
% Prints the title of a cited work in short citations only if there is more than one work of the same author.
%    \begin{macrocode}
    singletitle=true,
%    \end{macrocode}
%
% \DescribeOption[biblatex]{autocite}
% Defines the behavior of the \cs{autocite} command, which in this case will behave like the \cs{footcite} command and will print citations in the footnotes instead of directly in the text.
%    \begin{macrocode}
    autocite=footnote,
%    \end{macrocode}
%
% \DescribeOption[biblatex]{autopunct}
% Controls whether the citation commands scan ahead for punctuation marks and move the citation after the punctuation.
%    \begin{macrocode}
    autopunct=true
}{biblatex}
%    \end{macrocode}
%
% \DescribePackage{biblatex-arthistory-bonn}
% \iffalse
%% biblatex-arthistory-bonn package
% \fi
% Further approximation of the suggested bibliography and citation styles in the guidelines is achieved by using the \pkg{biblatex-arthistory-bonn} package.
% To use it, a few more options are passed to \pkg{biblatex}:
%    \begin{macrocode}
\PassOptionsToPackage{
%    \end{macrocode}
%
% \DescribeOption[biblatex]{style}
% The \optn{arthistory-bonn} style provided by the \pkg{biblatex-arthistory-bonn} package is suited to approximate the citation style suggested in the guidelines.
%    \begin{macrocode}
    style=arthistory-bonn,
%    \end{macrocode}
%
% The following options of the \optn{arthistory-bonn} biblatex style are set to further implement the guidelines:
%
% \DescribeOption[biblatex]{firstcitefull}
% Delivers a full citation for the first occurence of an entry.
%    \begin{macrocode}
    firstcitefull=true,
%    \end{macrocode}
%
% \DescribeOption[biblatex]{enddot}
% Every bibliography entry will end with a dot.
%    \begin{macrocode}
    enddot=true,
%    \end{macrocode}
%
% The next \optn{arthistory-bonn} option is not implementing any part of the guidelines but is still useful:
%
% \DescribeOption[biblatex]{namelinked}
% Both name and year in a short citation will link to the respective bibliography entry.
%    \begin{macrocode}
    namelinked=true
}{biblatex}
%    \end{macrocode}
%
% After specifying the default options, we pass along the ones that might have been set in the class options.
% \iffalse
%% pass biblatex class options along
% \fi
%    \begin{macrocode}
\PassOptionsToPackage{\@rubkgi@biblatexOptions}{biblatex}
%    \end{macrocode}
%
% And finally the \pkg{biblatex} package is loaded.
% \iffalse
%% load biblatex
% \fi
%    \begin{macrocode}
\RequirePackage{biblatex}
%    \end{macrocode}
%
% \subsubsection{Document format}
%
% \DescribePackage{setspace}
% To achieve 1.5 times line spacing as required by the guidelines,
% we simply load the package \pkg{setspace} with the \optn{onehalfspacing} option.
% \iffalse
%% Set 1.5 times line spacing
% \fi
%    \begin{macrocode}
\RequirePackage[onehalfspacing]{setspace}
%    \end{macrocode}
%
% \DescribePackage{geometry}
% Used to set page size and margins.
% The guidelines require 2cm top, left and bottom margins as well as a 4cm correction margin on the right side.
% Furthermore A4 paper is the standard page size here.
% \iffalse
%% Set a4 paper size and margins
% \fi
%    \begin{macrocode}
\RequirePackage[
    a4paper,
    top=2cm,left=2cm,bottom=2cm,right=4cm
]{geometry}
%    \end{macrocode}
%
% \DescribePackage{parskip}
% \changes{v0.2.0}{2024-09-06}{Use parskip to avoid paragraph indentation}^^A
% To avoid indentation at the start of paragraphs, the \pkg{parskip} package is loaded if the corresponding switch is set to true. See also \autoref{sec:implementation:class-options}.
% \iffalse
%% Avoid paragraph indentation
% \fi
%    \begin{macrocode}
\if@rubkgi@parskip
    \RequirePackage{parskip}
\fi
%    \end{macrocode}
%
% \subsubsection{Other useful packages}\label{sec:implementation:package-loading:others}
%
% \DescribePackage{hyperref}
% \changes{v0.2.0}{2024-09-06}{Use hyperref for clickable links and references.}^^A
% Makes links and references clickable.
% \iffalse
%% Hyperref
% \fi
%    \begin{macrocode}
\RequirePackage{hyperref}
%    \end{macrocode}
% By default, we configure it to not highlight clickable elements.
%    \begin{macrocode}
\hypersetup{hidelinks}
%    \end{macrocode}
%
% \DescribePackage{translations}
% Used internally by the class to create multilingual strings that react to the document language set e.g. by \pkg{babel}.
% \iffalse
%% Translations
% \fi
%    \begin{macrocode}
\RequirePackage{translations}
%    \end{macrocode}
%
% \iffalse
%% Other
% \fi
%
% \DescribePackage{tabularx}
% To make fancy tables. Is used e.g. in the title page.
%    \begin{macrocode}
\RequirePackage{tabularx} % For fancy tables. Is used in title page.
%    \end{macrocode}
%
% \DescribePackage{boxedminipage}
% Used by title page.
%    \begin{macrocode}
\RequirePackage{boxedminipage} % Used in title page.
%    \end{macrocode}
%
% \subsection{Macros}\label{sec:implementation:macros}
% \iffalse
%% Macros
% \fi
%
% \begin{macro}{\printbibliographies}
% \changes{v0.4.0}{2024-12-11}{Fix: Unwanted space before bibliography headings}^^A
% \changes{v0.3.0}{2024-10-30}{was added}^^A
% Prints the bibliography using the native \cs{printbibliography} macro, but divides it into sections for primary sources and secondary literature. The keyword \texttt{source} is used to sort entries into the primary sources section.
%
% We start by defining the macro with an optional argument that is passed to \cs{SetKeys} to allow customization using key-value pairs.
%    \begin{macrocode}
\newcommand{\printbibliographies}[1][]{%
    \SetKeys[rubkgi@printbibliographies]{#1}%
%    \end{macrocode}
% We add an entry to the table of contents and insert the main bibliography heading.
%    \begin{macrocode}
    \addcontentsline{toc}{section}{%
        \texorpdfstring{\@rubkgi@bibheading}{bibliography}%
    }%
    \printbibheading[%
        heading = bibliography,%
        title = {\@rubkgi@bibheading}%
    ]
%    \end{macrocode}
% Then we print the subbibliographies.
%    \begin{macrocode}
    \printbibliography[%
        keyword = source,%
        heading = subbibliography,%
        title = {\@rubkgi@bibheading@primary}%
    ]
    \printbibliography[%
        notkeyword = source,%
        heading = subbibliography,%
        title = {\@rubkgi@bibheading@secondary}%
    ]
}
%    \end{macrocode}
% For greater flexibility we define the heading strings as internal macros that can be redefined by the user with key-value options and use the \pkg{translations} package for the default strings. See \autoref{sec:implementation:translations} for the implementation of the translations. We don't want heading strings to include paragraphs, this is why we use the starred variant of \cs{newcommand}.
%    \begin{macrocode}
\newcommand*{\@rubkgi@bibheading}{%
    \GetTranslationWarn{Bibliography}
}
\newcommand*{\@rubkgi@bibheading@primary}{%
    \GetTranslationWarn{Primary Bibliography}
}
\newcommand*{\@rubkgi@bibheading@secondary}{%
    \GetTranslationWarn{Secondary Bibliography}
}
%    \end{macrocode}
% Finally, we declare the keys that the user can use to redefine the headings.
%    \begin{macrocode}
\DeclareKeys[rubkgi@printbibliographies]
{
    heading           .store = \@rubkgi@bibheading,
    heading-primary   .store = \@rubkgi@bibheading@primary,
    heading-secondary .store = \@rubkgi@bibheading@secondary
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\maketitle}
% \changes{v0.3.0}{2024-10-30}{Redefined for custom title page according to template in guidelines.}^^A
% We redefine the \cs{maketitle} macro to print a custom title page.
% We also add the ability to customize it using key-value pairs in the optional argument.
%    \begin{macrocode}
\renewcommand{\maketitle}[1][]{%
    \SetKeys[rubkgi@titlepage]{#1}%
    \@rubkgi@maketitle%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@rubkgi@maketitle}
% The custom title page is defined as a dedicated internal command.
%    \begin{macrocode}
\newcommand{\@rubkgi@maketitle}{
%    \end{macrocode}
% It uses the \env{titlepage} environment to dedicate a full page to the titel.
% Inside, it uses groups, minipages and tabularx tables to arrange the fields to resemble the template of the guidelines.
%    \begin{macrocode}
    \begin{titlepage}
        % set page margins for the title page
        \newgeometry{left=2.5cm,top=2.5cm,bottom=2cm,right=2.5cm}%
        % define the width of the grade box
        \def\@rubkgi@titlepage@gradebox@width{5.03cm}%
        %
        % create a group for the top part of the title page
        {\raggedright%
        % create a minipage for the top left part
        \begin{minipage}[t]%
        % calculate the width of the top left part
        % based on the grade box width
        {\dimexpr\textwidth%
        -\@rubkgi@titlepage@gradebox@width%
        -0.5cm\relax}%
        \vspace{0pt}% somehow helps aligning at the top
        \begin{tabularx}{\linewidth}{@{}lX}%
            \multicolumn{2}{@{}l}{%
                Ruhr-Universität Bochum%
            }\\%
            \multicolumn{2}{@{}l}{%
                Fakultät für Geschichtswissenschaft%
            }\\%
            \multicolumn{2}{@{}l}{%
                Kunstgeschichtliches Institut%
            }\\%
            \multicolumn{2}{@{}l}{%
                \@rubkgi@titlepage@seminar@semester%
            }\\%
            Dozent:in:    & \@rubkgi@titlepage@seminar@lecturer\\%
            Seminartitel: & \@rubkgi@titlepage@seminar@name\\%
            Studiengang:  & \@rubkgi@titlepage@seminar@degree\\%
            Modul:        & \@rubkgi@titlepage@seminar@module\\%
            Kreditpunkte: & \@rubkgi@titlepage@seminar@creditpoints\\%
        \end{tabularx}%
        \end{minipage}%
        % align grade box on the right side by filling in the gap
        \hfill%
        % define the grade box as a boxedminipage
        \begin{boxedminipage}[t][3.78cm][t]%
        {\@rubkgi@titlepage@gradebox@width}%
        % leave a little space and add the text inside
        \vspace{1em}%
        \hspace{1em}Note:%
        \end{boxedminipage}%
        }% top part ends here
        %
        \vfill% vertical space to fill
        %
        % create center part (title and author)
        \begin{center}%
        % add title relatively LARGE
        {\LARGE \@title \par}%
        \vskip 2em% add space between title and author
        % add author slightly larger than normal text
        {\large \@author \par}%
        % end the center environment
        % and switch back to normal paragraph text style
        \end{center}\par%
        %
        \vfill% fill gap to put next part at bottom
        %
        % create bottom part
        {\raggedright%
        \begin{tabular}{@{}ll}%
            Matrikelnr.: & \@rubkgi@titlepage@author@matricnum\\%
            % Add email as a clickable link
            Email: & \href{mailto:\@rubkgi@titlepage@author@email}%
                                 {\@rubkgi@titlepage@author@email}\\%
            Fachsemester: & \@rubkgi@titlepage@author@semester\\%
            Abgabetermin: & \@date\\%
        \end{tabular}
        }%
    \end{titlepage}%
%    \end{macrocode}
% The guidelines specify that the titlepage counts towards the page numbers but should not display one. Therefore we set the page number counter to two after the title page.
%    \begin{macrocode}
    \setcounter{page}{2}%
%    \end{macrocode}
% We also reset the geometry to the one defined before the title page and then end the custom titlepage macro.
%    \begin{macrocode}
    \restoregeometry%
}
%    \end{macrocode}
% The custom title page needs extra information which we want the user to be able to set via key-value pairs. We first define the key-value pairs and then set the defaults.
%    \begin{macrocode}
\DeclareKeys[rubkgi@titlepage]
{
    email            .store = \@rubkgi@titlepage@author@email,
    matricnum        .store = \@rubkgi@titlepage@author@matricnum,
    author-semester  .store = \@rubkgi@titlepage@author@semester,
    seminar-semester .store = \@rubkgi@titlepage@seminar@semester,
    seminar-lecturer .store = \@rubkgi@titlepage@seminar@lecturer,
    seminar-name     .store = \@rubkgi@titlepage@seminar@name,
    seminar-degree   .store = \@rubkgi@titlepage@seminar@degree,
    seminar-module   .store = \@rubkgi@titlepage@seminar@module,
    seminar-cp       .store = \@rubkgi@titlepage@seminar@creditpoints
}
\SetKeys[rubkgi@titlepage]
{
    email            = {YOUR-EMAIL},
    matricnum        = {YOUR MATRICULATION NUMBER},
    author-semester  = {YOUR NUMBER OF SEMESTERS},
    seminar-semester = {THE SEMESTER IN WHCIH THE SEMINAR IS HELD},
    seminar-lecturer = {NAME OF SEMINAR LECTURER},
    seminar-name     = {NAME OF THE SEMINAR},
    seminar-degree   = {DEGREE SEMINAR IS TAKEN IN},
    seminar-module   = {MODULE SEMINAR IS TAKEN IN},
    seminar-cp       = {SEMINAR CP}
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\configureTitlepage}
% Lastly, we create a macro that can be used in the preamble to set the titlepage info keys.
%    \begin{macrocode}
\newcommand{\configureTitlepage}[1]{%
    \SetKeys[rubkgi@titlepage]{#1}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\appendix}
% \changes{v0.4.0}{2024-12-11}{redefined to disable section numbering}
% To automatically disable section numbering in appendix sections,
% we redefine \cs{appendix} to include setting the section numbering depth to zero.
% \iffalse
%% Extend \appendix to disable section numbering
% \fi
% First, we save the old appendix definition in a different macro.
%    \begin{macrocode}
\let\oldappendix\appendix%
%    \end{macrocode}
% Then we redefine the \cs{appendix} command
%    \begin{macrocode}
\renewcommand{\appendix}{%
%    \end{macrocode}
% starting with the old appendix macro
%    \begin{macrocode}
    \oldappendix%
%    \end{macrocode}
% and extending it with setting the section numbering depth to zero,
% which will result in disabled section numbers.
%    \begin{macrocode}
    \setcounter{secnumdepth}{0}%
}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Translations}\label{sec:implementation:translations}
% \changes{v0.3.0}{2024-10-30}{Use translations package for multi-lingual support.}^^A
%
% The \pkg{translations} package offers an easy interface to create multilingual strings. We can define them all at once here, at the end of the class, since they are only used when the user commands are expanded in the document.
%
% \subsubsection*{Bibliography headings}
%
% The \pkg{translations} package already comes with translations for the main heading of the bibliography. Additionally, we provide the headings for the subbibliographies in english and german.
%    \begin{macrocode}
\DeclareTranslation{english}{Primary Bibliography}{Primary sources}
\DeclareTranslation{german}{Primary Bibliography}{Primärliteratur}
\DeclareTranslation{english}{Secondary Bibliography}{Secondary literature}
\DeclareTranslation{german}{Secondary Bibliography}{Sekundärliteratur}
%    \end{macrocode}
% 
% \iffalse

%</class>
%<*example>
% \fi
% \clearpage
%
% \section{Example}\label{sec:example}
%
% To further exemplify the use of this class,
% we create an example \filenm{.tex} file.
% The full \filenm{rub-kunstgeschichte-example.tex} and the corresponding \PDF{} are available on GitHub.^^A
% \footnote{\url{https://github.com/rub-kgi/rub-kunstgeschichte-latex/releases}}
%
% First, the \pkg{rub-kunstgeschichte} class is loaded
% \iffalse
%% Load the rub-kunstgeschichte class
% \fi
%    \begin{macrocode}
\documentclass{rub-kunstgeschichte}
%    \end{macrocode}
% \iffalse

% \fi
%
% followed by the information that is needed to typeset a normal title:
%    \begin{macrocode}
\title{Example usage of the \textsf{rub-kunstgeschichte} class}
\author{Joran Schneyer}
%    \end{macrocode}
% For the custom title we need to set additional information, such as
%    \begin{macrocode}
\configureTitlepage{
    email = {joran.schneyer@ruhr-uni-bochum.de}
}
%    \end{macrocode}
% We leave the rest to their default values for now.
%
% For citations, the bibtex entries are usually written to a seperate \filenm{.bib} file.
% For the sake of this example we keep everything in one \filenm{.tex} file and use the \env{filecontents} environment instead.
% \iffalse

%% bibliography file (usually you would put this in a seperate .bib file)
% \fi
%    \begin{macrocode}
\begin{filecontents}{rub-kunstgeschichte-example.bib}
@manual{guidelines,
    author = {{Kunstgeschichtliches Institut}},
    year   = {2023},
    title  = {Anleitung zur Erstellung von Hausarbeiten im Fach Kunstgeschichte},
    organization = {Ruhr University Bochum},
    url     = {https://kgi.ruhr-uni-bochum.de/wp-content/uploads/2023/04/Anleitung-zum-Erstellen-von-Hausarbeiten-im-Fach-Kunstgeschichte_Fassung-Juli-2023.pdf},
    urldate = {2024-11-04}
}
@article{exampleArticle,
    author  = {Maxi Mustermann},
    title   = {A very interesting article},
    year    = {2001},
    journal = {Important example journal}
}
@book{exampleBook,
    author    = {John Smith},
    title     = {A long example book marked as primary literature},
    year      = {2024},
    keywords  = {source}
}
@inbook{bible,
    author    = {{The Bible}},
    title     = {The Holy Bible: King James Version},
    booktitle = {The New Testament},
    publisher = {Oxford University Press},
    year      = {1769},
    location  = {Oxford},
    keywords  = {source}
}
@online{exampleWebsite,
    author  = {{Example consortium}},
    title   = {The truth about example documents},
    year    = {2020},
    note    = {Internet forum article},
    url     = {https://example.com},
    urldate = {2100-04-01}
}
@manual{biblatexDocs,
    author   = {Philip Kime and Moritz Wemheuer and Philipp Lehman},
    title    = {The biblatex Package},
    subtitle = {Programmable Bibliographies and Citations},
    year     = {2024},
    url      = {https://ctan.org/pkg/biblatex},
    urldate  = {2024-06-25}
}
@online{biblatexCheatsheet,
    title   = {Biblatex Cheat Sheet},
    author  = {Clea F. Rees},
    year    = {2017},
    url     = {https://ctan.org/pkg/biblatex-cheatsheet},
    urldate = {2024-06-25}
}
\end{filecontents}
%    \end{macrocode}
% \iffalse

% \fi
% After that, we need to load the bibliography to use it with biblatex.
%    \begin{macrocode}
\addbibresource{rub-kunstgeschichte-example.bib}
%    \end{macrocode}
% \iffalse

%% Load additional packages
% \fi
% To set our language to german (using the new spelling rules) we load \pkg{babel}.
%
%    \begin{macrocode}
\usepackage[ngerman]{babel} % Sets the language of the document
%    \end{macrocode}
% For including the graphics and placing them where we want them, we load the \pkg{graphicx} and \pkg{float} packages.
%    \begin{macrocode}
\usepackage{graphicx}
\usepackage{float}
%    \end{macrocode}
% \iffalse

% \fi
% Having finished the preamble, we begin the document, typeset the title and include a table of contents.
%    \begin{macrocode}
\begin{document}
    \maketitle
    \tableofcontents
%    \end{macrocode}
% \iffalse

% \fi
%
% Next we add different sections that explain common usage and some features of this class.
%    \begin{macrocode}
    \section{Introduction}
    The \textsf{rub-kunstgeschichte} class aims to implement
    the guidelines on scientific writing of the art history institute
    ``KGI'' (\textit{Kunstgeschichtliches Institut})
    at Ruhr University Bochum.

    This example document showcases a typical use
    of the \textsf{rub-kunstgeschichte} class.
    Just by using the class, the page is already formatted
    so that the typeset text has 12pt font size,
    there is a 1.5 times line-spacing present
    and the page size is A4 with 2cm margins at top, left and bottom,
    as well as a 4cm margin on the right.\autocite[See:][11]{guidelines}

    Also, paragraphs don't have an indentation
    in the first line by default,
    contrary to typical \LaTeX{} documents.
    Furthermore the \texttt{hyperref} package
    is automatically loaded to enable clickable
    links and references.

    Notably, the first page is a custom title page
    that aims to recreate the titlepage template
    of the guidelines in \LaTeX.
    Note, how the fields have descriptive default values in CAPS,
    so that you can easily see which information is still missing
    for the title page.
    As the documentation of this class states,
    you can either pass the corresponding key-value options
    into an optional argument of \verb|\maketitle|,
    or use the \verb|\configureTitlepage| macro
    in the preamble.\footnote{For a full list of titlepage options
    refer to the \texttt{rub-kunstgeschichte} class documentation.}

    We use the \texttt{babel} package
    to set the language to german
    (even though this example document is actually written in english)
    to showcase how headings are automatically translated.

    \section{How to cite sources}
    This class automatically loads the \texttt{biblatex} package
    for sophisticated bibliography and citations.
    The class also sets some options by default
    that make \texttt{biblatex} behave closer to the
    suggested citation style in the guidelines of the institute.

    You can cite sources using the \verb|\autocite| command,
    which is configured by this class to use footnotes
    \autocite{exampleArticle}.
    Page numbers can be added in the optional argument
    \autocite[394]{exampleBook}
    and citation signals in a second one
    that comes before the one for page numbers
    \autocite[see][]{exampleWebsite}.
    You can even cite multiple sources at once
    using the \verb|\autocites| command
    \autocites[111]{exampleBook}[see also][13]{exampleArticle}.

    For more information refer to the documentation
    of the \texttt{biblatex} package
    \autocite{biblatexDocs}
    or the biblatex cheatsheet
    \autocite{biblatexCheatsheet}.

    \clearpage
    \appendix

    \section{The appendix}

    We finished the main content of the example document
    so we call \verb|\appendix| before this first appendix section.
    It will automatically disable section numbering
    for any appendix sections.

    Here, we can include a bibliography
    containing all cited sources,
    divided into primary and secondary literature,
    with \verb|\printbibliographies|.
    Primary literature (also called a \textit{source})
    is something like the bible\autocite{bible},
    letters, treatises etc.
    We put the bibliography on a new page
    by using \verb|\clearpage| before printing it.
    Note, that since we used
    \verb|\usepackage[ngerman]{babel}| in the preamble,
    the headings of the bibliography are typed in german.

    \clearpage
    \printbibliographies

    \clearpage
    \section{Figures}

    The guidelines suggest putting all figures
    in a dedicated appendix section
    after the bibliography instead of in between the
    main content text.\autocite[10,25]{guidelines}

    We can include figures with \verb|\includegraphics|
    inside a \texttt{figure} environment.
    We also add a caption with the meta information
    of the shown artwork,\autocite[25--26]{guidelines}
    as well as a short caption in square brackets
    and a label for back-referencing.

    \begin{figure}[H]
        \centering
        \includegraphics[width=0.8\linewidth]{example-image-golden}
        \caption{An Artist, The artwork title, Where was it made?,
        The year, Material, Measurements, Where is it kept?,
        Inventory number.}
        \label{fig:exampleArtwork}
    \end{figure}
%    \end{macrocode}
%
% Finally we end the document environment
%    \begin{macrocode}
\end{document}
%    \end{macrocode}
% \clearpage
% \iffalse

%</example>
% \fi
%
% \Finale
