0

I am working with the KOMA-script class scrbook. Last week I asked this question about the page style see this and it was solved. However, I want a new format for my document, I would like keeping the format that my document already have (see below MWE) but I want the first page of each chapter with the page number centred in the footer, just the page number so I tried using \renewcommand*{\chapterpagestyle}{plain} but this does nothing to the document even though \renewcommand*{\chapterpagestyle}{empty} does work. Does anyone know a way to solve this?

Thanks in advance

\documentclass[12pt,headsepline,chapterprefix=true]{scrbook}
\usepackage{mathtools}
\usepackage{scrlayer-scrpage}
\usepackage{hyperref}
\usepackage{xpatch}
\usepackage{lipsum}

\automark[chapter]{chapter}
\automark*[section]{}

\clearpairofpagestyles
\ihead{\bfseries\headmark}
\ohead*{\pagemark}

\xapptocmd{\mainmatter}{\KOMAoptions{open=any}}{}{\PatchFailed}

\renewcommand*{\chapterpagestyle}{plain} %this works with "empty"

\begin{document}

\frontmatter

\tableofcontents
\thispagestyle{empty}
\addtocontents{toc}{\protect\thispagestyle{empty}}

\chapter{Acknowledgements}
\lipsum[1-2]
\chapter{Abstract}
\lipsum[3-4]
\mainmatter
\chapter{Int}
\lipsum[5-10]
\chapter{ Two }
\lipsum[11-16]
\section{Two1}
\lipsum[16-22]

\end{document}

2 Answers 2

2

\renewcommand*{\chapterpagestyle}{plain} works fine. You simply have redefined the plain style to put the page number in the header.

Change your page style definition to

\clearpairofpagestyles
\ihead{\bfseries\headmark}
\ohead{\pagemark}
\cfoot[\pagemark]{}

then it will work as expected. You even don't need to redefine the chapter page style.

\documentclass[12pt,headsepline,chapterprefix=true]{scrbook}
\usepackage{mathtools}
\usepackage{scrlayer-scrpage}
\usepackage{hyperref}
\usepackage{xpatch}
\usepackage{lipsum}

\automark[chapter]{chapter}
\automark*[section]{}

\clearpairofpagestyles
\ihead{\bfseries\headmark}
\ohead{\pagemark}
\cfoot[\pagemark]{}

\xapptocmd{\mainmatter}{\KOMAoptions{open=any}}{}{\PatchFailed}


\begin{document}

\frontmatter

\tableofcontents
\addtocontents{toc}{\protect\thispagestyle{empty}}

\chapter{Acknowledgements}
\lipsum[1-2]
\chapter{Abstract}
\lipsum[3-4]
\mainmatter
\chapter{Int}
\lipsum[5-10]
\chapter{ Two }
\lipsum[11-16]
\section{Two1}
\lipsum[16-22]

\end{document}
2
  • So the automark is enough to keep the format? I thought I had the put it explicitly. Thank you. Commented Jan 1, 2020 at 0:31
  • @Alberto plain is the predefined chapter page style. So there is no need to redefine \chapterpagestyle.
    – esdd
    Commented Jan 1, 2020 at 11:15
1

Here I have used and modified myheading macros, use the below macro just above the \begin{document}

\makeatletter
\renewcommand*{\ps@myheadings}{\let\@mkboth\@gobbletwo
  \renewcommand*{\@oddhead}{}%
  \let\@evenhead\@oddhead   
   \renewcommand*{\@evenfoot}{%
    \set@tempdima@hw\hss\hb@xt@ \@tempdima{\vbox{%
        \if@fsl \hrule \vskip 3\p@ \fi
        \hb@xt@ \@tempdima{{\hfil\pagemark\hfil}}}}}%
  \renewcommand*{\@oddfoot}{%
    \set@tempdima@hw\hb@xt@ \@tempdima{\vbox{%
        \if@fsl \hrule \vskip 3\p@ \fi
        \hb@xt@ \@tempdima{{\hfil\pagemark\hfil
            \if@twoside\else\hfil\fi}}}}\hss}%
  \renewcommand*{\chaptermark}[1]{}%
  \renewcommand*{\sectionmark}[1]{}%
}
\makeatother

\renewcommand*{\chapterpagestyle}{myheadings}

Hope it helps!!!

3
  • Thanks! It worked. However it adds a header in the first page of the chapter which was not there. Commented Dec 31, 2019 at 6:19
  • I have updated the above myheading macro.
    – Saravanan
    Commented Dec 31, 2019 at 6:28
  • Now it works, thanks! Commented Jan 1, 2020 at 0:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .