6

In my TOC, on pages where there chapter titles listed, the page header needs to contain the word "CHAPTER". However, on pages where only appendix titles are listed, the TOC header needs to read "APPENDIX." Is it possible to change the header midway through the TOC like this? I am using the memoir class.

update: I should have mentioned I am using a style package provided by my school. I'll give a MWE that is based on that style file and also give the relevant-seeming passage from the style file as well. First the MWE:

\documentclass[oneside,12pt]{memoir}
\setsecnumdepth{subsection}
\maxtocdepth{subsection}
\usepackage{appendix}
\usepackage{pwasu} 

\begin{document}
\DoubleSpacing
\pagestyle{plain}
\frontmatter

\tableofcontents
\listoftables
\listoffigures

\mainmatter

\pagestyle{plain} 

\addtocontents{toc}{\noindent\normalfont{CHAPTER}\par}
\chapter{Chapter the Next} 
\chapter{Chapter the Next} 
\section{My Next Section}
\subsection{And another subsection}
\subsection{And another subsection}
\subsection{And another subsection}
\section{My Next Section}
\subsection{And another subsection}
\subsection{And another subsection}
\subsection{And another subsection}
\section{My Next Section}
\subsection{And another subsection}
\subsection{And another subsection}
\subsection{And another subsection}
\chapter{Chapter the Next} 
\section{My Next Section}
\subsection{And another subsection}
\subsection{And another subsection}
\subsection{And another subsection}
\section{My Next Section}
\subsection{And another subsection}
\subsection{And another subsection}
\subsection{And another subsection}
\section{My Next Section}
\subsection{And another subsection}
\subsection{And another subsection}
\subsection{And another subsection}
\chapter{Chapter the Next} 
\section{My Next Section}
\subsection{And another subsection}
\subsection{And another subsection}
\subsection{And another subsection}
\section{My Next Section}
\subsection{And another subsection}
\subsection{And another subsection}
\subsection{And another subsection}
\section{My Next Section}
\subsection{And another subsection}
\subsection{And another subsection}
\subsection{And another subsection}
\chapter{Chapter the Next} 
\section{My Next Section}
\subsection{And another subsection}
\subsection{And another subsection}
\subsection{And another subsection}
\section{My Next Section}
\subsection{And another subsection}
\subsection{And another subsection}
\subsection{And another subsection}
\section{My Next Section}
\subsection{And another subsection}
\subsection{And another subsection}
\subsection{And another subsection}

\addtocontents{toc}{\noindent\normalfont{APPENDIX}\par}
\appendix
\chapter{Now I have an appendix} 
\chapter{Now I have an appendix} 
\section{Appdx. section }
\section{Appdx. section }
\section{Appdx. section }
\chapter{Now I have an appendix} 
\section{Appdx. section }
\section{Appdx. section }
\section{Appdx. section }
\chapter{Now I have an appendix} 
\section{Appdx. section }
\section{Appdx. section }
\section{Appdx. section }
\chapter{Now I have an appendix} 
\section{Appdx. section }
\section{Appdx. section }
\section{Appdx. section }
\end{document}

And here's the bit from the style file that needs to be different for toc pages that contain only appendix titles:

\makepagestyle{toc}
\makeevenfoot{toc}{}{\thepage}{}
\makeoddfoot{toc}{}{\thepage}{}
\makeevenhead{toc}{CHAPTER}{}{Page}
\makeoddhead{toc}{CHAPTER}{}{Page}

So when this document is created, the problematic area is the header of the last page of the toc, which should read APPENDIX instead of CHAPTER (I don't know why that header overlaps the top line of the toc in this MWE, but it doesn't happen in my real document so this is probably not important).

0

1 Answer 1

4

You can add a header switch during the toc using \addtocontents. For example, if we define the header type toc and apply it during the table of contents then you can also inject \makeevenhead and \makeoddhead part-way through the TOC:

\documentclass[oneside,12pt]{memoir}
\setsecnumdepth{subsection}
\maxtocdepth{subsection}
\usepackage{appendix}
\makepagestyle{toc}
\makeevenfoot{toc}{}{\thepage}{}
\makeoddfoot{toc}{}{\thepage}{}
\makeevenhead{toc}{CHAPTER}{}{Page}
\makeoddhead{toc}{CHAPTER}{}{Page}

\begin{document}
\DoubleSpacing
\frontmatter
\pagestyle{toc}
\tableofcontents
\listoftables
\listoffigures

\mainmatter

\pagestyle{plain} 

\addtocontents{toc}{\noindent\normalfont{CHAPTER}\par}
\chapter{Chapter the Next} 
\chapter{Chapter the Next} 
\section{My Next Section}
\subsection{And another subsection}
\subsection{And another subsection}
\subsection{And another subsection}
\section{My Next Section}
\subsection{And another subsection}
\subsection{And another subsection}
\subsection{And another subsection}
\section{My Next Section}
\subsection{And another subsection}
\subsection{And another subsection}
\subsection{And another subsection}
\chapter{Chapter the Next} 
\section{My Next Section}
\subsection{And another subsection}
\subsection{And another subsection}
\subsection{And another subsection}
\section{My Next Section}
\subsection{And another subsection}
\subsection{And another subsection}
\subsection{And another subsection}
\section{My Next Section}
\subsection{And another subsection}
\subsection{And another subsection}
\subsection{And another subsection}
\chapter{Chapter the Next} 
\section{My Next Section}
\subsection{And another subsection}
\subsection{And another subsection}
\subsection{And another subsection}
\section{My Next Section}
\subsection{And another subsection}
\subsection{And another subsection}
\subsection{And another subsection}
\section{My Next Section}
\subsection{And another subsection}
\subsection{And another subsection}
\subsection{And another subsection}
\chapter{Chapter the Next} 
\section{My Next Section}
\subsection{And another subsection}
\subsection{And another subsection}
\subsection{And another subsection}
\section{My Next Section}
\subsection{And another subsection}
\subsection{And another subsection}
\subsection{And another subsection}
\section{My Next Section}
\subsection{And another subsection}
\subsection{And another subsection}
\subsection{And another subsection}

\appendix
\addtocontents{toc}{\noindent\normalfont{APPENDIX}\par}
% Lines added here
\addtocontents{toc}{%
  \protect\makeevenhead{toc}{APPENDIX}{}{Page}
  \protect\makeoddhead{toc}{APPENDIX}{}{Page}%
}
\chapter{Now I have an appendix} 
\chapter{Now I have an appendix} 
\section{Appdx. section }
\section{Appdx. section }
\section{Appdx. section }
\chapter{Now I have an appendix} 
\section{Appdx. section }
\section{Appdx. section }
\section{Appdx. section }
\chapter{Now I have an appendix} 
\section{Appdx. section }
\section{Appdx. section }
\section{Appdx. section }
\chapter{Now I have an appendix} 
\section{Appdx. section }
\section{Appdx. section }
\section{Appdx. section }
\end{document}

The only problem with this is that it will apply from the first TOC page containing any appendix items. However, the question doesn't really detail what should happen for this case so that is a 'follow up' I think!

5
  • Btw: isn't this text material? It does not really belong in the headers. It can be done in the text using a recursive macro using \afterpage and some labels to check where we are. Should be doable to also handle the appendix shift
    – daleif
    Dec 17, 2014 at 21:48
  • @daleif The question asks for this in the header. I can see that it could be 'top of column' of the TOC as a table but that's not what is asked for. Unless the OP edits it's hard to say (I'm looking over some older questions seeing which ones might be sortable).
    – Joseph Wright
    Dec 17, 2014 at 21:52
  • I know, it just sounds like a really odd requirement.
    – daleif
    Dec 18, 2014 at 7:43
  • @JosephWright Thanks for the answer! I also have this requirement, and as you predicted, I need it to say Appendix only on the header of the page following the first appendix. Basically, the header should be tied to the first "chapter type" on the ToC page. I tried using marks but could not get it to work. For bonus points, if the last page does not contain a new appendix (i.e. just has sections and lower), then there should be no header. Dissertation formats are dumb. Any advice?
    – Paul
    Oct 19, 2018 at 17:06
  • @JosephWright Since it might be a lengthy answer, I asked a new question here
    – Paul
    Oct 19, 2018 at 17:28

You must log in to answer this question.

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