For this task and similar ones, the zref
package comes in handy. Based on the abspage
and thepage
modules provided by this package, you can define a macro \chappagerangelabel
as follows:
\documentclass{scrbook}
\usepackage{calc}
\usepackage[abspage, thepage]{zref}
\usepackage{scrpage2}
\usepackage{lipsum}% lorem ipsum placeholder text
\makeatletter
\newcounter{chappagerange}% auxiliary counter
\newcounter{chappointer}% auxiliary counter
\stepcounter{chappointer}% value 1 for first chapter
\newcommand*{\chappagerangelabel}{%
\zref@label{chappagerange:\the\value{chappointer}}%
\setcounter{chappagerange}{\zref@extract{chappagerange:\the\value{chappointer}}{abspage}}%
\edef\thechappagerange{\zthepage{\the\value{chappagerange}}}% first page
\stepcounter{chappointer}%
\setcounter{chappagerange}{\zref@extract{chappagerange:\the\value{chappointer}}{abspage}-1}%
\edef\thechappagerange{pp.~\thechappagerange--\zthepage{\the\value{chappagerange}}}% first page--last page
}
Now, define a macro \pagerangemark
modelled after \pagemark
:
\DeclareRobustCommand*{\pagerangemark}{%
{\pnumfont\thechappagerange}%
}
\makeatother
Put \chappagerangelabel
at the very beginning of each chapter and immediately after the last chapter and use \pagerangemark
in \ofoot
:
\begin{document}
\pagestyle{scrheadings}
\clearscrheadfoot
\cfoot[\pagemark]{\pagemark}
\chead[]{\headmark}
\frontmatter
\noindent
Text
\mainmatter
\ofoot[\pagerangemark]{\pagerangemark}
\chapter{A Chapter}
\chappagerangelabel
\lipsum[1-20]
\chapter{Another Chapter}
\chappagerangelabel
\lipsum[21-40]
\backmatter
\chappagerangelabel
\ofoot[]{}
\noindent
Text
\end{document}
Note that this solution does not allow for the case that the last page of the last chapter is also the last page of the whole document. Apart from that, it should work smoothly.