In my MNWE I try to change style for section in two column scrbook document. In same time I want to have page header also on pages where the first text line is the section header.
In my code I am loosing the setting of the page header because the section behaves in same manner like chapter. If the page contains only paragraphs it works as I want.
I try to use \AddtoDoHook technique but without success (therefore it is commented in MNWE).
MNWE:
% https://tex.stackexchange.com/questions/662860/komascript-section-header-over-two-column-text-layout
\documentclass[a4paper,11pt,twocolumn, chapterprefix=on]{scrbook}
\usepackage{blindtext}
\usepackage{lipsum}
\usepackage{xcolor}
\usepackage[headsepline, automark]{scrlayer-scrpage}
\usepackage{currfile}
\pagestyle{scrheadings}
\setkomafont{pageheadfoot}{\normalfont\normalcolor\itshape\small}
\setkomafont{pagenumber}{\normalfont\bfseries}
\chead{\currfilename}
% https://tex.stackexchange.com/questions/114570/koma-script-scrpage2-footer-height
\ihead{\pagemark} % scrguien page 255
\ofoot[]{} % remove pagenumber from outer foot
\cfoot[]{} % remove pagenumber from centre foot
% \AddtoDoHook appends persistent code to the hook named name.
% @gobble: https://tex.stackexchange.com/questions/85796/why-does-gobble-take-one-argument
\RedeclareSectionCommand[style=chapter]{section}
\makeatletter
\AddtoDoHook{heading/begingroup/section}{\KOMAoptions{chapterprefix=false}@gobble}
% \AddtoDoHook{heading/begingroup/section}{\pagestyle{scrheadings}@gobble}
% \AddtoDoHook{heading/begingroup/section}{\ihead{\pagemark} @gobble}
% \chapterlinesformat{level}{number}{text}
\renewcommand{\chapterlinesformat}[3]{%
@tempswafalse
% \Ifstr{string 1}{string 2}{then code}{else code} page 346 scrguide-en 3.38
\Ifstr{#1}{section}{%
\color{white}
\colorbox{black}{%
\parbox{\dimexpr\linewidth-2\fboxrule-2\fboxsep}{%
\raggedsection
@hangfrom{#2}{#3}%
}%
}%
]%
}{%
@hangfrom{#2}{#3}%
}%
}
\makeatother
\RedeclareSectionCommand[style=chapter,pagestyle=scrheadings]{section}– esdd Oct 25 '22 at 14:52