I am trying to customize the chapter formats in different matter of the document. How can I obtain a blue bar under the chapter headers from the frontmatter ? This is the best I obtained so far...
Note: If you don't have arial font, replace by anything so you can run the example.
\documentclass[
a4paper,
oneside,
11pt,
cleardoublepage=empty,
numbers=noenddot,
titlepage,
toc=bibliography,
chapterprefix=true,
headings=chapterprefix,
toc=index,
]{scrbook}
\usepackage{textcase}
% fonts
\RequirePackage{fontspec}
%\newfontfamily\AdobeCaslonPro{Adobe Caslon Pro}
%\newfontfamily\ZapfHumnstBT{ZapfHumnst BT}
%\newfontfamily\ZapfHumnstDmBT{ZapfHumnst Dm BT}
%\newfontfamily\ZapfHumnstUltBT{ZapfHumnst Ult BT}
\newfontfamily\AdobeCaslonPro{arial}
\newfontfamily\ZapfHumnstBT{arial}
\newfontfamily\ZapfHumnstDmBT{arial}
\newfontfamily\ZapfHumnstUltBT{arial}
% colors
\RequirePackage[usenames,dvipsnames]{xcolor}
\definecolor{darkbluejebrack}{RGB}{0,141,198}
\definecolor{mediumbluejebrack}{RGB}{0,171,238}
\definecolor{lightbluejebrack}{RGB}{114,214,247}
\newcommand{\titleprefixfontsize}{\fontsize{30}{30}}
\newcommand{\titlefontsize}{\fontsize{20}{20}}
\newcommand\titlerule[1][1pt]{\rule{\textwidth}{#1}}
\newcommand{\titlesubbar}{{\color{lightbluejebrack} \rule[.4\baselineskip]{\linewidth}{1.2mm}}}
%% This is for the spacing around chapter (above and under)
\RedeclareSectionCommand[innerskip=0pt]{chapter}
\makeatletter
\newcommand\matter@switch{}
\addtokomafont{chapterentry}{\matter@switch}
\g@addto@macro\frontmatter{%
\addtocontents{toc}{%
\protect\renewcommand\protect\matter@switch{\normalfont\itshape}%
}%
\setkomafont{chapter}{\titleprefixfontsize \normalfont \bfseries \ZapfHumnstDmBT \MakeTextUppercase}%
}
\g@addto@macro\mainmatter{%
\addtocontents{toc}{%
\protect\renewcommand\protect\matter@switch{}%
}%
\setkomafont{chapter}{\titlefontsize \AdobeCaslonPro \bfseries}%
\setkomafont{chapterprefix}{\titleprefixfontsize \normalfont \bfseries \ZapfHumnstDmBT
\MakeTextUppercase}
% Add a blue line under "CHAPTER"
\renewcommand\chapterlineswithprefixformat[3]{%
#2\nobreak\vspace{-.15cm}%
\titlesubbar\par\nobreak%%
\Ifstr{#2}{}{}{\kern-\dp\strutbox}
#3%
}
}
\begin{document}
\frontmatter
\tableofcontents
\chapter{Preface}
\chapter{Acknowledgements}
\mainmatter
\chapter{First Chapter}
\chapter{Second Chapter}
\end{document}

\chapterlineswithprefixformatinstead of\sectionlinesformat. Note, that the commands have a different number of arguments. For another example see also: “How to put a horizontal line above and below chapter headings” in the KOMA-Script Wiki. – cabohah Jan 18 '23 at 07:10