views:

202

answers:

2

Hi,

I am writing up my thesis in Latex and have a template. It works nicely for every thing else except one. Chapter numbers are correctly incremented on the first page of each chapter but for consecutive pages of each chapter, the header saying "Chapter x - This is a chapter title" have 1 always as chapter number.

Following is the code sample from the CLS file which i think is relevant to the headers:

\newcommand\btypeout[1]{\bhrule\typeout{\space #1}\bhrule}
\def\today{\ifcase\month\or
  January\or February\or March\or April\or May\or June\or
  July\or August\or September\or October\or November\or December\fi
  \space \number\year}
\usepackage{setspace}
\onehalfspacing
\setlength{\parindent}{0pt}
\setlength{\parskip}{2.0ex plus0.5ex minus0.2ex}
\usepackage{vmargin}
\setmarginsrb           { 1.5in}  % left margin
                        { 0.6in}  % top margin
                        { 1.0in}  % right margin
                        { 0.8in}  % bottom margin
                        {  20pt}  % head height
                        {0.25in}  % head sep
                        {   9pt}  % foot height
                        { 0.3in}  % foot sep
\raggedbottom
\setlength{\topskip}{1\topskip \@plus 5\p@}
\doublehyphendemerits=10000       % No consecutive line hyphens.
\brokenpenalty=10000              % No broken words across columns/pages.
\widowpenalty=9999                % Almost no widows at bottom of page.
\clubpenalty=9999                 % Almost no orphans at top of page.
\interfootnotelinepenalty=9999    % Almost never break footnotes.
\usepackage{fancyhdr}
\lhead[\rm\thepage]{\fancyplain{}{\sl{\rightmark}}}
\rhead[\fancyplain{}{\sl{\leftmark}}]{\rm\thepage}
\chead{}\lfoot{}\rfoot{}\cfoot{}
\pagestyle{fancy}

%% Chapter Heading ---------------
\renewcommand{\chaptermark}[1]{\btypeout{\thechapter\space #1}\markboth{\@chapapp\ \thechapter\ #1}{\@chapapp\ \thechapter\ #1}}

%%--------------------------------------------------
\renewcommand{\sectionmark}[1]{}
\renewcommand{\subsectionmark}[1]{}
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
\hbox{}
\thispagestyle{empty}
\newpage
\if@twocolumn\hbox{}\newpage\fi\fi\fi}

Thanks, Omer

A: 

have you tried clearing the headers and footers before calling commands into them with the fancyhdr package?

something like this:

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{} % Clear Headers
\fancyfoot{} % Clear Footers
\lhead[\rm\thepage]{\fancyplain{}{\sl{\rightmark}}}
\rhead[\fancyplain{}{\sl{\leftmark}}]{\rm\thepage}
\chead{}\lfoot{}\rfoot{}\cfoot{}
Mica
Hi Mica,Thanks for your reply. I tried this trick with clearing headers and footers but it's did't work :(((Any other ideas?CheersOmer
I also tried \fancyhf{} but it didn't work either to reset the headers!
have you tried commenting out all the re-defined chaptermarks below where you are calling fancyhdr?
Mica
A: 

Although I am not using the same template as you, my solution to a similar problem involved three packages: sectsty, fancyhdr, and partpg (my rewriting of chappg to give the same effect to parts as chappg does for chapters).

I set out below portions of my header code. You will see from my comments in that code that there is still one unresolved problem, but the comments give a workaround.

%----------------------------------------------------------
\usepackage{sectsty} % Fancy section Headers.
\usepackage{fancyhdr} % Headers and footers.
\usepackage[auto]{partpg} % Modified version of chappg to provide part-pageno type page numbering.
\usepackage{appendix} % Multiple appendix sections in multi part document.
\usepackage[style=altlist,toc=true]{glossary} % Enhanced glossary commands.
%----------------------------------------------------------
\makeglossary
% There is a conflict between partpg and makeglos.
% To generate the glossary, run makeglos AFTER removing the next line.
\renewcommand{\partpgsep}{.}
\renewcommand{\glossaryname}{Glossary}
\setlength{\headheight}{13.6pt}
\pagestyle{fancy}%
{% Ensure appendices in different parts restart numbering at A each time 
\renewcommand{\restoreapp}{} 

\fancypagestyle{plain}{% Redefine style to use the relevant elements on the part pages
\fancyhfoffset[LE,RO]{\marginparsep+\marginparwidth}
\renewcommand{\headrulewidth}{0.1pt}
\renewcommand{\footrulewidth}{0.1pt}
\fancyhead[LE,RO]{\leftmark}
\fancyfoot[LE,RO]{\thepage}}%

\makeatletter% Redefine cleardoublepage so blank pages at the end of chapters have desired header.
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
  \hbox{}
  \vspace*{\fill}
  \pagestyle{plain}
  \newpage
  \if@twocolumn\hbox{}\newpage\fi\fi\fi}
\makeatother

\fancyhead{}
\fancyfoot{}
%----------------------------------------------------------
\begin{document}
\end{document}
%----------------------------------------------------------

If this takes you forward, and you want to have details of my coding in partpg please comment on this answer.

Chris Walton