TransWikia.com

Footer ruler on first page in fancyhdr with `book`

TeX - LaTeX Asked on February 8, 2021

I have a problem with the footer ruler on the first page of each chapter, it doesn’t show whilst for the the second and following page of each chapter the ruler occurs.
I found the answer: https://tex.stackexchange.com/a/344092/44119 but this is for a scrreprt and I use book. In book the chapterpagestyle does not exist.

The first page:

enter image description here

The subsequent pages:

enter image description here

My MWE:

documentclass[twoside]{book}
usepackage{lipsum}                                                                                                                 
usepackage{fancyhdr}
pagestyle{fancyplain}
fancyhead[LE]{fancyplain{}{bfseriesthepage}}
fancyhead[CE]{fancyplain{}{}}
fancyhead[RE]{fancyplain{}{bfseriesleftmark}}
fancyhead[LO]{fancyplain{}{bfseriesrightmark}}
fancyhead[CO]{fancyplain{}{}}
fancyhead[RO]{fancyplain{}{bfseriesthepage}}
fancyfoot[LE]{fancyplain{bfseriesthepage}{bfseriesthepage}}
fancyfoot[CE]{fancyplain{}{}}
fancyfoot[RE]{fancyplain{bfseriesscriptsize Generated }{bfseriesscriptsize Generated }}
fancyfoot[LO]{fancyplain{bfseriesscriptsize Generated }{bfseriesscriptsize Generated }}
fancyfoot[CO]{fancyplain{}{}}
fancyfoot[RO]{fancyplain{bfseriesthepage}{bfseriesthepage}}
renewcommand{footrulewidth}{0.4pt}

begin{document}

chapter{My Chapter}
lipsum[1]
newpage
lipsum[1]
newpage
lipsum[1]

end{document}

So my question is how to solve this:

  • what is the alternative for chapterpagestyle in book

or

  • how to directly solve it in the given MWE?

One Answer

As the first page of a chapter is in the plain style, you have to redefine it. I took the opportunity to simplify the code for the fancyplain style:

documentclass[twoside]{book}
usepackage{lipsum}
usepackage{fancyhdr}
pagestyle{fancyplain}%
renewcommand{footrulewidth}{0.4pt}
%%%
fancypagestyle{fancyplain}{%
fancyhf{}
fancyhead[LE, RO]{bfseriesthepage}
fancyhead[LO]{bfseriesrightmark}
fancyhead[RE]{bfseriesleftmark}
fancyfoot[LE, RO]{bfseriesthepage}
fancyfoot[LO, RE]{bfseriesscriptsize Generated}
}
%%%
fancypagestyle{plain}{%
fancyhf{}
fancyfoot[LE, RO]{textbf{thepage}}
fancyfoot[LO, RE]{bfseriesscriptsize Generated}
renewcommand{headrulewidth}{0pt}}

pagestyle{fancyplain}%

begin{document}

chapter{My Chapter}
lipsum[1]
newpage
lipsum[1]
newpage
lipsum[1]

end{document}

enter image description here

Answered by Bernard on February 8, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP