2

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

enter image description here

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}

\renewcommand*{\cftsectionleader}{}

\tableofcontents*

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

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

enter image description here

  • How can I achieve that using only the memoir utilities?
  • 1
    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
3

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
    \addpenalty{-\@highpenalty}%
    \vskip 1ex \@plus\p@
    \setlength\@tempdima{1.5em}%
    \begingroup
      \parindent \z@ 
      \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode \large  % added for large font for chapters
      %\advance\leftskip\@tempdima
      \hskip -\leftskip %\@chapapp~ \par % added \@chapapp~ \par 
      #1\nobreak \raggedright % originally \hfil
%added for leaders (dots) in chapter in toc
%\xleaders\hbox{$\m@th
%       \mkern \@dotsep mu\hbox{.}\mkern \@dotsep
%        mu$}\hfill%
%%
\nobreak\hb@xt@\@pnumwidth{\hss ~\textbullet~#2}\par\vspace{.5ex} % ADDED VSPACE
      \penalty\@highpenalty
    \endgroup
  \fi}  

\renewcommand*\l@section[2]{%
    \ifnum \c@tocdepth >\m@ne
    \addpenalty{-\@highpenalty}%
    %\vskip .5ex \@plus\p@
    \setlength\@tempdima{1.5em}%
    \begingroup
    \parindent 3em 
    \rightskip \@pnumwidth
    \parfillskip -\@pnumwidth
    \leavevmode \normalsize %
    \advance\leftskip\@tempdima
    \hskip -\leftskip %
    #1\nobreak \raggedright % originally \hfil
    %added for leaders (dots) in chapter in toc
    %\xleaders\hbox{$\m@th
    %      \mkern \@dotsep mu\hbox{.}\mkern \@dotsep
    %       mu$}\hfill%
    %%%
    \nobreak\hb@xt@\@pnumwidth{\hss \textbullet~#2}\par%\vspace{.5ex} % ADDED VSPACE
    \penalty\@highpenalty
    \endgroup
    \fi} 



\renewcommand*\l@subsection[2]{%
    \ifnum \c@tocdepth >\m@ne
    \addpenalty{-\@highpenalty}%
    %\vskip .5ex \@plus\p@
    \setlength\@tempdima{2.3em}%
    \begingroup
    \parindent 5.3em 
    \rightskip \@pnumwidth
    \parfillskip -\@pnumwidth
    \leavevmode \normalsize %
    \advance\leftskip\@tempdima
    \hskip -\leftskip %
    #1\nobreak \raggedright % originally \hfil
    %added for leaders (dots) in chapter in toc
    %\xleaders\hbox{$\m@th
    %      \mkern \@dotsep mu\hbox{.}\mkern \@dotsep
    %       mu$}\hfill%
    %%%
    \nobreak\hb@xt@\@pnumwidth{\hss \textbullet~#2}\par\vspace{1ex} % ADDED VSPACE
    \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}

enter image description here

You may adapt lengths to your taste.

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
  • 1
    @djnavas, you're right; adding \renewcommand\chapternumberline[1]{\numberline{#1}} there is no warning. – Joseph Jul 11 '17 at 10:54
3

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

\documentclass{memoir}
\usepackage{lipsum}

\renewcommand*{\cftchapterleader}{}
\renewcommand*{\cftsectionleader}{}
\renewcommand*{\cftsubsectionleader}{}
\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
  • 1
    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

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.