[texhax] How to get current section etc number into page heading or footing?

Van Snyder van.snyder at jpl.nasa.gov
Tue Feb 27 05:57:27 CET 2007

I looked at the faq at http://www.tex.ac.uk/ and couldn't find an answer
to the question "How do I get the current chapter.section.subsection etc
number into a page heading or footing?"

By "current" I mean what one would get by putting a \label immediately
before the end of the page, assuming there's nothing in the way (such as
an enumerated list item) that would get labeled by something other than
a section etc. number.

I'm not using fancyheadings or anything like that.  Here are my
header/footer definitions:

 \def\ps at headings{%
    {\hff \hdate \hfill \hftitle \hfill \vers}%
    {\hff \vers \hfill \hftitle \hfill \hdate}%
    {\hff \cpright \hfill \midfoot \hfill \thepage}%
    {\hff \thepage \hfill \midfoot \hfill \cpright}%

where I define \hff, \hftitle, \vers, \hdate, \cpright and \midfoot.
I'd like \midfoot to be the current chapter, chapter.section,
chapter.section.subsection... number.

My first thought was to use \renewcommand{\midfoot}{\@currentlabel}, but
that gets the label of an item in a list or indeed any of my special
counters if the footer falls in the middle of one of my special numbered
thing-o's, such as note boxes.

I tried to mimic how LaTeX sets \@currentlabel, but that required me to
know what was the current level of document subdivision.  So I tried
putting something into the appropriate @startsection command, but that
produced either nothing in the footer, or the index of the next document
division if that was the first thing on the next page, or the number of
the previous document division or..., probably because the stuff in #6
is processed *before* the appropriate counter is refstepcounter'd.

Thanks in advance,

Van Snyder                    |  What fraction of Americans believe 
Van.Snyder at jpl.nasa.gov       |  Wrestling is real and NASA is fake?
Any alleged opinions are my own and have not been approved or
disapproved by JPL, CalTech, NASA, the President, or anybody else.

More information about the texhax mailing list