The question of removing redundant page numbers [ie, where a page is repeated follows another in the table of contents in a work with short sections on the same page] is addressed here (Suppress redundant page numbers in the toc) and here (Removing repeated page numbers from table of contents) but the replies to both deal with tocloft and I can’t get them to work with memoir. Is it possible to do this in memoir?

So, I desire this code:


which currently produces

enter image description here

to instead produce: enter image description here

1 Answer 1


Since tocloft and memoir are by the same author, most tocloft solutions will work with memoir, but with slightly changed names. Roughly, where tocloft uses abbreviated sectioning names like chap, sec, subsec etc., memoir usually use the full version of the name. So here's the approach shown here adapted to memoir. You need to apply the patch to each sectioning level that you want it to work at. In your case, since you don't want the page number displayed at all, there's no need to make the code use \textcolor{} at all, but I've left that option available in the commented code.

Since the original code (which is not originally mine) effectively uses the displayed page number, it fails if the numbering is not arabic, which means that if you put \frontmatter in the document, it will fail, since the page numbering is set to roman. I've now fixed this and cleaned up the code substantially to deal with repeated roman or arabic page numbers.

% this function from https://tex.stackexchange.com/a/427559/
\prg_new_protected_conditional:Npnn \if_is_int:n #1 { T, F, TF }
    \regex_match:nnTF { ^[\+\-]?[\d]+$ } {#1}% $
      { \prg_return_true: }
      { \prg_return_false: }
%   Instead of the previous line, use the next line
%   to change the colour of the page number instead
%   {\textcolor{white}{#1}}
    {#1\int_gset:Nn \l_clrize_svpage_int {\l_tmpa_int}}

\chapter{A chapter}

output of code

  • The code seems not to work when subsection is followed by section? imgur.com/a/16YFDog
    – ezgranet
    Nov 18 at 22:53
  • @ezgranet You need to apply the patch to every level you want it to apply to. I've updated the answer.
    – Alan Munn
    Nov 19 at 0:33
  • Thank you! One other point—it seems to break down if \frontmatter is set? Triggers missing number errors with frontmatter content
    – ezgranet
    Nov 20 at 2:16
  • 1
    @ezgranet I've updated to the code to work properly with both the \frontmatter and \mainmatter page numbers of the contents.
    – Alan Munn
    Nov 20 at 17:15

You must log in to answer this question.

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