2

I'm taking notes for my classes, and it would be nice to include the session number and date in the footer, I'm aware of custom footers using fancyhdr (custom footer for each page, chapter), but I was wishing to find something similar in functionality to \centering and \raggedleft

like \newfooter{session 1, 4 October 2021}, and that will be added to all pages following this until the next command \newfooter{sessoin 2, 5 October 2021}

I think changing fancyhdr style will make the trick like in this question, but I don't know how to apply it to my situation.

Note I'm using book document class, and I don't want to interfere with its header (and footer in each chapter beginning)

Your help is appreciated

1 Answer 1

4

You can use the following as a starting point. It defines \newfooter to update \customfooter - a macro that is set in the footer on pages other than the starting chapter page. Since footers are bound to a page style, the page would probably need to be shipped out (turned) with each \newfooter. So, the starred version \newfooter* doesn't issue a \clearpage, while \newfooter (the unstarred version) does.

\documentclass{book}

\usepackage{fancyhdr}
\usepackage{lipsum}

\fancyhf{}% Clear header/footer
\fancyfoot[C]{\customfooter}
\fancyhead[LE,OR]{\thepage}
\pagestyle{fancy}
\newcommand{\customfooter}{}% Define \customfooter to be empty at the start

\NewDocumentCommand{\newfooter}{s m}{%
  \IfBooleanF{#1}{\clearpage}% \newfooter* doesn't \clearpage 
  \renewcommand{\customfooter}{#2}% Store new footer
}

\begin{document}

\chapter{First chapter}

\newfooter*{Session 1, 4 October 2021}% Stay on current page

\lipsum[1-4]

\newfooter{Session 2, 5 October 2021}% Just to new page

\lipsum[5-10]

\end{document}

The concept is simple: Use \customfooter in the footer, and update \customfooter with the argument supplied to \newfooter.

2
  • How can I make footer alignment alternate between odd and even pages? (thank you) Oct 11, 2021 at 14:20
  • 1
    \fancyfoot[LE,RO] or [LO,RE] Oct 11, 2021 at 15:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .