%% This is file `bfhlayout.sty' version 2.2.6 (2026-01-12),
%% it is part of
%% BFH-CI -- Corporate Design for Bern University of Applied Sciences
%% ----------------------------------------------------------------------------
%%
%%  Copyright (C) 2021--2026 by
%%      Marei Peischl <marei@peitex.de>
%%      Andreas Habegger <andreas.habegger@bfh.ch>
%%
%% ============================================================================
%% 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
%% http://www.latex-project.org/lppl.txt
%% and version 1.3c or later is part of all distributions of LaTeX
%% version 2008/05/04 or later.
%%
%% This work has the LPPL maintenance status `maintained'.
%%
%% The Current Maintainers of this work are
%%   Marei Peischl <bfh-ci@peitex.de>
%%   Andreas Habegger <andreas.habegger@bfh.ch>
%%
%% The development respository can be found at
%% https://gitlab.ti.bfh.ch/bfh-latex/bfh-ci/
%% Please use the issue tracker for feedback!
%%
%% ============================================================================
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{bfhlayout}[2026-01-12 v2.2.6 BFH style package (layout)]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Process Options created for bfharticle
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{l3keys2e}

\ExplSyntaxOn
\int_new:N \g_ptxcd_paper_int
\tl_new:N \g_ptxcd_titleimage_ratio_tl
\bool_new:N \g__ptxcd_tmp_bool
\bool_new:N \g_ptxcd_geometry_bool
\bool_new:N \g_ptxcd_margins_bool

\keys_define:nn {ptxcd/layout} {
	margins .choice:,
	margins / typearea .code:n ={
			\bool_gset_true:N \g_ptxcd_margins_bool
			\bool_gset_false:N \g_ptxcd_geometry_bool
		},
	margins / official .code:n ={
			\bool_gset_true:N \g_ptxcd_margins_bool
			\bool_gset_true:N \g_ptxcd_geometry_bool
		},
	margins / default .meta:n =  {margins=typearea},
	margins .initial:n = default,
	invert-title .bool_gset:N = \g__ptxcd_title_inverted_bool,
	invert-title .initial:n = false,
	paper .choices:nn = {a0,a1,a2,a3,a4,a5}{
			\int_gset_eq:NN \g_ptxcd_paper_int  \l_keys_choice_int
			\exp_args:Nx \PassOptionsToPackage{paper=\l_keys_choice_tl}{typearea}
			\exp_args:Nx \PassOptionsToPackage{\l_keys_choice_tl paper}{geometry}
		},
	paper .initial:n = a4,
	titleimage-ratio .choice:,
	titleimage-ratio / 12 .code:n = \tl_gset:Nn \g_ptxcd_titleimage_ratio_tl {.5},
	titleimage-ratio / 13 .code:n = \tl_gset:Nn \g_ptxcd_titleimage_ratio_tl {.333333},
	titleimage-ratio / 23 .code:n = \tl_gset:Nn \g_ptxcd_titleimage_ratio_tl {.666666},
	titleimage-ratio / 56 .code:n = \tl_gset:Nn \g_ptxcd_titleimage_ratio_tl {.833333},
	titleimage-ratio / 34 .code:n = \tl_gset:Nn \g_ptxcd_titleimage_ratio_tl {.75},
	titleimage-ratio / 1011 .code:n = \tl_gset:Nn \g_ptxcd_titleimage_ratio_tl {0.909090},
	titleimage-ratio .initial:n = 12,
	logo-language .code:n = \PassOptionsToPackage{language=#1}{bfhlogo},
	trilingual .meta:n = {logo-language=de_fr_en},
	bilingual .meta:n = {logo-language=de_fr},
	monolingual .meta:n = {logo-language=default},
	logofile .tl_gset:N = \g_ptxcd_logofile_tl,
	logofile .initial:n =,
	type .choices:nn = {publication,thesis,beamerarticle} {\tl_gset_eq:NN \g_ptxcd_pubType_tl \l_keys_choice_tl},
	type / intern .code:n = {\keys_set:nn {ptxcd/pub}  {titlepage=false}},
	type / factsheet .code:n = \tl_gset:Nn  \g_ptxcd_pubType_tl {factsheet}\keys_set:nn {ptxcd/layout}  {margins=official}\KOMAoptions{titlepage=true},
	type / projectproposal .code:n = \tl_gset:Nn  \g_ptxcd_pubType_tl {projectproposal}\keys_set:nn {ptxcd/layout}  {margins=official}\KOMAoptions{titlepage=false,parskip=half-},
	type .initial:n = publication,
	beamerarticle .meta:n = {type=beamerarticle},
	landscape .bool_gset:N = \g_ptxcd_landscape_bool,
	landscape .initial:n = false,
}

\ProcessKeysOptions{ptxcd/layout}

%%
\bool_if:NT \g_ptxcd_geometry_bool {
	\bool_if:NT \g_ptxcd_margins_bool {
		\dim_new:N \g_ptxcd_innerMargin_dim
		\dim_new:N \g_ptxcd_outerMargin_dim
		\dim_new:N \g_ptxcd_bottomMargin_dim
		\dim_new:N \g_ptxcd_topMargin_dim
		\dim_new:N \g_ptxcd_topLogoMargin_dim
		\dim_new:N \g_ptxcd_columnSep_dim
		\dim_gset:Nn \g_ptxcd_columnSep_dim {4mm}
		%a4
		\int_compare:nTF {\g_ptxcd_paper_int=5}
		{
			\bool_if:NTF \g_ptxcd_landscape_bool {
				\dim_gset:Nn \g_ptxcd_topMargin_dim {12mm}
				\dim_gset:Nn \g_ptxcd_bottomMargin_dim {14mm}
				\dim_gset:Nn \g_ptxcd_innerMargin_dim {14mm}
				\dim_gset:Nn \g_ptxcd_outerMargin_dim {11mm}
				\dim_gset:Nn \g_ptxcd_topLogoMargin_dim {44mm}
			}{
				\dim_gset:Nn \g_ptxcd_topMargin_dim {12mm}
				\dim_gset:Nn \g_ptxcd_bottomMargin_dim {13mm}
				\dim_gset:Nn \g_ptxcd_innerMargin_dim {16mm}
				\dim_gset:Nn \g_ptxcd_outerMargin_dim {12mm}
				\dim_gset:Nn \g_ptxcd_topLogoMargin_dim {48mm}
			}
		}{
			%a0, a1, a2,a3
			\int_compare:nT {1<=\g_ptxcd_paper_int<=4}
			{
				\int_case:nn {\g_ptxcd_paper_int}
				{
					{1} {\dim_gset:Nn \g_ptxcd_outerMargin_dim {39mm}\dim_gset:Nn \g_ptxcd_columnSep_dim {12mm}}
						{2} {\dim_gset:Nn \g_ptxcd_outerMargin_dim {28mm}\dim_gset:Nn \g_ptxcd_columnSep_dim {9mm}}
						{3} {\dim_gset:Nn \g_ptxcd_outerMargin_dim {20mm}\dim_gset:Nn \g_ptxcd_columnSep_dim {6mm}}
						{4} {\dim_gset:Nn \g_ptxcd_outerMargin_dim {14mm}}
				}
				\dim_gset_eq:NN \g_ptxcd_bottomMargin_dim \g_ptxcd_outerMargin_dim
				\dim_gset_eq:NN \g_ptxcd_innerMargin_dim \g_ptxcd_outerMargin_dim
				\dim_gset_eq:NN \g_ptxcd_topMargin_dim \g_ptxcd_outerMargin_dim
			}
			%a5
			\int_compare:nT {\g_ptxcd_paper_int<=6}
			{
				\bool_if:NTF \g_ptxcd_landscape_bool {
					\dim_gset:Nn \g_ptxcd_topMargin_dim {7mm}
					\dim_gset:Nn \g_ptxcd_bottomMargin_dim {13mm}
					\dim_gset:Nn \g_ptxcd_innerMargin_dim {15mm}
					\dim_gset:Nn \g_ptxcd_outerMargin_dim {10mm}
					\dim_gset:Nn \g_ptxcd_topLogoMargin_dim {35mm}
				}{
					\dim_gset:Nn \g_ptxcd_topMargin_dim {7mm}
					\dim_gset:Nn \g_ptxcd_bottomMargin_dim {11mm}
					\dim_gset:Nn \g_ptxcd_innerMargin_dim {14mm}
					\dim_gset:Nn \g_ptxcd_outerMargin_dim {9.75mm}
					\dim_gset:Nn \g_ptxcd_topLogoMargin_dim {39mm}
				}
			}
		}
	}
	\KOMAoptions{footlines=1}
	\RequirePackage{geometry}
	\geometry{
		includefoot,
		%		footskip=\dim_eval:n {\footskip+\baselineskip},
		top=\g_ptxcd_topMargin_dim,
		inner=\g_ptxcd_innerMargin_dim,
		outer=\dim_eval:n {\g_ptxcd_outerMargin_dim},
		bottom=\dimexpr\g_ptxcd_bottomMargin_dim-\dp\strutbox,
		columnsep= \g_ptxcd_columnSep_dim,
		%		footinclude,
	}
}
\ExplSyntaxOff
%%
%% Loading necessary packages
%% For Colors
\PassOptionsToPackage{table}{xcolor}
\RequirePackage{bfhcolors}
\colorlet{BFH-info}{BFH-LightGreen}
%% Helper macros
%\RequirePackageWithOptions{bfhhelpers}
%%% For page references
\PassOptionsToPackage{lastpage,user}{zref}
\RequirePackage{zref}
%% For internationalization
\RequirePackage{translations}
\LoadDictionary{bfhtranslations}

%% For Pagestyles
\PassOptionsToPackage{automark,headsepline}{scrlayer-scrpage}
\RequirePackage{scrlayer-scrpage}

\RequirePackage{amsmath}
\RequirePackage{bfhfonts}
\RequirePackage{graphicx}
%%
%% ====================== In Package Translations ================================
%% -----------------------
%% author and
%% -----------------------
\DeclareTranslationFallback{and}{and}
%% DE
\DeclareTranslation{German}{and}{und}
%% FR
\DeclareTranslation{French}{and}{et}
%% EN
\DeclareTranslation{English}{and}{and}
%% -----------------------
%% page-of-pages
%% -----------------------
\DeclareTranslationFallback{page-of-pages}{page~\thepage\ of~\zpageref{LastPage}}
%% DE
\DeclareTranslation{German}{page-of-pages}{Seite~\thepage\ von~\zpageref{LastPage}}
%% FR
\DeclareTranslation{French}{page-of-pages}{page~\thepage\ sur~\zpageref{LastPage}}
%% EN
\DeclareTranslation{English}{page-of-pages}{page~\thepage\ of~\zpageref{LastPage}}
%% -----------------------
%% version-of-date
%% -----------------------
\DeclareTranslationFallback{version-of-date}{%
	Version~\@version\ of~\@date
}%
%% DE
\DeclareTranslation{German}{version-of-date}{%
	Version~\@version\ vom~\@date
}%
%% FR
\DeclareTranslation{French}{version-of-date}{%
	Version~\@version\ de~\@date
}%
%% EN
\DeclareTranslation{English}{version-of-date}{%
	Version~\@version\ of~\@date
}%
%% -----------------------
%%
%% BFH Logos
%%
\PassOptionsToPackage{
	variant=C,
	height=67.5pt,%125% for a4
}{bfhlogo}

\ExplSyntaxOn
\bool_if:NTF \g__ptxcd_title_inverted_bool {
	\PassOptionsToPackage{invert-logo-colors=true}{bfhlogo}
} {
	\PassOptionsToPackage{invert-logo-colors=false}{bfhlogo}
}

\file_if_exist:nTF {bfhlogo.sty}
{\RequirePackage{bfhlogo}}
{
	\tl_if_empty:NT \g_ptxcd_logofile_tl {
		\msg_new:nnnn {bfh-ci} {missing-bfhlogo}
		{I~could~not~find~the~bfhlogo~package.}
		{Please~have~a~look~at~the~bfh-ci~documentation~for~more~information~or~provide~an~alternative~using~the~logofile~option.}
		\msg_warning:nn {bfh-ci} {missing-bfhlogo}
	}
}

\dim_if_exist:NF \g__ptxcd_logo_height_dim {
	\dim_new:N \g__ptxcd_logo_height_dim
	\dim_gset:Nn \g__ptxcd_logo_height_dim {67.5pt}
}

\box_if_exist:NF \g__ptxcd_logo_box {
	\box_new:N \g__ptxcd_logo_box
}

\tl_if_empty:NF \g_ptxcd_logofile_tl {
	\hbox_gset:Nn \g__ptxcd_logo_box {\includegraphics[height=\g__ptxcd_logo_height_dim]{\g_ptxcd_logofile_tl}}
}

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

\providecommand{\Logo}{\g_ptxcd_logofile_tl}
\providecommand{\Logoplain}{\g_ptxcd_logofile_tl}

\ExplSyntaxOn
\dim_new:N \g_ptxcd_rule_height_dim
\dim_new:N \g_ptxcd_rule_arc_dim
\file_input:n {bfh-a\int_eval:n {\g_ptxcd_paper_int -1} paper.clo}
\ptxcd_setup_base_sizes:
%% ============================== BFH Item List ==============================
%%
\@ifundefined {scr@fnt@labelitemi}{\newkomafont{labelitemi}{}}{}

\cs_new:Nn \__ptxcd_itemlabel: {{\ifvmode\leavevmode\fi\usekomafont{labelitemi}\raise1.25pt\hbox{$\blacktriangleright$}}}
\AddToHook{begindocument/end}[bfh-ci-label]{\renewcommand*{\labelitemi}{\__ptxcd_itemlabel:}\setkomafont{labelitemi}{\color{BFH-Orange}}}
\newcommand*{\bfhitemlabel}{\__ptxcd_itemlabel:\quad}

%%
%%
%% ===================== Set fonts for caption, chapter etc. ==================

\colorlet{BFH-textaccentcolor}{BFH-Gray}
%color all headers:
\setkomafont{disposition}{\sffamily\bfseries\color{BFH-textaccentcolor}}

\setkomafont{caption}{\sffamily\footnotesize\color{BFH-textaccentcolor}}
\setkomafont{captionlabel}{\usekomafont{caption}\bfseries}

\setkomafont{pageheadfoot}{\footnotesize\color{BFH-textaccentcolor}}
\setkomafont{footnote}{\sffamily\color{BFH-textaccentcolor}}

\setkomafont{pagenumber}{\sffamily\bfseries\small\color{BFH-Orange}}

\RequirePackage{trimclip}

\ExplSyntaxOn
\colorlet{BFH-Title}{BFH-Gray}
\setkomafont{title}{\Huge\color{BFH-Title}}
\setkomafont{subtitle}{\large\color{BFH-Title}}
\setkomafont{subject}{\normalsize\color{BFH-Title}}
\setkomafont{author}{\normalsize\color{BFH-Title}}
\setkomafont{date}{\normalsize\color{BFH-Title}}
\setkomafont{publishers}{\normalsize\color{BFH-Title}}
\newkomafont{titlefooter}{\color{BFH-Title}\sffamily\bfseries}

\seq_new:N \g_ptxcd_author_seq

\renewcommand*\author[1]{
	\seq_gset_split:Nnn \g_ptxcd_author_seq {\and} {#1}
}

\renewcommand*{\@author}{%
	\begingroup
	\hyphenpenalty=100000
	\seq_use:Nnnn \g_ptxcd_author_seq {~\GetTranslation{and}~} {,~} {~\&~}
	\endgroup
}

\bool_if:NTF \g__ptxcd_title_inverted_bool
{
	\colorlet{BFH-titlebg}{BFH-Gray}
	\colorlet{BFH-titlefg}{BFH-Orange}
}{
	\colorlet{BFH-titlebg}{BFH-Orange}
	\colorlet{BFH-titlefg}{BFH-Gray}
}

%Titelseite
\tl_new:N  \g_ptxcd_titleimage_code_tl
\tl_gset_eq:NN  \g_ptxcd_titleimage_code_tl \c_empty_tl

\box_new:N \l__ptxcd_titlegraphic_box
\box_new:N \g__ptxcd_title_box

\RequirePackage{xparse}

\NewDocumentCommand{\titlegraphic}{sm}{
	\IfBooleanTF{#1}{
		\tl_gset:Nn \g_ptxcd_titleimage_code_tl {
			\hbox_set:Nn \l__ptxcd_titlegraphic_box {\raisebox{\depth}{#2}}
			\box_resize_to_wd:Nn \l__ptxcd_titlegraphic_box {\width}
			\dim_compare:nTF {\box_ht:N \l__ptxcd_titlegraphic_box - \height> \c_zero_dim}
			{
				\dim_set:Nn \l_tmpa_dim {.5\box_ht:N \l__ptxcd_titlegraphic_box - .5\height}
				\clipbox{0pt~\dim_eval:n{\l_tmpa_dim}~0pt~\dim_eval:n{\l_tmpa_dim}}{\box_use:N \l__ptxcd_titlegraphic_box}
			}{
				\box_resize_to_ht:Nn \l__ptxcd_titlegraphic_box {\height}
				\dim_set:Nn \l_tmpa_dim {(\box_wd:N \l__ptxcd_titlegraphic_box - \width) / 2}
				\clipbox{\dim_eval:n{\l_tmpa_dim}~0pt~\dim_eval:n{\l_tmpa_dim}~0pt}{\box_use:N \l__ptxcd_titlegraphic_box}
			}
		}
	}{
		\tl_gset:Nn \g_ptxcd_titleimage_code_tl {#2}
	}
}

\tl_new:N \g_ptxcd_partnerlogo_tl
\newcommand{\partnerlogo}[1]{\tl_gset:Nn \g_ptxcd_partnerlogo_tl {#1}}

\dim_new:N \g__ptxcd_titleimage_ht_dim


\dim_gset:Nn \g__ptxcd_titleimage_ht_dim { \g_ptxcd_titleimage_ratio_tl\paperheight- \g_ptxcd_titleimage_ratio_tl\g_ptxcd_rule_height_dim}

\exp_args:NV \tl_if_eq:nnT \g_ptxcd_pubType_tl {thesis} {
	\dim_compare:nT {\g__ptxcd_titleimage_ht_dim > .666\paperheight} {
		\msg_new:nnnn {ptxcd/layout} {incompatble-titleimage-ratio} {You~tried~to~set~the~titleimage-ratio~larger~than~23.\\This~is~not~allowed~for~theses.} {I~will~set~it~to~the~maximum~allowed~value~23.}
		\msg_warning:nn {ptxcd/layout} {incompatble-titleimage-ratio}
		\keys_set:nn {ptxcd/layout} {titleimage-ratio=23}
		\dim_gset:Nn \g__ptxcd_titleimage_ht_dim { \g_ptxcd_titleimage_ratio_tl\paperheight- \g_ptxcd_titleimage_ratio_tl\g_ptxcd_rule_height_dim}
	}
}

\DeclareNewLayer[
	page,
	height=\g__ptxcd_titleimage_ht_dim,
	background,mode=picture,
	contents={
			\putLL{\color{BFH-titlebg}\rule{\layerwidth}{\layerheight}}
			\putLL{\color{BFH-titlebg}
				\let\width\layerwidth
				\let\height\layerheight
				\g_ptxcd_titleimage_code_tl
			}
		}
]{title.BFH.image}

\DeclareNewLayer[
	page,
	height=\dim_eval:n {\box_ht:N \g__ptxcd_title_box + \box_dp:N \g__ptxcd_title_box + \coverpagetopmargin+1.5\box_ht:N \g__ptxcd_logo_box},
	background,mode=picture,
	contents={
			\putLL{\color{BFH-titlebg}\rule{\layerwidth}{\layerheight}}
			\putLL{\color{BFH-titlebg}
				\let\width\layerwidth
				\let\height\layerheight
				\g_ptxcd_titleimage_code_tl
			}
		}
]{title.BFH.titlehead}

\DeclareNewLayer[
	mode=picture,
	page,background,
	voffset=\dim_eval:n {\box_ht:N \g__ptxcd_title_box + \box_dp:N \g__ptxcd_title_box + \coverpagetopmargin+1.5\box_ht:N \g__ptxcd_logo_box},
	width=\paperwidth,height=\g_ptxcd_rule_height_dim,
	contents={\putLL{\color{BFH-titlefg}\rule{\layerwidth}{\layerheight}}}
]{title.BFH.titleheadrule}

\bool_if:NTF \g_ptxcd_geometry_bool {
	\def\coverpagetopmargin{\g_ptxcd_topMargin_dim}
	\def\coverpagebottommargin{\g_ptxcd_bottomMargin_dim}
	\def\coverpageleftmargin{\g_ptxcd_innerMargin_dim}
	\def\coverpagerightmargin{\g_ptxcd_outerMargin_dim}
}{
	\def\coverpagetopmargin{.5\g__ptxcd_logo_height_dim}
	\def\coverpagebottommargin{.5\g__ptxcd_logo_height_dim}
	\def\coverpageleftmargin{.75\g__ptxcd_logo_height_dim}
	\def\coverpagerightmargin{.75\g__ptxcd_logo_height_dim}
}
\DeclareNewLayer[background,foot,align=bl,
	voffset=\paperheight-\coverpagebottommargin+.35\baselineskip,
	width=\dimexpr\paperwidth-\coverpageleftmargin-\coverpagerightmargin\relax,
	contents={
			\usekomafont{titlefooter}
			\makebox[\linewidth]{
				\@titlefooterleft\hfill
				\@titlefooterright
			}
		}
]{title.BFH.footer}

\DeclareNewLayer[
	mode=picture,
	page,background,
	voffset=\g__ptxcd_titleimage_ht_dim,
	width=\paperwidth,height=\g_ptxcd_rule_height_dim,
	contents={\putLL{\color{BFH-titlefg}\rule{\layerwidth}{\layerheight}}}
]{title.BFH.rule}

\DeclareNewLayer[
	mode=picture,
	foreground,
	align=tl,
	hoffset=\oddsidemargin+1in,
	voffset=\coverpagetopmargin,
	width=\box_wd:N \g__ptxcd_logo_box,
	height=\box_ht:N \g__ptxcd_logo_box,
	%width=\paperwidth,height=\g_ptxcd_rule_height_dim,
	contents={\putLL{\box_use:N \g__ptxcd_logo_box}}
]{title.BFH.logo}

\DeclareNewLayer[
	mode=picture,
	foreground,
	align=tr,
	hoffset=\oddsidemargin+1in+\textwidth,
	voffset=\coverpagetopmargin,
	width=\textwidth - \box_wd:N \g__ptxcd_logo_box,
	height=\box_ht:N \g__ptxcd_logo_box,
	contents={%
			\putUL{%
			\makebox[\layerwidth][r]{%
				\let\width\layerwidth
				\let\height\layerheight
				\raisebox{-\height}{\g_ptxcd_partnerlogo_tl}}%
		}%
	}%
]{title.BFH.partnerlogo}

\DeclareNewPageStyleByLayers{title.BFH}{title.BFH.rule,title.BFH.image,title.BFH.footer}

\DeclareNewPageStyleByLayers{titlehead.BFH}{title.BFH.titleheadrule,title.BFH.titlehead,title.BFH.logo,title.BFH.partnerlogo}
\renewcommand*{\titlepagestyle}{titlehead.BFH}

% The following macro is an adapted version of the corresponding KOMA-Script macro
% Copyright (c) 1994-2019 Markus Kohm [komascript at gmx info]
\renewcommand*{\maketitle}[1][1]{
	\def\and{,~ }
	\cs_if_exist_use:N \ptxcd_pass_TitleData:
	\if@titlepage
		\begin{titlepage}
			\setcounter{page}{%
				#1%
			}%
			\def\thefootnote{\fnsymbol{footnote}}
			\edef\titlepage@restore{%
				\noexpand\endgroup
				\noexpand\global\noexpand\@colht\the\@colht
				\noexpand\global\noexpand\@colroom\the\@colroom
				\noexpand\global\vsize\the\vsize
				\noexpand\global\noexpand\@titlepageiscoverpagefalse
				\noexpand\let\noexpand\titlepage@restore\noexpand\relax
			}%
			%always is coverpage!
			\begingroup
			\topmargin=\dimexpr \coverpagetopmargin-1in\relax
			\oddsidemargin=\dimexpr \coverpageleftmargin-1in\relax
			\evensidemargin=\dimexpr \coverpageleftmargin-1in\relax
			\textwidth=\dimexpr
			\paperwidth-\coverpageleftmargin-\coverpagerightmargin\relax
			\textheight=\dimexpr
			\paperheight-\coverpagetopmargin-\coverpagebottommargin\relax
			\headheight=0pt
			\headsep=0pt
			\footskip=\baselineskip
			\@colht=\textheight
			\@colroom=\textheight
			\vsize=\textheight
			\columnwidth=\textwidth
			\hsize=\columnwidth
			\linewidth=\hsize
			\setparsizes{\z@}{\z@}{\z@\@plus 1fil}\par@updaterelative
			\thispagestyle{title.BFH}
			\vbox_to_ht:nn {\g__ptxcd_titleimage_ht_dim-\coverpagetopmargin}{
				\makebox[\linewidth]{\leavevmode\box_use:N \g__ptxcd_logo_box\hfill\raisebox{\dim_eval:n {-\height+\box_ht:N \g__ptxcd_logo_box}}[0pt][0pt]{
						\let\height\g__ptxcd_logo_height_dim
						\g_ptxcd_partnerlogo_tl
					}}
				\par
				\vfill
				%Check if title should be placed above or below the rule
				\bool_gset_false:N \g__ptxcd_tmp_bool
				\dim_compare:nT {\g__ptxcd_titleimage_ht_dim > .75\paperheight} {\bool_gset_true:N \g__ptxcd_tmp_bool}
				\bool_if:NTF \g__ptxcd_tmp_bool
				{
					\begingroup
					\colorlet{BFH-Title}{BFH-titlefg}
					\__ptxcd_print_title:
					\endgroup
					\bool_gset_false:N \g__ptxcd_tmp_bool
				} {
					\bool_gset_true:N \g__ptxcd_tmp_bool
				}
				\skip_vertical:n {\coverpagetopmargin}
				\null
			}
			\nointerlineskip
			\bool_if:NT \g__ptxcd_tmp_bool
			{
				\skip_vertical:n {\coverpagetopmargin}
				\__ptxcd_print_title:
			}
			\@thanks\let\@thanks\@empty
			\if@twoside
				\@tempswatrue
				\if@tempswa
					\next@tpage
					\begin{minipage}[t]{\textwidth}
						\@uppertitleback
					\end{minipage}\par
					\vfill
					\begin{minipage}[b]{\textwidth}
						\@lowertitleback
					\end{minipage}\par
					\@thanks\let\@thanks\@empty
				\fi
			\fi
			\ifx\@dedication\@empty
			\else
				\next@tdpage\null\vfill
				{\centering\usekomafont{dedication}{\@dedication \par}}%
				\vskip \z@ \@plus3fill
				\@thanks\let\@thanks\@empty
				\cleardoubleemptypage
			\fi
			\ifx\titlepage@restore\relax\else\clearpage\titlepage@restore\fi
		\end{titlepage}
		\setcounter{footnote}{0}%
		\global\let\and\relax
		\cleardoublepage
	\else
		\par
		\@tempcnta=%
		#1%
		\relax\ifnum\@tempcnta=1\else
			\ClassWarning{\KOMAClassName}{%
				Optional argument of \string\maketitle\space ignored\MessageBreak
				in `titlepage=false' mode%
			}%
		\fi
		\ifx\@uppertitleback\@empty\else
			\ClassWarning{\KOMAClassName}{%
				non empty \string\uppertitleback\space ignored
				by \string\maketitle\MessageBreak
				in `titlepage=false' mode%
			}%
		\fi
		\ifx\@lowertitleback\@empty\else
			\ClassWarning{\KOMAClassName}{%
				non empty \string\lowertitleback\space ignored
				by \string\maketitle\MessageBreak
				in `titlepage=false' mode%
			}%
		\fi
		\begingroup
		\let\titlepage@restore\relax
		\def\thefootnote{\fnsymbol{footnote}}
		\next@tdpage
		\ifx\@extratitle\@empty
			\ifx\@frontispiece\@empty\else \mbox{}\fi
		\else
			\@makeextratitle
		\fi
		\ifx\@frontispiece\@empty
			\ifx\@extratitle\@empty\else\next@tdpage\fi
		\else
			\next@tpage
			\@makefrontispiece
			\next@tdpage
		\fi
		\if@twocolumn
			\twocolumn[\@maketitle]
		\else
			\@maketitle
		\fi
		\ifx\titlepagestyle\@empty\else\thispagestyle{\titlepagestyle}\fi
		\global\let\@thanks\@empty
		\endgroup
	\fi
}

\renewcommand*{\@maketitle}{%
	\begingroup
	\setparsizes{\z@}{\z@}{\z@\@plus 1fil}\par@updaterelative
	\thispagestyle{title.BFH}
	\hbox_gset:Nn \g__ptxcd_title_box {
		\bool_if:NT \g__ptxcd_title_inverted_bool {\colorlet{BFH-Title}{white}}
		\parbox{\textwidth}{
			\__ptxcd_print_title:
		}
	}
	\null
	\skip_vertical:n {.5\box_ht:N \g__ptxcd_logo_box}
	\box_use:N \g__ptxcd_title_box
	\skip_vertical:n {\g_ptxcd_rule_height_dim+.5\box_ht:N \g__ptxcd_logo_box}
	\endgroup
	\@thanks\let\@thanks\@empty
}

\newcommand*{\versionformat}[1]{\enskip(#1)}

\cs_new:Nn 	\__ptxcd_print_title: {
	\usekomafont{disposition}
	{\usekomafont{title}\@title\par}
	\ifx\@subtitle\@empty\else{\medskip\usekomafont{subtitle}\@subtitle\par}\fi
	\bigskip
	\exp_args:NV \tl_if_eq:nnTF \g_ptxcd_pubType_tl {thesis} {
		\begin{tabular}{@{}p{0.25\linewidth}@{\quad}p{\dimexpr.75\linewidth-1em}}%
			\ifx\@degreeprogram\@empty\else
			\GetTranslation{Degreeprogram} & \@degreeprogram \\
			\fi
			\GetTranslation{Author}          & \@author          \\
			\ifx\@advisor\@empty\else
			\GetTranslation{Advisor}         & \@advisor         \\
			\fi
			\ifx\@coadvisor\@empty\else
			\GetTranslation{Co-advisor}      & \@coadvisor       \\
			\fi
			\ifx\@projectpartner\@empty\else
			\GetTranslation{Project~partner} & \@projectpartner  \\
			\fi
			\ifx\@expert\@empty\else
			\GetTranslation{Expert}          & \@expert          \\
			\fi
		\end{tabular}\par\medskip
	}{
		\ifx\@subject\@empty\else{\usekomafont{subject}\@subject\par\smallskip}\fi
		\ifx\@author\@empty\else{\usekomafont{author}\@author\par\smallskip}\fi
	}
	{
		\usekomafont{date}
		\ifx\@version\@empty\@date\else\GetTranslation{version-of-date}\fi
		\par\smallskip
	}
	\ifx\@publishers\@empty\else{\usekomafont{publishers}\@publishers\par}\fi
}

\ExplSyntaxOff

\providecommand*{\frontmatter}{%
	\if@twoside\cleardoublepage\else\clearpage\fi
	\@mainmatterfalse
	\pagenumbering{roman}%
}

\providecommand*{\mainmatter}{%
	\if@twoside\cleardoublepage\else\clearpage\fi
	\@mainmattertrue
	\pagenumbering{arabic}%
}

\providecommand*{\backmatter}{%
	\if@twoside\cleardoublepage\else\clearpage\fi
	\@mainmatterfalse
}


\RequirePackage{bfhmodule}

\LoadBFHModule{tabular,rules}
%type dependent config
\ExplSyntaxOn
\file_if_exist_input:n {bfh-\g_ptxcd_pubType_tl.cfg}
\ExplSyntaxOff

%%
%% Variables for titlepages other than the standard ones (like \title, \date, \author, etc)
%%
%%
%% AuthorVariable declarations
%%
%%  This class exposes the following variables to authors for use in the template.
%%	All variables are optional.
%%
%%  \institution{}             --- The company name i.e. Bern University of Applied Sciences
%%  \department{}              --- The department i.e. Engineering and Information Technology
%%  \institute{}               --- The instidute or faculty i.e. Micro and Medical Technology
%%  \subtitle{}                --- A document Subtitle used for some document types
%%  \version{}                 --- (optional) Document version used on some documents when supplied
%%  \titlegraphic*{}              --- (optional) Document titel page image used on some documents when supplied
%%%%%%%%%%%%%%%%%%%%%%%
%% General Variable Definitions
%%%%%%%%%%%%%%%%%%%%%%%
\providecommand*{\institution}[1]{\def\@institution{#1}}
\institution{\GetTranslation{Bern University of Applied Sciences}}

\providecommand*{\department}[1]{\def\@department{#1}}
\department{}

\providecommand*{\institute}[2][]{\def\@institute{#2}}
\institute{}

\providecommand*{\version}[1]{\def\@version{#1}}
\version{}

\providecommand{\titlefooterleft}[1]{\def\@titlefooterleft{#1}}
\titlefooterleft{%
	\begin{tabular}[b]{@{}l@{}}%
		\ifx\@department\@empty\else
		\bfhitemlabel\@department \\\par
		\fi
		\ifx\@institute\@empty\else
		\bfhitemlabel\@institute
		\fi
	\end{tabular}%
}

\providecommand{\titlefooterright}[1]{\def\@titlefooterright{#1}}
\titlefooterright{}

\endinput
%end of package bfhlayout.sty
