How can I add a line under the headers of normal pages (i.e. not chapter pages, or TOC, etc) using the svmono
class?
Below is an example of what I'm trying to achieve: I'd like the headers in pages 2 & 3 to have a line below them, spanning all the page width, as shown in the 2nd figure. A copy of svmono.cls can be found here. The code that defines the headers seems to be the following, how can I insert a page-wide rule in this code?:
Snippet of svmono.cls (lines 1917-1927):
\def\ps@headings{\let\@mkboth\markboth
\let\@oddfoot\@empty\let\@evenfoot\@empty
\def\@evenhead{\runheadsize\runheadstyle\rlap{\thepage}\hfil
\leftmark}
\def\@oddhead{\runheadsize\runheadstyle\rightmark\hfil
\llap{\thepage}}
\def\chaptermark##1{\markboth{{\if@chapnum
\thechapter\thechapterend\hskip\betweenumberspace\fi ##1}}{{\if@chapnum
\thechapter\thechapterend\hskip\betweenumberspace\fi ##1}}}
\def\sectionmark##1{\markright{{\ifnum\c@secnumdepth>\z@
\thesection\seccounterend\hskip\betweenumberspace\fi ##1}}}}
Notes:
1) Modifications to svmono.cls
are OK (this is not intended to be send to the publisher)
2) I tried using fancyhdr
, but it totally messes the style of the header.
Example:
\documentclass[envcountchap,envcountchap]{svmono}
\usepackage[paperheight=220mm,paperwidth=140mm,top=1.5cm,bottom=1.5cm,inner=1cm,outer=1cm]{geometry}
\usepackage{mathptmx}
\usepackage{lipsum}
\begin{document}
\chapter{Title of chapter}
\section{Title of section}
\lipsum[1-14]
\end{document}
Actual output (undesired):
Desired output:
Updated example (titleps
almost solves it, but breaks in the bibliography!):
\documentclass[envcountchap,envcountchap]{svmono}
\usepackage[paperheight=220mm,paperwidth=140mm,top=1.5cm,bottom=1.5cm,inner=1cm,outer=1cm]{geometry}
\usepackage{mathptmx}
\usepackage{lipsum}
\usepackage{titleps}
\newpagestyle{withheadrule}{%
\headrule
\sethead[\footnotesize\thepage][][\footnotesize\thechapter~\chaptertitle]{\footnotesize\thesection~\sectiontitle}{}{\footnotesize\thepage}
\setfoot{}{}{}
}
\pagestyle{withheadrule}
\begin{document}
\chapter{Title of chapter}
\section{Title of section}
\lipsum[1-14]
\cite{dummy1,dummy2,dummy3,dummy4}
\backmatter
\bibliographystyle{plain}
\bibliography{./sample}
\end{document}
Contents of sample.bib:
@misc{dummy1,author="Dummy 1",title={\lipsum[1-4]}}
@misc{dummy2,author="Dummy 2",title={\lipsum[1-4]}}
@misc{dummy3,author="Dummy 3",title={\lipsum[1-4]}}
@misc{dummy4,author="Dummy 4",title={\lipsum[1-4]}}
Updated example output (last pages; note spurious "Reference" text added in header and footer):
Solution with fancyhdr: how to define it only on a part of the document?
\documentclass[envcountchap,envcountchap]{svmono}
\usepackage[paperheight=220mm,paperwidth=140mm,top=1.5cm,bottom=1.5cm,inner=1cm,outer=1cm,heightrounded]{geometry}
\usepackage{newtxtext,newtxmath} % <--- not mathptmx
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[RE]{\runheadsize\runheadstyle\leftmark}
\fancyhead[LO]{\runheadsize\runheadstyle\rightmark}
\fancyhead[LE,RO]{\runheadsize\runheadstyle\thepage}
\fancypagestyle{plain}{%
\renewcommand{\headrulewidth}{0pt}%
\fancyhf{}%
\fancyfoot[RE,LO]{\runheadsize\runheadstyle\thepage}%
}
\makeatletter
\renewcommand\chaptermark[1]{%
\markboth{%
\if@chapnum\thechapter\thechapterend\hskip\betweenumberspace\fi #1%
}{%
\if@chapnum\thechapter\thechapterend\hskip\betweenumberspace\fi #1%
}%
}
\renewcommand{\sectionmark}[1]{%
\markright{%
\ifnum\c@secnumdepth>\z@ \thesection\seccounterend\hskip\betweenumberspace\fi #1%
}%
}
\makeatother
% How to define a "normal" page style? or invoke the default style (i.e. non-fancy)?
\fancypagestyle{test}{%
}
\usepackage{lipsum}
\begin{document}
\pagestyle{test}
\tableofcontents
\chapter{Title of chapter}
\section{Title of section}
\lipsum[1-14]
\cite{dummy1,dummy2,dummy3,dummy4}
\pagestyle{test}
\backmatter
\bibliographystyle{plain}
\bibliography{./sample}
\end{document}