# TOC style in memoir class

I am attempting to reach the below design for a TOC (but using the memoir class):

Which is basically only presenting the chapter number, name and page and subsection number, name and page. The standard toc strucutre in memoir adds dots between the name and the page, which I am to remove.

I was able to arrive at a partial solution, where I managed to remove the dots in subsections, but not in chapters or in subsections (MWE):

\documentclass{memoir}
\usepackage{lipsum}

\tableofcontents*

\begin{document}
\chapter{Introduction}
\section{lipsum}
\lipsum[1-10]
\end{document}


This approach, however, generates malformed lines in the toc:

• How can I achieve that using only the memoir utilities?
• As always on this site, please post a minimal of what you have now. That makes it radioer to help you. – daleif Jul 9 '17 at 6:31
• See the memoir manual page 155 (current version on ctan), it has several small tips one of which is setting the page numbers right after the title. – daleif Jul 9 '17 at 11:55

I see you want to reproduce this: https://logic.rwth-aachen.de/~ummels/diss.pdf

One option is to redefine l@chapter and so on:

\documentclass{memoir}
\usepackage{fontspec}
\setmainfont{Minion Pro}

\renewcommand\chapternumberline[1]{\numberline{#1}} %not necessary when using the book class

\makeatletter

\renewcommand*\l@chapter[2]{%
\ifnum \c@tocdepth >\m@ne
\vskip 1ex \@plus\p@
\setlength\@tempdima{1.5em}%
\begingroup
\parindent \z@
\rightskip \@pnumwidth
\parfillskip -\@pnumwidth
\leavevmode \large  % added for large font for chapters
\hskip -\leftskip %\@chapapp~ \par % added \@chapapp~ \par
#1\nobreak \raggedright % originally \hfil
%\xleaders\hbox{$\m@th % \mkern \@dotsep mu\hbox{.}\mkern \@dotsep % mu$}\hfill%
%%
\penalty\@highpenalty
\endgroup
\fi}

\renewcommand*\l@section[2]{%
\ifnum \c@tocdepth >\m@ne
%\vskip .5ex \@plus\p@
\setlength\@tempdima{1.5em}%
\begingroup
\parindent 3em
\rightskip \@pnumwidth
\parfillskip -\@pnumwidth
\leavevmode \normalsize %
\hskip -\leftskip %
#1\nobreak \raggedright % originally \hfil
%\xleaders\hbox{$\m@th % \mkern \@dotsep mu\hbox{.}\mkern \@dotsep % mu$}\hfill%
%%%
\penalty\@highpenalty
\endgroup
\fi}

\renewcommand*\l@subsection[2]{%
\ifnum \c@tocdepth >\m@ne
%\vskip .5ex \@plus\p@
\setlength\@tempdima{2.3em}%
\begingroup
\parindent 5.3em
\rightskip \@pnumwidth
\parfillskip -\@pnumwidth
\leavevmode \normalsize %
\hskip -\leftskip %
#1\nobreak \raggedright % originally \hfil
%\xleaders\hbox{$\m@th % \mkern \@dotsep mu\hbox{.}\mkern \@dotsep % mu$}\hfill%
%%%
\penalty\@highpenalty
\endgroup
\fi}

\makeatother

\begin{document}

\tableofcontents

\chapter{title}
\section{section name}
\subsection{section name}

\chapter{title}
\section{section name}
\subsection{section name}

\chapter{title}
\section{section name}
\subsection{section name}

\chapter{title}
\section{section name}
\subsection{section name}

\end{document}


If you want subsections to appear in the TOC in memoir you should add

\setcounter{tocdepth}{2}
\setcounter{secnumdepth}{2}

• Thank you so much for the answer! Its exactly what I needed. How I make sure that memoir will number subsections throughout the document? – lf_araujo Jul 10 '17 at 1:03
• \setcounter{secnumdepth}{2}. – Joseph Jul 10 '17 at 10:35
• When I tried your code, I was getting the following error, for each chapter: ! Undefined control sequence. <argument> \@chapapp@head \@cftbsnum 1\@cftasnum l.1 ...e {chapter}{\chapternumberline {1}title}{3} From question 12471 "Elements of toc styling using memoir class", was proposed by mformes on march 30, 2012, to correct it with: \renewcommand\chapternumberline[1]{\numberline{#1}} which solved the problem. – djnavas Jul 11 '17 at 7:58
• @djnavas, you're right; adding \renewcommand\chapternumberline[1]{\numberline{#1}} there is no warning. – Joseph Jul 11 '17 at 10:54

Here is the same, using memoir only (mainly from page 155 in the memoir manual)

\documentclass{memoir}
\usepackage{lipsum}

\renewcommand{\cftchapterpagefont}{}
\renewcommand*{\cftchapterformatpnum}[1]{~\textbullet~#1}
\renewcommand*{\cftsectionformatpnum}[1]{~\textbullet~#1}
\renewcommand*{\cftsubsectionformatpnum}[1]{~\textbullet~#1}
\renewcommand{\cftchapterafterpnum}{\cftparfillskip}
\renewcommand{\cftsectionafterpnum}{\cftparfillskip}
\renewcommand{\cftsubsectionafterpnum}{\cftparfillskip}
\setrmarg{3.55em plus 1fil}
\setsecnumdepth{subsection}
\maxsecnumdepth{subsection}
\settocdepth{subsection}

\begin{document}

\tableofcontents*

\chapter{Introduction}
\section{lipsum}
\subsection{lipsum 2}

\end{document}


Addition, here is some extra code to play with the indentations

\setlength\cftsectionindent{0pt}
\setlength\cftsubsectionindent{0pt}
\setlength\cftchapternumwidth{3em}
\setlength\cftsectionnumwidth{3em}
\setlength\cftsubsectionnumwidth{3em}


Also made the number boxes the same size

• Thanks, interesting and simple solution. Is it possible to also remove the indentation before subsections? I am also getting: ! LaTeX Error: Missing \begin{document}. l.126 \renewcommand*{\cftchapterformatpnum}{#1 – lf_araujo Jul 11 '17 at 11:54
• Read the memoir manual, (almost) all of it is configurable. Did you copy it wrong? The code as it is works fine. See if your editor or browser converts some of this into non-ascii. – daleif Jul 11 '17 at 12:46
• Tried the solution and I am truly happy that works flawlessly and also, was able to adjust the spaces for the chapter-section-subsection numbering in TOC to mimic the layout asked for. Congratulations, This solutions deserves to be included in memmanual. – djnavas Jul 11 '17 at 19:59