% \iffalse meta-comment
%
% Copyright 2025 Michael E. Hammer
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
% 
% The Current Maintainer of this work is Michael E. Hammer.
%
% This file is part of the "fhj-script bundle" and all files in that
% bundle must be distributed together.
%
% \fi
% \iffalse
%<*driver>
\ProvidesFile{fhjbook.dtx}
%</driver>
%<class>\NeedsTeXFormat{LaTeX2e}[2023-11-01]
%<class>\ProvidesClass{fhjbook}
%<*class>
    [2026-02-25 v4.2c A class for formatting books/thesis in the FHJ style]
%</class>
%
%<*driver>
\documentclass[a4paper]{ltxdoc}
\usepackage{fhjcommon}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\OnlyDescription % We only want the description
\begin{document}
    \DocInput{fhjbook.dtx}
\end{document}
%</driver>
% \fi
%
% \GetFileInfo{fhjbook.dtx}
%
% \changes{v4.0}{2025/08/03}{Initial package version}
%
% \title{The \textsf{fhjbook} class\thanks{This document
% corresponds to \textsf{fhjbook}~\fileversion,
% dated \filedate.}}
% \author{Michael E. Hammer \\ \texttt{michael.hammer@fh-joanneum.at}}
%
% \maketitle
% 
% \begin{abstract}
% This class is intended to be used for formatting books and thesis in the FHJ style.
% It is based on the \textsf{scrbook} class and provides a set of
% macros and commands to simplify the formatting of thesis and books.
% \end{abstract}
%
% \tableofcontents
% 
% \section{Configuration and styling}
%
% It is important to note that this class is based on the \textsf{scrbook} class and we 
% support forwarding options to it.
%
%    \begin{macrocode}
\newcommand{\@ClassName}{fhjbook}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{scrbook}}
\ProcessOptions\relax
%    \end{macrocode}
%
% We load the \textsf{scrbook} class with the following options:
%
% \begin{itemize}
%     \item \texttt{a4paper}: We want to use A4 paper size
%     \item \texttt{DIV=14}: The DIV parameter should be set to 14 to ensure a good
%           balance between text width and height
%     \item \texttt{BCOR=10mm}: The binding correction should be set to 10mm to ensure
%           proper binding of the printed document
% \end{itemize}
% 
% \textit{Remark}: Feel free to switch to \verb|twoside| which we clearly recommend!
%    
%    \begin{macrocode}
\LoadClass[a4paper,DIV=14,BCOR=10mm]{scrbook}
%    \end{macrocode}
%
% For styling of the document headers we rely on the predefined stylings from 
% KOMA-Script.
% 
%    \begin{macrocode}
\pagestyle{headings}
%    \end{macrocode}
%  
% \subsection{Used packages}
% 
% For the styling of the document we use the following packages and therefore they are 
% preloaded and you might not load them again in your document:
% 
%    \begin{macrocode}
\RequirePackage{fhjcommon}
\PassOptionsToPackage{hidelinks}{hyperref}
\RequirePackage{hyperref}
\RequirePackage{array}
\RequirePackage{supertabular}
\RequirePackage{xstring}
%    \end{macrocode}
% 
% \section{Preamble}
% 
% For using the class you need to define a few macros (preferably in your preamble).
% 
% \subsection{Multlilingual support}
% 
% This class supports multilingual documents and therefore we recommend to load the 
% \texttt{babel} package and set one of two supported languages -- either \texttt{ngerman} 
% or \texttt{english}. A possible boilerplate for the preamble could look like this:
% 
% \begin{quote}
%   |\newcommand{\mylanguage}|\marg{language}\\
%   |\usepackage[T1]{fontenc}|\\
%   |\usepackage[\mylanguage]{babel}|\\
%   |\selectlanguage{\mylanguage}|
% \end{quote}
% 
% The definition of the macro \cs{mylanguage} is optional, but it has the advantage that
% you might want to use it in other packages as well.
% 
% \subsection{Title page}
%
% To have the correct icon and name for the study program typeset on the title page, you
% need to define it with the macro from \texttt{fhjcommon} package (see the according 
% documentation):
% 
% \begin{quote}
%  |\FHJProgram{DAT}|
% \end{quote}
%
% \DescribeMacro{\title}
% This command defines the title of your master thesis and is placed on the title page
% on the according position. It is supported to use line breaks in the title, so you can
% have up to three lines in the title.
% 
% \DescribeMacro{\subtitle}
% This command defines the subtitle of your master thesis and is placed on the title 
% page on the according position. The subtitle is optional and it is expected to be a 
% single line.
%
% \DescribeMacro{\author} \DescribeMacro{\authorinfo}
% On the title page it is mandatory to define the author of the thesis. The command
% \cs{author} is used for this purpose and must be followed by the author's name in the
% following format -- make sure to use first name first and the last name second in all
% capital letters:
% 
% \begin{quote}
%  |\author{Lisa MUSTERFRAU}|
% \end{quote}
%
% Besides the name of the author, you need to provide some additional information with
% the macro \cs{authorinfo}\marg{gender}\marg{mat-nr}\marg{year} which may look as 
% follows:
%
% \begin{quote}
%  |\authorinfo{f}{0130508}{2024}|
% \end{quote}
%
% Currently we support the following values for the gender -- \texttt{m}, \texttt{f} and 
% \texttt{o} (for other). The matrikel number is the student's ID number and the year 
% is the cohort of the student.
% 
% \DescribeMacro{\supervisor}
% Finally it is mandatory to define the supervisor of the thesis with the help of 
% \cs{supervisor}\marg{name}\marg{gender} macro:
%
% \begin{quote}
%   |\supervisor{MMMMag. DDr. Wolfgang GRANIGG}{m}|
% \end{quote}
%
% \DescribeMacro{\cosupervisor}
% It may be the case that you have a second supervisor, which is optional and can be 
% defined with the help of \cs{cosupervisor}\marg{name}\marg{gender} macro in the same
% way as for \cs{supervisor}.
% 
% \DescribeMacro{\date}
% The date of submission is defined with the \cs{date} macro and it is expected to be
% a single line in the following format:
%
% \begin{quote}
%   |\date{YYYY-MM-DD}|
% \end{quote}
%
% \DescribeMacro{\FHJLocation}
% The location which is used on the titlepage is defined with the \cs{FHJLocation} macro
% and it is expected to be a single line.
% 
% \subsection{Abstract and keywords}
% 
% All master thesis must contain an abstract in both German and English. The abstract
% should provide a brief summary of the research question, methodology, and key 
% findings. To support you in typesetting the abstract, we provide macros for defining
% the abstract itself and the keywords.
% 
% \DescribeMacro{\FHJAbstractDE} \DescribeMacro{\FHJAbstractEN}
% These macros are used to define the abstract in German and English respectively. Both
% commands follow the same syntax:
% 
% \begin{quote}
%  |\FHJAbstractDE|\marg{abstract text}\marg{keyword1,keyword2,$\dots$}\\
%  |\FHJAbstractEN|\marg{abstract text}\marg{keyword1,keyword2,$\dots$}
% \end{quote}
% 
% \textbf{Note:} The keywords are expected to be a comma-separated list of keywords
% whithout spaces before or after the commas. Do not forget to define the abstract and 
% keywords in both languages!
%
% \section{Thesis document}
% 
% \subsection{Front matter}
% 
% If you have defined all necessary macros in the preamble, you can start with the
% document itself. In most cases you will want to use the following boilerplate at the
% beginning:
% 
% \begin{quote}
% |\begin{document}|\\
% \hspace*{2em}|\frontmatter|\\
% \hspace*{2em}|\FHJThesisFrontMatter|\\
% \hspace*{2em}|\tableofcontents|\\
% \hspace*{2em}|\listoftables|\\
% \hspace*{2em}|\listoffigures|\\
% \hspace*{2em}|\mainmatter|\\
% \hspace*{2em}$\dots$\\
% |\end{document}|
% \end{quote}
% 
% The macros \cs{frontmatter}, \cs{mainmatter} are special macros from KOMA-Script which
% seperate the front matter from the main content of the thesis -- one consequence for 
% example is roman numbering of the pages in the front matter and arabic numbering in 
% the main matter.
% 
% \DescribeMacro{\FHJThesisFrontMatter}
% The macro \cs{FHJThesisFrontMatter} is used to typeset the front matter of the thesis.
% It will take care of all
% necessary formatting for you (for title page, abstract and declarations). 
% Nevertheless, we also export the individual macros for the title page, abstract and
% declarations.
%
% \DescribeMacro{\FHJMakeTitlePage}
% The macro \cs{FHJMakeTitlePage} is used to typeset the title page of the thesis. 
% It is expected to be
% called in the document body and will take care of all necessary formatting for you. 
% It generates an empty page and should be the first page of the document.
% 
% \DescribeMacro{\FHJMakeDeclaration}
% The macro \cs{FHJDeclaration} is used to typeset the declaration page of the thesis.
% It is actually contained in package \texttt{fhjcommon}.
% 
% \DescribeMacro{\FHJMakeAbstract}
% The macro \cs{FHJMakeAbstract} is used to typeset the abstract of the thesis including
% keywords in both languages.
%
% \subsection{Appendix}
%
% The appendix is a section at the end of the thesis where you can include additional
% material that is not essential to the main text but may be helpful for the reader. 
% This can include supplementary data, detailed explanations of methods or source code,
% or other relevant information.
% 
% We at least recommend to include the list of abbreviations.
% 
% \begin{quote}
% |\appendix|\\
% |\chapter{Appendix}|\\
% |\section{Source Code}|\\
% $\cdots$\\
% |\section{|$\cdots$|}|\\
% $\cdots$\\
% |% Will create its own section in the table of contents|\\
% |\printacronyms[template=supertabular,heading=section]|\\
% \end{quote}
% 
% \subsection{Bibliography}
% 
% The bibliography is an essential part of any thesis, as it provides a list of all the
% sources that were cited or consulted during the research process. It is important to
% follow a consistent citation style throughout the thesis and to include all necessary
% information for each source (see \verb|fhj_guide.pdf| for further information on 
% writing a thesis in {\LaTeX}).
% 
% A possible boilerplate for printing the bibliography in the document could look like
% this (|heading=bibnumbered| ensures that the bibliography is listed and numbered in 
% the table of contents):
% 
% \begin{quote}
% |\printbibliography[heading=bibnumbered]|
% \end{quote}
% 
% \MaybeStop{\PrintChanges}
% 
% \section{Implementation}
% 
%    \begin{macrocode}
\renewcommand*{\title}[1]{\renewcommand*{\@title}{{#1}}}
\newcommand{\check@title}{%
  \@ifundefined{@author}{
    \ClassWarningNoLine{fhjbook}{Author not defined}\author{first SECOND}
  }{}
  \@ifundefined{@title}{
    \ClassWarningNoLine{fhjbook}{Title not defined}\title{Title}
  }{}
  \@ifundefined{@supervisor}{
    \ClassWarningNoLine{fhjbook}{Supervisor not defined}\supervisor{Supervisor}{m}
  }{}
}
\newcommand{\check@abstract}{%
  \@ifundefined{@abstractDE}{
    \ClassWarningNoLine{fhjbook}{German ``Kurzfassung'' not defined!}\FHJAbstractDE{Eine Beispielkurzfassung...}{kw1,kw2}
  }{}
  \@ifundefined{@abstractEN}{
    \ClassWarningNoLine{fhjbook}{English abstract not defined!}\def\@abstractDE{An example abstract...}{kw1,kw2}
  }{}
}
% Handhabung von Untertiteln:
\newif\ifsubtitlepresent\subtitlepresentfalse
\renewcommand{\subtitle}[1]
{\subtitlepresenttrue
  \def\thesissubtitle{#1}}

% Autoren- und Betreuerinformationen:
\newif\ifauthormale\authormalefalse
\newif\ifauthorfemale\authorfemalefalse
\newcommand{\authorinfo}[3]{
  \if#1m \authormaletrue \fi
  \if#1f \authorfemaletrue \fi
  \def\personenkennzahl{#2}
  \def\jahrgang{#3}
}

\newif\ifsupervisormale\supervisormalefalse
\newif\ifsupervisorfemale\supervisorfemalefalse
\newcommand{\supervisor}[2]{
  \def\@supervisor{#1}
  \if#2m \supervisormaletrue \fi
  \if#2f \supervisorfemaletrue \fi
}

\newif\ifcosupervisorpresent\cosupervisorpresentfalse
\newif\ifcosupervisormale\cosupervisormalefalse
\newif\ifcosupervisorfemale\cosupervisorfemalefalse
\newcommand{\cosupervisor}[2]{
  \cosupervisorpresenttrue
  \def\thesiscosupervisor{#1}
  \if#2m \cosupervisormaletrue \fi
  \if#2f \cosupervisorfemaletrue \fi
}

\newcommand{\FHJLocation}[1]{
  \newcommand{\@location}{#1}
}

% Main title page
\newcommand{\FHJMakeTitlePage}{%
\check@title%
\thispagestyle{empty}%
\begin{center}
%%  \IfStrEqCase{\FHJProgramShort}{
%%  {DAT}{%
%%    \includegraphics[width=70mm]{fhjInformaticsLogo.img.pdf}
%%  }{IMS}{%
%%    \includegraphics[width=70mm]{fhjInformaticsLogo.img.pdf}
%%  }
\iflanguage{ngerman}{\includegraphics[width=70mm]{fhjInformaticsLogo.de.img.pdf}}{}
\iflanguage{english}{\includegraphics[width=70mm]{fhjInformaticsLogo.en.img.pdf}}{}
\\[10mm]

% Masterarbeit, Titel, Untertitel
\iflanguage{ngerman}{\textbf{MASTERARBEIT}}{}
\iflanguage{english}{\textbf{MASTER'S THESIS}}{}
\\[10mm]

\begin{minipage}{\textwidth}\begin{center}
  \fontsize{16}{20}\selectfont
  \textbf{\@title}
\end{center}\end{minipage}\\[5mm]

\ifsubtitlepresent
  {\large\thesissubtitle}\\[10mm]
\else
  \vspace*{15mm}
\fi

\iflanguage{ngerman}{
  {\footnotesize
  Eingereicht bei
  }\\[2mm]
  \FHJ\\
  Masterstudiengang\\
  ``\FHJProgramLong''
}{}
\iflanguage{english}{
  { \footnotesize
  Submitted at
  }\\[2mm]
  \FHJ\\
  Master's Degree Programme\\
  ``\FHJProgramLong''
}{}
\vspace*{10mm}

{ \footnotesize
\iflanguage{ngerman}{\ifauthormale Autor \else \ifauthorfemale Autorin \else Autor:in \fi \fi}{}
\iflanguage{english}{Author}{}\\[2mm]
}
\@author\\
\personenkennzahl\\
\iflanguage{english}{Cohort}{}\iflanguage{ngerman}{Jahrgang}{} \FHJProgramShort\ \jahrgang\\[10mm]

{\footnotesize
\iflanguage{ngerman}{\ifsupervisormale Betreuer \else \ifsupervisorfemale Betreuerin \else Betreuer:in \fi \fi}{}
\iflanguage{english}{Supervisor}{}\\[2mm]
}
\@supervisor\\[10mm]

\ifcosupervisorpresent
  {\footnotesize
  \iflanguage{ngerman}{\ifcosupervisormale Zweiter Betreuer \else \ifcosupervisorfemale Zweite Betreuerin \else Zweite:r Betreuer:in \fi \fi}{}
  \iflanguage{english}{Second Supervisor}{}\\[2mm]
  }
  \thesiscosupervisor
\fi

\end{center}

\vfill

\@location, \@date \hfill
\iflanguage{ngerman}{Unterschrift}{}
\iflanguage{english}{Signature}{}
\par\vspace*{1cm}
}

\newcommand{\FHJAbstractDE}[2]{%
  \newcommand{\@abstractDE}{#1}
  \newcommand*{\@keywordsDE}{#2}
}

\newcommand{\FHJAbstractEN}[2]{%
  \newcommand{\@abstractEN}{#1}
  \newcommand*{\@keywordsEN}{#2}
}

\newcommand*{\@lastkeyword}{}%
\newcommand*{\@kwseparator}{\space$\vert$\space}%
\newcommand{\@printkeyword}[1]{%
  \expandafter\ifblank\expandafter{\@lastkeyword}{}%
    {\@kwseparator}%
  {#1}%
  \renewcommand*{\@lastkeyword}{#1}%
}

\newcommand{\@printkeywords}[2]{%
  \renewcommand*{\@lastkeyword}{}%
  \IfStrEq{#2}{de}{\textit{Schlüsselwörter: }}{}%
  \IfStrEq{#2}{en}{\textit{Keywords: }}{}%
  \expandafter\forcsvlist\expandafter\@printkeyword\expandafter{#1}%
}

\newcommand{\FHJMakeAbstract}{%
\check@abstract
\cleardoublepage
\begingroup % to make sure we change parindent only in this group
  \setlength{\parindent}{0pt}
  \textbf{\Large Kurzfassung:}\\[5mm]
  \@abstractDE
  \vfill
  \@printkeywords{\@keywordsDE}{de}
  \clearpage
  \textbf{\Large Abstract:}\\[5mm]
  \@abstractEN
  \vfill
  \@printkeywords{\@keywordsEN}{en}
\endgroup
\cleardoublepage
}

%% Compile all title pages together
\newcommand{\FHJThesisFrontMatter}{%
% Main title page
\FHJMakeTitlePage%
% Declaration
\FHJMakeDeclaration%
% Abstract
\FHJMakeAbstract%
}
%    \end{macrocode}
% 
% \Finale
% 
% \section{Acknowledgements}
% 
% The original work for creating a base class for the study program ``\FHJDATLong'' was
% done by \textbf{Klaus Lichtenegger}. All appreciation goes to him for creating the
% first version of this class.
%  
\endinput
