I would like to have a different custom footer for each chapter. For e.g each chapter has a version, i would like to print that version for that chapter in the footer.
[Tex/LaTex] Different footer for each chapter
header-footer
Related Solutions
The scrpage2
commands for placing elements in the header and footer (\chead
, \ifoot
, ...) feature an optional argument that affects the scrplain
page style, which is the default style for chapter-starting pages.
\documentclass{book}
\usepackage[automark]{scrpage2}
\pagestyle{scrheadings}
\clearscrheadfoot
\chead{\headmark}
\ohead{\pagemark}
\ifoot[A remark]{A remark}
\ofoot[\pagemark]{}
\usepackage{lipsum}
\begin{document}
\chapter{foo}
\section{foobar}
\lipsum[1-12]
\end{document}
I am not entirely sure that I understand what you want but the code below:
- has a page footer on EVERY page with a line and the page number on the right-hand side
- has your page headers except on the "first" pages
Rather than using fancyhdr
etc I define the page headers and footers directly. When you type \pagestyle{mine}
what happens is that latex executes the command \ps@mine
, if it exists. The actual page headers and footers are stored in \@oddhead
, \@evenhead
, \@oddfoot
and \@evenfoot
so you just need to set these appropriately. There is also a \ps@empty
command for clearing all of the current page headers and footers.
Anyway, this is what I have done:
\documentclass[10pt,a4paper,twoside]{report}
\usepackage{mwe}
\usepackage{tcolorbox}
\usepackage[foot=4em]{geometry}% need to make the footer bigger
\makeatletter
\def\my@foot{\hbox to \textwidth{\rlap{\rule[2ex]{\textwidth}{0.4pt}}\hfill\thepage}}
\def\ps@mine{\ps@empty% clear all current headings and footings
\let\@oddfoot\my@foot\let\@evenfoot\my@foot
\def\@oddhead{Contents\hfill\includegraphics[height=22pt]{example-image-a}}
\def\@evenhead{\includegraphics[height=22pt]{example-image-a}\hfill Contents}
}
\def\ps@plain{% this seems to be the "first" page for report.cls
\ps@empty\let\@oddfoot\my@foot\let\@evenfoot\my@foot
}
\makeatother
\pagestyle{mine}
\begin{document}
\tableofcontents
\section{A}\lipsum \section{B}\lipsum \section{C}\lipsum \section{D}\lipsum
\end{document}
Perhaps the most painful part of this game is working out which pagestyle controls the first pages of chapters etc. For report.cls
this seems to be \ps@plain
, so I have changed it in order to get your line in the footer on the "first" pages as well. (For amsart
and friends I think it is \ps@firstpage
...).
If this isn't quite what you want then please explain clearly what the problems are and I will try and fine-tune.
Best Answer
Using the
fancyhdr
package, you can easily place the version at the footer. The following example illustrates this (details may vary depending on how you actually define the version). I used a\ChapVersion
command to be used at the beginning of chapters, to hold the chapter version; internally, this version is placed at the footer: