0

I'm using the memoir documentclass, and I'm tring to customize the table of contents style. For this, I'm using the package titletoc, and the command \titlecontents for the formatting. What works ok for section and subsection fails for chapter, with the following error:

! Undefined control sequence.

<argument> \@chapapp@head 

\@cftbsnum 1\@cftasnum 

l.3 ...er}{\chapternumberline {1}first chapter}{3}%

?

Here is a MWE that reproduces the error for me. It's happening with both pdflatex and lualatex (at least, I didn't try others). If \documentclass{memoir} is replaced with \documentclass{book}, everything works fine.

\documentclass{memoir}

\usepackage{titletoc}

\titlecontents{chapter}[0pt]{\vskip0pt}{\small\thecontentslabel.\ }{}{\small\dotfill\contentspage}
\titlecontents{section}[0pt]{\vskip0pt}{\qquad\small\thecontentslabel.\ }{}{\small\dotfill\contentspage}
\titlecontents{subsection}[0pt]{\vskip0pt}{\qquad \qquad \small\thecontentslabel.\ }{}{\small\dotfill\contentspage}

\setcounter{tocdepth}{3} 
\setcounter{secnumdepth}{3} 

\begin{document}
\tableofcontents
\listoffigures

test
\chapter{first chapter}
Contents of first chapter.
\section{first section}
Contents of first section.
\chapter{second chapter}
contents of second chapter.
\section{second section}
Contents of second section.
\subsection{First subsection}
Contents of first subsection
\end{document}
  • 2
    As far as I know titletoc is not compatible with memoir in the first place. What exactly are you trying to do? Then perhaps we can create a purely memoir based solution – daleif Nov 20 '19 at 14:35
  • Hello, thanks for your answer, I'm trying to replicate a complex word document I have with LaTeX, and it's almost done, but this is one of the last things I cannot solve. I would like to have the table of contents with all elements (chapter, section and subsection) in uppercase and a smaller font size. Chapters are not working, but sections and subsections are. For example, this works for section and subsection, but not for chapter: \titlecontents{section}[0pt]{\vskip0pt}{\qquad\small\thecontentslabel.\ }{}{\small\dotfill\contentspage} – antlarac Nov 20 '19 at 14:43
1

As far as I can see this seem to do the trick. I'm not quite sure if the box redefinition is wanted, but you can just leave it out

\documentclass{memoir}
\renewcommand\cftchapterfont{\normalfont\small}
\renewcommand{\cftchapterleader}{\cftdotfill{\cftchapterdotsep}}
\renewcommand{\cftchapterdotsep}{\cftdotsep}
\renewcommand{\cftchapterpagefont}{\normalfont\small}
\renewcommand{\cftchapteraftersnum}{.\ }
\setlength\cftbeforechapterskip{0pt}
\renewcommand\cftsectionfont{\normalfont\small}
\renewcommand\cftsubsectionfont{\normalfont\small}
\renewcommand\cftsubsubsectionfont{\normalfont\small}
\renewcommand{\cftsectionaftersnum}{.\ }
\renewcommand{\cftsubsectionaftersnum}{.\ }
\renewcommand{\cftsubsubsectionaftersnum}{.\ }
\renewcommand\numberlinebox[2]{#2}
\renewcommand\chapternumberlinebox[2]{#2}

\settocdepth{subsubsection}
\setsecnumdepth{subsubsection}


\begin{document}
\tableofcontents*
\listoffigures*

test
\chapter{first chapter}
Contents of first chapter.
\section{first section}
Contents of first section.
\chapter{second chapter}
contents of second chapter.
\section{second section}
Contents of second section.
\subsection{First subsection}
Contents of first subsection
 \end{document}

enter image description here

  • 1
    Great, thank you! Seems to be working, I will continue from here! – antlarac Nov 20 '19 at 15:07
0

I noticed in your comment that you wanted the elements in uppercase, which daleif's answer did not do although it did the other things you wanted. To make chapter entries uppercase do:

\renewcommand{\cftchapterfont}{\normalfont\small\MakeUppercase}

and similarly add \MakeUppercase to the \cftsectionfont, \cftsubsectionfont, etc.

  • Better use \MakeTextUppercase , but under the latest memoir it is the same thing (we load textcase with the overload option) – daleif Nov 20 '19 at 18:08
  • 1
    @daleif I bow to your superior memory :-) – Peter Wilson Nov 20 '19 at 18:59
  • I just changed it in the latest memoir release. We no longer embed a copy of textcase, we load the real thing. When the ltx team is already on it why no use their work. – daleif Nov 20 '19 at 19:02

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.