Page LayoutHeader on some pages not correct

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
couperc
Posts: 9
Joined: Fri Apr 09, 2010 3:31 pm

Header on some pages not correct

Post by couperc »

Hi

I am having a slight problem with the header from my List of Figures carrying over into the next chapters. I have tried setting the headers at the start of the chapter but it doesn't have the desired effect. The following is the preamble etc for my doc

Code: Select all

\documentclass[12pt]{report}
\usepackage{upgreek}
\usepackage[small]{caption}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{amsmath}
\usepackage{appendix}
\usepackage{listings}
\usepackage{fancyhdr}
\usepackage{subfigure}
\usepackage{longtable}
%\usepackage{subfig}
\usepackage{tabularx}
%\usepackage[sectionbib]{bibunits}
\usepackage[square,sectionbib,numbers]{natbib}
\usepackage{chapterbib}
\usepackage{geometry}
%\usepackage[pdftex, bookmarks=true]{hyperref}
\geometry{top=20mm, bottom=20mm, left=35mm, right=20mm}
\linespread{1.5}

\begin{document}

\include{title}
\renewcommand{\sectionmark}[1]{\markright{#1}{}}

\fancypagestyle{plain}{%
    \fancyhf{} % clear all header and footer fields
    \rhead{ \thepage} % except the right top corner
    \lhead{\nouppercase{\rightmark}}
    }
\pagestyle{plain}
\tableofcontents
\pagenumbering{roman}
\listoffigures

\include{symbols}
\include{greek}
\include{const}

\include{intro }

\include{theory}

\include{chapter3}

\include{chapter6}

\include{apps}
\bibliographystyle{ieeetr}
\renewcommand\bibname{{References}}
\addcontentsline{toc}{chapter}{References}
\bibliography{thesis}
%\addcontentsline{toc}{chapter}{References}


\end{document}
What happens is the header displays "List of Figures" for the first 3 chapters (symbols, greek, const) but changes to the desired behaviour for intro onwards/

I start each of the first three chapters the same way

Code: Select all

\begin{center}
\chapter*{List of Symbols} \addcontentsline{toc}{chapter}{List of Symbols}
\end{center}
I reckon it's got something to do with \chapter*{} but I can't figure out how to rectify it without using \chapter{} (I need to use the former because of the way i want the title).

All help greatly appreciated :)

Recommended reading 2024:

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

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

User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Header on some pages not correct

Post by frabjous »

Please pay attention to the board rules and provide an actual minimal working example. No one likes having their patience tested or have to do a lot of playing around with other people's code just to see the problem that needs fixing!

The post on Avoidable Mistakes is particularly relevant here.

Putting \chapter* inside a center environment makes little sense. Use titlesec or similar package to customize the look and feel of titles.

Consider also using customized "list of" commands for a List of Symbols rather than a pseudo-chapter. There's some info on doing this on pp. 12+ of the tocloft package manual.

In any case, if you want to do things the way you are, probably you need to do the headers manually using, e.g., the \markright or \markboth commands, and/or the commands from fancyhdr, but I'm too lazy to make the changes I'd need to make to your code to test this. If you provide an actual MWE, I'm sure lots of people would be willing to provide help.
couperc
Posts: 9
Joined: Fri Apr 09, 2010 3:31 pm

Header on some pages not correct

Post by couperc »

Soz for not having a MWE - the code below should show the behaviour I'm getting (I'm using pdflatex to generate a pdf from it). On the pdf that i get, page three shows the header behavious I'm trying to correct.

Code: Select all

\documentclass[12pt]{report}
\usepackage{upgreek}
\usepackage[small]{caption}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{amsmath}
\usepackage{appendix}
\usepackage{listings}
\usepackage{fancyhdr}
\usepackage{subfigure}
\usepackage{longtable}
%\usepackage{subfig}
\usepackage{tabularx}
%\usepackage[sectionbib]{bibunits}
\usepackage[square,sectionbib,numbers]{natbib}
\usepackage{chapterbib}
\usepackage{geometry}
%\usepackage[pdftex, bookmarks=true]{hyperref}
\geometry{top=20mm, bottom=20mm, left=35mm, right=20mm}
\linespread{1.5}

\begin{document}
\renewcommand{\sectionmark}[1]{\markright{#1}{}}

\fancypagestyle{plain}{%
    \fancyhf{} % clear all header and footer fields
    \rhead{ \thepage} % except the right top corner
    \lhead{\nouppercase{\rightmark}}
    }
\pagestyle{plain}
\tableofcontents
\pagenumbering{roman}
\listoffigures

\chapter*{List of Symbols} \addcontentsline{toc}{chapter}{List of Symbols}

some stufffff

\chapter{The first thing}

\end{document}
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Header on some pages not correct

Post by frabjous »

That's not exactly a MWE since there are lots of packages left there unrelated to the problem, but it's close enough.

Yeah you can see that your headers are set up with \rightmark on the left headers. The starred version of \chapter* isn't set up to make any changes to this, so it'll stick with whatever did something with it last.

You can change the \rightmark using the \markright (or \markboth) commands

I'd put in something like:

Code: Select all

    \clearpage%
    \markright{List of Symbols}%
    \addcontentsline{toc}{chapter}{List of Symbols}%
    \chapter*{List of Symbols} 
where you currently have:

Code: Select all

    \chapter*{List of Symbols} \addcontentsline{toc}{chapter}{List of Symbols}
You can change it to whatever you want in that header.

There are fancier solutions too, but this may suffice for your purposes.
Tompoesje
Posts: 3
Joined: Thu Apr 30, 2009 4:51 pm

Header on some pages not correct

Post by Tompoesje »

I had a similar problem when writing my thesis, I decided to create a new environment for non-numbered chapters (with a option to either include or exclude it from the ToC). Perhaps you could try something similar (see attachment).

I'm sure that it's not the 'best' solution, but it gets the jobs done with a small amount of 'clutter' in your code ;-).

Code: Select all

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Premable

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\documentclass[12pt,a4paper,oneside]{book}					

\usepackage{mathptmx}
\usepackage[a4paper,top=2.5cm,bottom=2.5cm,left=2.5cm,right=2.5cm,headsep=1cm,
headheight=0.5cm,marginparwidth=0cm]{geometry}
\usepackage{ifthen}							
\usepackage{fancyhdr}	
																	
\pagestyle{fancy}							
\fancyhf{}							
\renewcommand{\headrulewidth}{0pt}		
\fancyhf[HL]{\footnotesize{\nouppercase{\leftmark}}}				
\fancyhf[HR]{\footnotesize{\textbf{\thepage}}}					

\makeatletter																																
\let\ps@plain\ps@fancy
\makeatother

\newenvironment{starchapter}[2][Chaptername]{																
\cleardoublepage																													
\fancyhf[HL]{\footnotesize{\nouppercase{#1}}}															
\chapter*{#1}																														
\ifthenelse{\equal{#2}{addtoc}}{\addcontentsline{toc}{chapter}{#1}}{}
}{
\cleardoublepage
\fancyhf[HL]{\footnotesize{\nouppercase{\leftmark}}}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Body

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\frontmatter
\begin{starchapter}[Acknowledgement]{}
Acknowledgement Text
\end{starchapter}

\begin{starchapter}[Foreword]{}
Foreword text
\end{starchapter}

\tableofcontents

\mainmatter
\begin{starchapter}[Abstract]{addtoc}
Abstract text
\end{starchapter}

\chapter{Title one}
Chapter one text

\chapter{Title two}
Chapter two text

\end{document}
[/code]
Post Reply