The first pages of ToC, LoF, LoT is always pagestyle plain
, like all other first chapter pages. This causes the chosen page style tocstyle
not to be effective on these first pages.
Update: Added a solution with the plain
definitions inside the other pagestyles.
- One solution this would be to redefine
plain
to be the same as tocstyle
before the ToC etc. and then redefine it to be the desired plain
style for the document after the \clearpage
that separates these ToC pages from the main document. A comprehensive way to do this would be to include the \fancypagestyle{plain}...
inside the other \fancypagestyle
definitions, thereby bundling them up with these page styles. See Solution 1.
- Another way is to inject an additional
\thispagestyle{tocstyle}
in the ToC, LoF and LoT with commands like
\addtocontents{toc}{\protect\thispagestyle{tocstyle}}
This needs an additional LaTeX run to get effectuated. See Solution 2.
Here are the complete solutions with these ideas. For demonstration purposes I have added the name of the page style in the left footer so that you can clearly see where it comes from.
Solution 1:
\documentclass[a4paper,12pt,oneside]{report}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{blindtext}
\usepackage{lastpage}
\fancypagestyle{document}{%
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\fancyfoot[R]{\thepage\ |\ \pageref{LastPage}}
\fancyfoot[L]{document}
\fancypagestyle{plain}{%
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\fancyfoot[R]{\thepage\ |\ \pageref{LastPage}}
\fancyfoot[L]{plain-document}
}
}
\fancypagestyle{tocstyle}{%
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\fancyfoot[R]{\thepage}
\fancyfoot[L]{tocstyle}
% Make plain pagestyle the same as tocstyle
% The optional argument needs fancyhdr version 4.0 or later.
% Otherwise you have to copy all the definitions from tocstyle.
\fancypagestyle{plain}[tocstyle]{\fancyfoot[L]{plain-tocstyle}}
}
\begin{document}\sloppy
\pagenumbering{Roman}
\pagestyle{tocstyle}
\tableofcontents
\listoffigures
\listoftables
\clearpage
\pagenumbering{arabic}
\pagestyle{document}
\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument
\end{document}
Solution 2:
\documentclass[a4paper,12pt,oneside]{report}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{blindtext}
\usepackage{lastpage}
\fancypagestyle{document}{%
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\fancyfoot[R]{\thepage\ |\ \pageref{LastPage}}
\fancyfoot[L]{document}
}
\fancypagestyle{plain}{%
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\fancyfoot[R]{\thepage\ |\ \pageref{LastPage}}
\fancyfoot[L]{plain}
}
\fancypagestyle{tocstyle}{%
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\fancyfoot[R]{\thepage}
\fancyfoot[L]{tocstyle}
}
\begin{document}\sloppy
\pagenumbering{Roman}
\pagestyle{tocstyle}
\addtocontents{toc}{\protect\thispagestyle{tocstyle}}
\addtocontents{lot}{\protect\thispagestyle{tocstyle}}
\addtocontents{lof}{\protect\thispagestyle{tocstyle}}
\tableofcontents
\listoffigures
\listoftables
\clearpage
\pagenumbering{arabic}
\pagestyle{document}
\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument
\end{document}
