I'm trying to customize the TOC layout with titletoc
in a memoir
document.
The chapter
styling works well as below, but if I try the appendix
section, I'll get an error for missing number.
I think I see that this is because \chapternumberline
is renewed to \numberline
, and that doesn't take in the A
as the appendix number.
But if \chapternumberline
isn't renewed this way, it errors out with Undefined control sequence
for \@chapapp@head
in the memoir
definition:
\newcommand{\chapternumberline}[1]{%
\chapternumberlinehook{#1}%
\hb@xt@\@tempdima{\@chapapp@head\@cftbsnum #1\@cftasnum\hfil}%
\@cftasnumb}
So it looks like memoir
is locking horns with titlesec
. Any suggestions to on how to pacify them?
The aim is to have the appendix appear similar to the chapter:
Chapter 1 * It Came Into My Head 3
Appendix A * The Time Machine 5
(In the MWE below the appendix styling is commented out, otherwise it would be MNWE)
mwe.toc
\contentsline {chapter}{\chapternumberline {1}It Came Into My Head}{3}
\contentsline {appendix}{\chapternumberline {A}The Time Machine}{5}
\contentsfinish
mwe.tex
\documentclass[11pt]{memoir}
\makeatletter
\usepackage{titletoc}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures={TeX}}
\setmainfont{TeX Gyre Pagella}
% Fixes Undefined control sequence error for \@chapapp@head
\renewcommand\chapternumberline[1]{\numberline{#1}}
\titlecontents{chapter}[6pc]
{\normalsize}%
{%
\contentsmargin{0pt}%
\makebox[0pt][r]{%
\chaptername~{\thecontentslabel}%
\hspace*{0.5em}$\cdot$\hspace*{0.5em}%
}%
}
{\contentsmargin{0pt}%
\itshape}
{\hfill\normalsize\thecontentspage}
% FIXME: perhaps \numberline is erroring out b/c "A" is not numerical
%! Missing number, treated as zero.
%<to be read again>
% \ttll@appendix
%l.21 ...rline {A}The Time Machine}{11}{appendix.A}
%\titlecontents{appendix}[6pc]
%{\normalsize}%
%{%
% \contentsmargin{0pt}%
% \makebox[0pt][r]{%
% \appendixname~{\thecontentslabel}%
% \hspace*{0.5em}$\cdot$\hspace*{0.5em}%
% }%
%}
%{\contentsmargin{0pt}%
%\itshape}
%{\hfill\normalsize\thecontentspage}
\makeatother
\begin{document}
\tableofcontents*
\chapter{It Came Into My Head}
'In another moment we were standing face to face, I and this fragile thing out of futurity\ldots
\appendix
\chapter{The Time Machine}
'There were others coming, and presently a little group of perhaps eight or ten\ldots
\end{document}
Best Answer
You can
\let
the command\ttll@appendix
to be\ttll@chapter
:Instead of using
titletoc
(which might produce problems ifhyperref
is going yo be used), you could use the built in mechanisms offered bymemoir
and inspired in thetocloft
package; a little example producing a result similar to the one you want (some details still have to be adjusted):In my example I commented out the line
\setmainfont{TeX Gyre Pagella}
since I don't have that font.