The following memoir documentclass source produces two tables of contents -- a short one and a detailed one. (The difference is that only the latter includes subsections.)

Question: How do I get the name of each of those (the values of \shortcontentsname and \longcontentsname, respectively), to appear in the headers of its pages after its first? E.g., I want to see

iv                                                   Detailed Contents


Detailed Contents                                                   v

for the left-hand page iv and the right-hand page v, respectively.

As the source shows, I tried


within \makepsmarks{main}, but that produces headers with just the page numbers. I also tried, instead




but with the same results.


  % insert "Chapter\space" & "Section\space" if desired as 4th argument:
% daleif (https://tex.stackexchange.com/a/512636/13492):
  \createmark{chapter}{both}{shownumber}{}{\enspace} % use both not left
  % ---> My attempted additions: <---




%% Code by Christian Hupfer 
% Just in case we're not loading hyperref
 % Addition
 \protected@edef\@currentlabel{shorttoc}% Rather unimportant
 \edef\@currentlabelname{\shortcontentsname}% For \nameref
 % Now let us fix the hyperanchor for the short toc
 \protected@edef\@currentlabel{longtoc}% Rather unimportant
 % Now let us fix the hyperanchor for the long toc
 % End of additions
\newcommand{\longcontentsname}{Detailed Contents}
\newcommand{\shortcontentsname}{Short Contents}
  \let\contentsname\shortcontentsname% Disabling the \shortcontentsstuff in toc
  \@shorttocfalse% Disable the short toc
  \let\longcontentsstuff\relax% Disabling the \longcontentsstuff in toc





\section{A section}
% Many (sub-)sections to force multi-page TOC
\section{B section}\section{C section}\section{D section}
\section{E section}\section{F section}\section{G section}\section{H section}
\section{I section}\section{J section}\section{K section}\section{L section}
\section{M section}\section{N section}\section{O section}\section{P section}
\section{Q section}\section{R section}\section{S section}\section{T section}
\section{U section}\section{V section}\section{W section}\section{X section}
\section{Y section}\section{Z section}\section{AA section}\section{BB section}
\section{CC section}\section{DD section}\section{EE section}\section{FF section}
\section{GG section}\section{HH section}\section{II section}\section{JJ section}
\section{KK section}\section{LL section}\section{MM section}\section{NN section}
\section{OO section}\section{PP section}\section{QQ section}\section{RR section}
\section{SS section}\section{TT section}\section{UU section}\section{VV section}
\section{WW section}\section{XX section}\section{YY section}\section{ZZ section}


Here's what I get now for pages in the detailed table of contents:

Detailed contents even-page header misssing longcontentsname

Detailed contents odd-page header misssing longcontentsname


  • This question is a follow-up to https://tex.stackexchange.com/a/512636/13492 (which is working as desired for other frontmatter and mainmatter.
  • The code for the two tables of contents comes in part from https://tex.stackexchange.com/a/346433/13492. Thsy method, unfortunately, does not preserve the pagestyle for pages after chapter page in the Short Contents and the Long Contents. It does, however, produce the wanted entries of each of the two TOCs in, and only in, the other; and it makes the links on each of those entries point to the top of the corresponding TOC page.

Partial solution:

Using the etoc package allows a short and a long table of contents that do preserve the page style and chapter style -- without, however, seeming to allow each of the two TOCs to have an entry only for the other TOC.

See: memoir: Exclude entry of other TOC from each of two TOCs,

  • Again you are creating marks that are never executed. Toc marks does not use \createmark as the name of the toc is not something that changes and thus one can get aways with a simpler interface. Guess what the ` \createplainmark{toc}{both}{\contentsname}` lines does?
    – daleif
    Oct 18, 2019 at 14:49
  • What exactly is that insane piece of toc code suppose to do? What is your goal here? It is not particularly clear. Removing almost everything from that answer and using \newcommand{\shorttableofcontents}[1][1]{% \begingroup \setcounter{tocdepth}{#1} \let\contentsname\shortcontentsname \tableofcontents* \endgroup } and your definition for the name seems to work fine. That redefinition of \tableofcontents removes everything that memoir does so of course everything you try via memoir interfaces fail
    – daleif
    Oct 18, 2019 at 14:57
  • Among other things, that "insane" piece of toc code is to make an entry for the Detailed Contents to appear in the Short Contents (and, as I recall, vice versa). See the 2nd reference at the end of my post.
    – murray
    Oct 18, 2019 at 15:11
  • They they be in both or crossed aka short in long, and long in short?
    – daleif
    Oct 18, 2019 at 15:21
  • @daleif: Yes, an entry for each in the other. But no entry for Short Contents in the shorttableofcontents, and similarly for longtableofcontents.
    – murray
    Oct 18, 2019 at 15:25

1 Answer 1


Here is a better solution. This works with and without biblatex and hyperref. Special thanks to Ulrike Fischer for the trick in https://tex.stackexchange.com/a/513634/3929 which forms the basis for this solution.

Also added a slight change for memoir such that the anchor for the toc header now is above the header and not below. This will be included in the next memoir release.

I did not include your arguments for the long and short toc, I trust you can make those adjustments yourself.


% this changes where the hyperref anchor for the TOC header is, will
% be in the next memoir release
%%%%  \parskip\cftparskip
} % end \newlistof


% just to show this woth with biblatex and hyperref


% credit for Ulrike Fischer for this idea, we need to have the
% conditionals defined **inside** the toc


% next use patching to add a wrapper around the \addcontentsline
% that \tableofcontents generates. Since this is inside a group we
% don't having one patch messing up the other
  \def\contentsname{Short toc}

  \def\contentsname{Long toc}

% automatically add the activation to the toc











Old fragile solution removed

  • Yes, this does work. It's essential, though, for the links to go to the tops of the two TOCs pages, that the code come after hyperref is loaded. (It's shown that way in the source, but I want to make that explicit here.
    – murray
    Oct 22, 2019 at 17:08
  • This method causes an error if I also load biblatex! See: tex.stackexchange.com/questions/513429/….
    – murray
    Oct 23, 2019 at 22:15
  • @murray see updated version
    – daleif
    Oct 25, 2019 at 14:21
  • I think this completely solves the problem. I'm about to try it with my actual book-length document to make sure there's nothing I'm overlooking.
    – murray
    Oct 26, 2019 at 14:24
  • a snag - I have a sectioning command \subsec which is an unnumbered version of \subsection, and unfortunately it is appearing in the long (detailed) toc, too. I'll post a new question on this.
    – murray
    Oct 27, 2019 at 19:13

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.