[Tex/LaTex] Headings with scrlayer-scrpage

koma-scriptscrlayer-scrpagesectioning

I'm new to LaTeX and this forum. I hope I can formulate the question well enough.

My document class is scrreprt, so it's one-sided, but I want to have the section in the left part of the header and the chapter in the right part on every page, with this code the output is the chapter in both cases and I want to have a headsepline under the header.

And I read that in one-page documents only right pages exist for LaTeX and every page is then considered odd. Shouldn't it be possible to write \ihead{\leftmark} for example?
And here's my code so far:

\usepackage{scrlayer-scrpage}
\pagestyle{scrheadings}
\automark[section]{chapter}  
\clearpairofpagestyles
\ihead[\leftmark]{}
\ohead[\rightmark]{}
\cfoot[\pagemark]{}

I hope you can help me!

Best Answer

Maybe the following helps:

\documentclass{scrreprt}
\usepackage{blindtext}% only for dummy text

\usepackage[
  automark,
  autooneside=false,% <- needed if you want to use \leftmark and \rightmark in a onesided document
  headsepline
]{scrlayer-scrpage}
\clearpairofpagestyles
\ihead{\leftmark}
\ohead{\ifstr{\leftmark}{\rightbotmark}{}{\rightbotmark}}
\cfoot*{\pagemark}
\renewcommand*\chapterpagestyle{scrheadings}% default pagestyle on chapter pages is plain


\begin{document}
\tableofcontents
\blinddocument
\end{document}

Result:

enter image description here

Related Question