1

I am trying the fancyhdf.pdf page 11 example. But I find I am getting wrong headers like Foo--Foo on the first page of the Foo entry, but correctly Foo on subsequent pages. The reason seems to be that the equal{\leftmark}{\rightmark}} command is failing because \leftmark is lower case, and \rightmark is upper case. I cannot find any way to fix this. Any suggestions? My code is:

\renewcommand{\parishmarks}{% as in fancyhdr.pdf page 11, but with \nouppercase added
\ifthenelse{\equal{\leftmark}{\rightmark}}{\rightmark}{\nouppercase\rightmark--\leftmark}}

\fancyhead[L]{\chaptermark}\fancyhead[R]{\parishmarks}

See How can I achieve dictionary headers for two page spreads in LaTeX


Here is a complete example. Without the \renewcommand, the first page has "-AAA" where it should have "AAA".

\documentclass[12pt,a4paper]{article}

\usepackage{fancyhdr,ifthen}

\renewcommand{\sectionmark}[1]{} % turn off section marks

% create a command to create marks and collapse them if they are identical...
\newcommand{\mymarks}{%
\ifthenelse{\equal{\leftmark}{\rightmark}}
{\rightmark} % if equal
{`\rightmark'--`\leftmark'}} % if not equal

\renewcommand{\mymarks}{% fix the case where \rightmark is an empty string \ifthenelse{\equal{\leftmark}{\rightmark}}
{\rightmark} % if equal
{\ifthenelse{\equal{}{\rightmark}}{\leftmark}{\rightmark--\leftmark}}} % if not equal

\fancyhead[LE,RO]{\mymarks}
\fancyhead[LO,RE]{\thepage}

\pagestyle{fancy}

\begin{document}

\section{First section}\markboth{AAA}{AAA} % this goes wrong without the fix

\noindent This is the first section.

\clearpage\markboth{CCC}{BBB}

\noindent This is a new page, not a new section.

\end{document}
  • Could you provide a complete, minimal working example (MWE) that replicates the problem that the community can play with? It'll make things easier for us and you, speeding up a response time. – Werner Aug 7 '13 at 15:59
  • 1
    If you're in a hurry, there's a complete example here: Indexing an interval of words on top of every page – Alan Munn Aug 7 '13 at 16:15
  • Thanks - but making a minimal example would be hard, as it's a 500 page book. I looked at the complete example, but it's the same as what I already have. I will have to debug my code some more... – KeithB Aug 8 '13 at 8:20
  • I have a minimal example where it fails. If a new section starts at the top of a page, then the method given at tex.stackexchange.com/questions/26122/… goes wrong. For example, if this is added:\section{Adjourn section} \begin{itemize} \ditem[adjourn] \lipsum[3] \end{itemize} I would be grateful for a suggested fix. – KeithB Aug 8 '13 at 11:53
  • Here is a complete example. Without the \renewcommand, the first page has "-AAA" where it should have "AAA". – KeithB Aug 14 '13 at 10:45