[Tex/LaTex] Header for frontmatters using scrpage2

front-matterheader-footerkoma-scriptscrpage2

How to set page numbers for front matters similar to main matters. Main matters header need to have chapter title also. Not added in MWE. Front matters must have only page number as in main matters of MWE.

%
\documentclass[12pt]{scrbook}

\usepackage{scrpage2}
\usepackage{amsmath}
\usepackage{graphicx}

\title{Your Paper}
\author{You}

\begin{document}
\frontmatter
\maketitle
\tableofcontents

\mainmatter
\pagestyle{scrheadings}
\clearscrheadfoot
\ohead[\pagemark]{\pagemark}
\chapter{First}
\section{Introduction}
Text

\section{Some Examples}
Text

\subsection{Sections}
Text

\clearpage
\subsection{Tables and Figures}
Text

\end{document}

Best Answer

Use the scrplain pagestyle for \frontmatter, and switch to scrheadings for \mainmatter. Optionally, redefine the \chapterpagestyle command at \mainmatter. If you want the first pages of frontmatter and mainmatter chapters to show no header/footer at all, add \renewcommand*{\chapterpagestyle}{empty} to the preamble.

\documentclass[12pt]{scrbook}

\usepackage{scrpage2}
\clearscrheadfoot
\ohead[\pagemark]{\pagemark}
\ihead{\leftmark}

\renewcommand*{\chapterpagestyle}{empty}

\begin{document}

\frontmatter
\pagestyle{scrplain}

\title{Your Paper}
\author{You}
\maketitle

\tableofcontents

\mainmatter
\pagestyle{scrheadings}
% \renewcommand*{\chapterpagestyle}{scrheadings}% optional

\chapter{First}
\section{Introduction}
Text

\addtocontents{toc}{\protect\clearpage}% just for the example

\section{Some Examples}
Text

\subsection{Sections}
Text

\clearpage
\subsection{Tables and Figures}
Text

\end{document}