1

I'm using LaTeX and the memoir class to typeset a book. The book publisher (Cambridge) requests that the table of contents have chapter and headings on the left, page numbers on the right, with the very first entry containing the page number preceded by the word "page".

I tried:

\renewcommand*{\cftchapterformatpnum}[1]{\emph{page} \cftchapterpagefont #1}

and this allowed me to add "page", but it adds it to every entry. I tried:

\renewcommand*{\cftchapterformatpnum}[1] {\cftchapterpagefont #1}

elsewhere in my document to set it back, but there is obviously something I fundamentally don't understand about how LaTeX works. It seems that it only honors this command prior to:

\begin{document}

Can a LaTeX expert tell me the proper way to achieve the goal?

1 Answer 1

2

How about this (less any typos)?

\documentclass{memoir}
\newcommand*{\epage}{\emph{page }} % for convenience
\renewcommand*{\cftchapterformatpnum}[1]{\epage\cftchapterpagefont #1}
\begin{document}
\frontmatter
\tableofcontents* % don't add the ToC reference to the ToC
  %\addtocontents{toc}{\hfill \epage\par} % put page above page numbers
\mainmatter
\chapter{One}
\addtocontents{toc}%
  {\protect\renewcommand*{\protect\epage}{}% nullify printing page
}
\section{one}
\chapter{Two}
\section{one}
\end{document}

Well done for getting as far as you did. The trick is to add commands into the ToC at appropriate places using the \addtocontents{<file>}{<text>} macro; see section 9.1 General ToC Methods in the manual (> texdoc memoir).

3
  • 1
    wow, when I asked for a LaTeX expert, I got one! That did the trick perfectly. Thanks! Can I upvote ten votes? But I did have to correct one typo - \addtocontents{toc}{%. (note added brace)
    – Pete P
    Aug 14, 2019 at 23:01
  • @PeteP Thanks for the correction. Sometime during the night I wondered if CUP wanted page above the page numbers rather than before the first page number. I have added (commented out) code to my answer if this is the case and then you don't have to do all the fiddling around with the \cftchapterformatpnum. Aug 15, 2019 at 18:18
  • Thanks again, Peter. I believe that they want page preceding the page of the first TOC entry. I've seen another CUP book like that, so I think I got it right. It's in copy-edit now, so I'll hear soon.
    – Pete P
    Aug 16, 2019 at 20:35

You must log in to answer this question.

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