[texhax] Custom Headers

Karthik Narayanaswamy kn5d at virginia.edu
Fri Oct 6 23:47:23 CEST 2006


Folks,

I have an article class document with sections, subsections and 
subsubsections. I want the headers of the document to read the section 
name (without number), except on pages where I start a new section. 
After trying my hand with published solutions on the web using 
fancyhdr.sty and associated \leftmark and \rightmark, I decided instead 
to write my own macro.

I included this in my custom Section macro:

\newcommand{\Section}[1]{
    \section{#1}
    \thispagestyle{empty}
    \def\Sec{#1}
% Other lines irrelevant to this e-mail
}

The headers were then defined as:
    \pagestyle{fancy}
    \fancyhf{}
    \lhead{\Sec}

Simple enough, and it works ... well, sort of. I found that when a 
section starts at the bottom of a page, LaTeX is smart enough to move 
the section to a new page, but the \pagestyle{empty} command still 
applies to the previous page. That is, I end up with the page where the 
section really starts with a header, and the previous page with no 
headers. Any idea how I might get around this? I've only been using 
LaTeX a couple of months and am not savvy enough to fix this.

Cheers,
Karthik
_______________________________________________
Karthik Narayanaswamy
Doctoral Candidate
Department of Civil Engineering, Thornton Hall B220B
University of Virginia
351 McCormick Road
Charlottesville, VA22904-4742

Web: www.people.virginia.edu/~kn5d
e-mail: kn5d at virginia.edu (Best way to reach me)
MRI Lab: 434-924-7168
Bacterial Lab: 434-982-2839



More information about the texhax mailing list