[OS X TeX] fancyhdr question

Michael Sharpe msharpe at ucsd.edu
Thu Oct 13 20:02:03 EDT 2011


On Oct 13, 2011, at 7:51 AM, Christopher Menzel wrote:

> Greetings,
> 
> I am using the article documentclass and the following header formatting:
> 
> \usepackage{fancyhdr}
> \pagestyle{fancy}
> 
> \lhead{\smaller\nouppercase{\textsc{\leftmark}}}
> \chead{}
> \rhead{\smaller\nouppercase{\textit{\rightmark}}}
> \lfoot{}
> \cfoot{\smaller\thepage}
> \rfoot{}
> 
> The documentation for fancyhdr points out that if one wants both the current section (\leftmark) and subsection (\rightmark) to appear in one's header (and the code above shows that I do), on the first page of a new section the \rightmark will be empty and hence the subsection, even though it appears on that page, will not show up in the header for that page.  The documentation then notes:
> 
>  If this is a problem you must manually insert extra \markright 
>  commands or redefine the ... \sectionmark command to issue a
>  \markboth command with two decent parameters.
> 
> Alas, although it looks like it would be easy for a TeX whiz, I have no idea how to implement these solutions.  I have spent a good bit of time trying to hunt more concrete code on the web, to no avail.  A relevant URL or a code snippet would be most appreciated.
> 

One way to do this manually is

(a) first page should start with something like

\maketitle
\thispagestyle{fancy}
\section{Introduction\markboth{}{1.1\hspace{8pt}Test}}
\verb|<intro>|
\subsection{Test\markboth{Introduction}{}}

(b) the beginning of each section should be handled with a similar \markboth, as well as any subsection on the same page.

Michael




More information about the MacOSX-TeX mailing list