LaTeX forum ⇒ Page LayoutSection number in footer using fancyhdr Topic is solved

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

Section number in footer using fancyhdr

Postby sparktech » Tue Apr 15, 2014 8:49 am

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 2883 times

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

Postby esdd » Wed Apr 16, 2014 10:43 am

You can try

  1. \renewcommand{\sectionmark}[1]{%
  2. \markboth{\thesection}{\thesection}}
  3. \rfoot{\rightmark{} to \leftmark}


Best regards
Elke

sparktech
Posts: 6
Joined: Fri May 31, 2013 4:02 am

Postby sparktech » Thu Apr 17, 2014 11:55 am

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

Postby esdd » Fri Apr 18, 2014 11:08 am

\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

Postby sparktech » Sat Apr 19, 2014 4:25 am

Cool, thanks again!


Return to “Page Layout”

Who is online

Users browsing this forum: No registered users and 1 guest