0

I have a long and complex book class document, split in frontmatter mainmatter and backmatter, and using both shorttoc for a summary in the beggining and etoc for a local TOC of th appendix. With \pagestyle{headings}, the headers of the pages located after the summary and the appendix's TOC still have "Summary" or "Contents", even on pages containing some text.

Here is a MWE :

\documentclass[12pt,a4paper, oneside]{book}
\usepackage[latin1]{inputenc}
\usepackage[left=1.00cm, right=2.00cm, top=2.00cm, bottom=2.00cm]{geometry}
\usepackage{bookmark}
\usepackage{shorttoc}
\usepackage{etoc}
\usepackage{lipsum}

\pagestyle{headings}

\begin{document}

\frontmatter
\shorttoc{Summary}{0}
\chapter*{Foreword}
\lipsum[1-8]

\mainmatter
\part{ONE}
\chapter{a}
\lipsum[1-3]

\chapter{b}
\lipsum[1-3]

\part{TWO}
\chapter{c}
\lipsum[1-3]

\backmatter
\appendix
\bookmarksetup{startatroot}
\cleardoublepage \phantomsection
\chapter{Appendix}
\etocsetnexttocdepth{1}\localtableofcontents
\section{one}
\lipsum[1-6]
\section{two}
\lipsum[1-6]
\end{document}

On my document, "Summmary" is on page 1, but the word "Summary" still appears in the header of the "foreword", on p.3. Similarly, "contents" appears in the headers of the appendix, on the two last pages, where "appendix" should appear (or "one" or "two" would fit also).

Reading this question (Contents in heading where I want preface), I have seen that replacing chapter* by chapter in the frontmatter solves the problem for page 3.

For the two last pages problem, I have tried a solution proposed here : Fix "CONTENTS" in header using etoc, by Johannes B, but it didn't solve my problem.

I'm ok to use another extension rather than etoc if it does the same work without trouble, but not minitoc because it creates too much auxiliary files, considering the big number of chapters I have, and the fact that I only need one local TOC for the appendix. A solution using fancyhdr could also be good for my purpose, as long as it doesn't need too many re-organizing, because the content of the document is already done.

Thank you.

1 Answer 1

0

The starred versions of \chapter and \section don't modify the header, so it keeps showing the last label set. You can set the header yourself using \markboth.

\chapter*{Foreword}
\markboth{}{}

will clear the header, whereas

\chapter*{Foreword}
\markboth{Foreword}{Foreword}

sets the header to Foreword.

3
  • Thank you @gernot ! The problem for the foreword had already disappeared by deleting the star (as the foreword is in frontmatter, the chapters are not numbered, so the star was useless), but \markboth is very usefull for the Appendix ! I will even be able to make more precise heading, putting one \markboth in every section (some are very long) !
    – Malo
    Dec 21, 2016 at 19:47
  • @Malo There is also an optional argument to the unstarred chapter and section commands, to set a short title for header and toc: \section[Short title]{Long Title}
    – gernot
    Dec 21, 2016 at 20:14
  • Yes, this is also usefull, but I wis speaking about the length of my sections (nb of pages), not of their title. The organisation that I've chosen makes the whole Appendix get into one chapter and not a Part, but the Appendix is 400p long. When the document is already written and I'm just making some final corrections, I prefer a solution like adding markboth in every section, rather than changing a parameter of the headings only in the Appendix (e.g. with fancyhdr). I guess we are more adventurous when beggining a document, and more conservative when it's at the end.
    – Malo
    Dec 22, 2016 at 22:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .