[Tex/LaTex] scrlayer-scrpage: different styles for different pages

koma-scriptscrlayer-scrpage

thanks to this site I was able to get a functional implementation of scrlayer-scrpage.

\documentclass[12pt,headsepline,footsepline,plainfootsepline,plainheadsepline]{scrreprt}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{geometry}
\geometry{verbose,tmargin=3.5cm,bmargin=3.5cm,lmargin=3cm,rmargin=2.5cm,headheight=33pt}
\usepackage{graphicx}
\usepackage{xcolor,calc}
\definecolor{mygreen}{RGB}{23,156,125}
\usepackage{kantlipsum}

\usepackage{scrlayer-scrpage}

\setkomafont{pageheadfoot}{\upshape}
\setkomafont{pagehead}{\slshape}
\setkomafont{headsepline}{\color{mygreen}}
\setkomafont{footsepline}{\color{mygreen}}
\pagestyle{scrheadings}
\automark{chapter}
\ihead{\leftmark\hfill \includegraphics[height=1cm]{IMG/Logo.jpg}}
\ohead{}
\chead{}
\ofoot*{\thepage}
\cfoot*{}
\chead{}
\ihead*{\leftmark\hfill \includegraphics[height=1cm]{IMG/Logo.jpg}}

\begin{document}
    \chapter*{Some chapter}
    \tableofcontents{}
    \part{Hello}
    \chapter{Some chapter}
    \kant[1-10]
\end{document}

This works as intended but I would like to have two changes. The chapter "Some Chapter" which does not show in the TOC should have its title in the header alongside with the logo but without the page number. And the "parts" page should have two logos in the header instead of title and logo. I tried it with

\newpairofpagestyles{speciallayout}{
\ihead{\leftmark\hfill \includegraphics[height=1cm]{IMG/Logo.jpg}
\ofoot{}
\ofoot*{}}

but this didn't work.

Thanks in advance

Jon

Best Answer

Note that the unstarred version of \ihead sets only the content of the main page style while the starred version sets both. There is no need to use both if their argument ist the same.

On the first page of a chapter the plain style of the current pairofpagestyles is used. So you could define

\newpairofpagestyles[scrheadings]{specialchapter}{\ofoot*{}}

Then the pair of page styles specialchapter is a child of scrheadings with an empty outer footer.

To get the unnumbered chapter title in the header but not in table of contents use option headings=optiontoheadandtoc and use \addchap[tocentry={}]{Some chapter} instead \chapter*{Some chapter}.

Additionally you can define the page style for the part page by

\newpairofpagestyles[scrheadings]{part}{%
  \ihead*{\includegraphics[height=1cm]{IMG/Logo.jpg}\hfill\includegraphics[height=1cm]{IMG/Logo.jpg}}%
}
\renewcommand\partpagestyle{part}

enter image description here

enter image description here

Code:

\documentclass[12pt,headsepline,footsepline,plainfootsepline,plainheadsepline,
  headings=optiontoheadandtoc% <- added
]{scrreprt}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{geometry}
\geometry{verbose,tmargin=3.5cm,bmargin=3.5cm,lmargin=3cm,rmargin=2.5cm,headheight=33pt}
\usepackage[demo]{graphicx}
\usepackage{xcolor,calc}
\definecolor{mygreen}{RGB}{23,156,125}
\usepackage{kantlipsum}

\usepackage[automark]{scrlayer-scrpage}
\clearpairofpagestyles
\ihead*{\leftmark\hfill \includegraphics[height=1cm]{IMG/Logo.jpg}}
\ofoot*{\pagemark}
%\ifoot*{\currentpagestyle}% only to show which page style is active

\setkomafont{pageheadfoot}{\upshape}
\setkomafont{pagehead}{\slshape}
\setkomafont{headsepline}{\color{mygreen}}
\setkomafont{footsepline}{\color{mygreen}}

\newpairofpagestyles[scrheadings]{specialchapter}{\ofoot*{}}

\newpairofpagestyles[scrheadings]{part}{%
  \ihead*{\includegraphics[height=1cm]{IMG/Logo.jpg}\hfill\includegraphics[height=1cm]{IMG/Logo.jpg}}%
}

\renewcommand\partpagestyle{part}

\begin{document}
    \pagestyle{specialchapter}
    \addchap[tocentry={}]{Some chapter}
    \cleardoublepage
    \pagestyle{scrheadings}
    \tableofcontents{}
    \part{Hello}
    \chapter{Some chapter}
    \kant[1-10]
\end{document}