Page LayoutSection number in footer using fancyhdr

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
sparktech
Posts: 6
Joined: Fri May 31, 2013 4:02 am

Section number in footer using fancyhdr

Post by sparktech »

Hi all,

I'm working on a set of carry-in notes for exams, made up of a bunch of court cases. Each case starts with a \section which has the case name, year etc. There are multiple \section commands on a page. What I'd like in the footer is a note that gives the section numbers which appears on the page as shown on the example image.

I'm using the fancyhdr package to lay out the custom footer, but I'm not sure how I can get the number of the first section that appears on any given page (the letter 'X' in the example image). The \thesection command in the fancyhdr package places the last section of the page (the number '5' in the example image) in the footer. Any suggestions welcome; I don't have to use the fancyhdr package.

Thanks! :)
Screen Shot 2014-04-15 at 6.41.47 PM.PNG
Screen Shot 2014-04-15 at 6.41.47 PM.PNG (291.52 KiB) Viewed 4748 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

esdd
Posts: 36
Joined: Sat Jan 25, 2014 9:13 pm

Section number in footer using fancyhdr

Post by esdd »

You can try

Code: Select all

\renewcommand{\sectionmark}[1]{%
  \markboth{\thesection}{\thesection}}
\rfoot{\rightmark{} to \leftmark}
Best regards
Elke
sparktech
Posts: 6
Joined: Fri May 31, 2013 4:02 am

Re: Section number in footer using fancyhdr

Post by sparktech »

Thank you, it works perfectly!! Can you please explain how the code works? I know \renewcommand is reconfiguring the \sectionmark command, but after that I'm lost.
esdd
Posts: 36
Joined: Sat Jan 25, 2014 9:13 pm

Re: Section number in footer using fancyhdr

Post by esdd »

\sectionmark is called by every \section command. Then the first argument of \markboth sets a left mark and the second sets a right mark. \rightmark uses the first right mark on a page and \leftmark uses the last.
sparktech
Posts: 6
Joined: Fri May 31, 2013 4:02 am

Re: Section number in footer using fancyhdr

Post by sparktech »

Cool, thanks again!
Post Reply