[Tex/LaTex] TOC with pagestyle empty in memoir

header-footermemoirtable of contents

I'm using the memoir class for a thesis, and want no page numbering of the front matter including the TOC. Have followed the answer to Table of contents with page style empty which does remove the page numbering of the first page of the TOC. My TOC is three pages long, and the last 2 pages still has a heading with roman page numbering. Minimal example below here:

\documentclass[danish,12pt,a4paper,oneside,openany]{memoir}
\AtBeginDocument{\addtocontents{toc}{\protect\thispagestyle{empty}}} 

\begin{document}
  \frontmatter
  \pagestyle{empty}
  \include{frontmatter/titlepage}
  \include{frontmatter/abstract}
  \tableofcontents*
  \pagestyle{headings}

  \mainmatter
  ...       

Best Answer

Because memoir doesn't automatically start contents lists on a new page, you need to issue \clearpage commands to make sure that the page style gets associated correctly. Headers and footers are added after the page content is produced, so the \clearpage is necessary. The standard document classes incorporate \clearpage into some of these commands, but memoir chooses not to.

\documentclass[danish,12pt,a4paper,oneside,openany]{memoir}
\AtBeginDocument{\addtocontents{toc}{\protect\thispagestyle{empty}}} 

\begin{document}
\pagestyle{empty}
\frontmatter
\include{frontmatter/titlepage}
\include{frontmatter/abstract}
\tableofcontents*
\clearpage % TOC will now have the previous pagestyle setting
\pagestyle{headings}

\mainmatter
  ...
\end{document}  
Related Question