0

I am writing a book in twoside book documentclass. I am using the following code snippet to modify my headers and footers.

% Header-Footer
\usepackage[english]{babel}
\renewcommand\cftsecpresnum{\S}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE,RO]{\rightmark}
\fancyhead[LO,RE]{\leftmark}
\fancyfoot[C]{\thepage}
\renewcommand{\chaptermark}[1]{\markboth{\MakeUppercase{\thechapter.\ #1}}{}}
\renewcommand{\sectionmark}[1]{\markright{\S\thesection.\ #1}}

And here is my Exercises environment:

\newlist{exercise}{enumerate}{5}
\setlist[exercise]{
    label*=\thechapter.\arabic*.,
    ref=\thechapter.\arabic*, 
    before={%
        \section*{\hfil{Exercises -- \thechapter}}%
        \addcontentsline{toc}{section}{Exercises -- \thechapter}%
        \setlist*[enumerate,1]{ref=\theexercisei.~\arabic*}%
        \setlist*[enumerate,2]{ref=\theenumi.(\alph*)}%
    },
}
\setlist*[enumerate,2]{ref=\theenumi.(\alph*)}

Here are the issues I am looking solutions for:

  1. The section name Exercises is not showing up in the header. Insted, the header is continuing with the last section name.enter image description here

  2. The Bibliography and the Index pages are showing the chapter names in both left and right headers.enter image description here enter image description here In the Bibliography and Index chapters, I want to get rid of the chapter names appearing in the sectionname space.

I am a bit confused about what to include in an MWE. If anybody needs one, please ask me about things that might be affecting this and I will include them and post an MWE.

  • 2
    \section* doesn't set the right mark, so add \markright{...} with the same text as used for the section heading, right after launching the \section* in the \setlist{exercise}. Similarly, when launching the bibliography and index, insert \markright{ } in a place that will take effect before the first page of that chapter is complete; this may be just before the \bibliography or \printindex commands, and it may be necessary to insert \newpage before the \markright`. (not tested) – barbara beeton Mar 23 at 23:55
  • Thanks a lot! They worked. Only thing is that I needed to put \markright{} after \bibliography{...} and \printindex` commands. Why don't you make it an answer so that I can upvote this? – Subhajit Paul Mar 24 at 6:35
1

In many document classes (including the basic book), \section* doesn't set the right mark, so add \markright{...} with the same text as used for the section heading, right after launching the \section*. Here, that should be done in the \setlist{exercise} definition.

Similarly, when launching the bibliography and index, insert an empty \markright{} in a place that will take effect before the first page of that chapter is complete. The mark command will take effect on the page where it is read in by (La)TeX.

Where the mark is inserted depends on how these starred components (\chapter* or \section*) are defined and used. Assume that they are launched by\bibliographyand\printindex. With these commands, the starred command is part of those definitions, and thus will appear in a derived file (.bblor.ind`) instead of in the main source file. If such a component is more than one page long, placing the mark command after the component-launching command will delay the inclusion of the mark in the page heading until the page when it is read.

It is inadvisable to make manual changes in a .bbl or .ind file as those files will be regenerated with the next LaTeX run. In such a case, the mark command should be inserted just before the component-launching command (\bibliography or \printindex), preceded by \newpage so that the changed heading doesn't appear before it is wanted.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.