In the memoir class, I want to include \part in my book. I have used the code from p.78 of the Memoir manual, tweaked slightly, to change the look of the \part title. However, something is causing the \part information to not be included in the Table of Contents. The code between the % seems to be the problem. So, how do I get the formatting I want in the text for part titles, and still get the parts included in the table of contents?

\documentclass[letterpaper]{memoir}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}

%%%%%%%%%%%

\renewcommand{\part}[1]{%
\cleardoublepage % start a new recto page
\beforepartskip % space before Name and Number
\midpartskip % space after Name and Number
\renewcommand*{\parttitlefont}{\centering\HUGE\normalfont}
\printparttitle{#1} % print the title
\partpageend
} % finish off

%%%%%%%%%%%

\renewcommand{\partpageend}{%
\afterpartskip
\normalsize
}

\begin{document}
\tableofcontents

\part{Test Part 1}
\chapter{Name}
\lipsum*[1]

\part{Test Part 2}

\lipsum*[1]

\end{document}

• Are the parts numbered in the TOC? The default is Roman numerals (e.g., I, II, III, ...). The way your part pages are set up now should only print (e.g.) 'Test Part 1' but also print a plain page number at the bottom of the page. – jon Jan 21 '17 at 20:30
• The parts are not numbered in the text and there are no page numbers on the page or the next page (which is what I want). I have not included in the MWE the rest of the sty file as it has not impact on the problem. Ideally, in the TOC, each part would be a centered title, normal font, with the part title preceded by PART X: as in PART I: Test Part 1. – kgrady Jan 21 '17 at 20:35
• @kgrady: Your definition of \part can't work as expected, since most of its desired features have been omitted by your \renewcommand{\part} especially the fact that \part is a command with moving arguments and actually using either \@part or \@spart -- this is never called by your renewed macro. The mentioned page (on p.80 of the current manual) is a bit misleading, I think – user31729 Jan 21 '17 at 21:07
• Seems like I shouldn't use \addcontentsline since that would mean I have to update the sty file every time I change the \part text in the main file. – kgrady Jan 21 '17 at 21:09
• So what code should I use to update the formatting as I have done, and still retain the other features of \part, including insertion into the TOC? – kgrady Jan 21 '17 at 21:12

It seems you want to remove the “Part I” from the part page and the numbering from the table of contents.

\documentclass[letterpaper]{memoir}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}

%%%%%%%%%%%
\renewcommand*{\parttitlefont}{\centering\HUGE\normalfont}
\global\chardef\keepsecnumdepth=\value{secnumdepth}%
\setcounter{secnumdepth}{-1000}%
}
\setcounter{secnumdepth}{\keepsecnumdepth}%
}
\renewcommand{\printpartname}{}
\renewcommand{\printpartnum}{}
%%%%%%%%%%%

\begin{document}

\tableofcontents*

\part{Test Part 1}
\chapter{Name}
\lipsum*[1]

\part{Test Part 2}

\lipsum*[1]

\end{document}


Before the code that does the TOC related jobs I set secnumdepth to a very large negative value; this suppresses the numbering, but still adds the part to the table of contents. After that, the counter is reset to its previous value.

Next, I redefine the macros responsible for printing “Part I” to do nothing.

Unrelated, but I also added * next to \tableofcontents: I can't stand the “Contents” line just below the title “Contents”.

• Very nice! Simple and yes, solved the text preceding the part issue. I had the * in my full document, just missed it in the MWE. I still go with the manual leaving a lot to be desired. – kgrady Jan 21 '17 at 21:42