I use memoir
class and want to customize the table-of-contents and chapters style. When I use \renewcommand*\l@chapter[2]
I get this error after the second compilation:
Undefined control sequence.
\chapternumberline ... \@tempdima {\@chapapp@head
\@cftbsnum #1\@cftasnum \h...
l.2 ...pter}{\chapternumberline {1}Chapter One}{3}
My code:
\documentclass{memoir}
\usepackage{xcolor}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{titletoc}
\usepackage{etoolbox}
\definecolor{secnum}{RGB}{13,151,225}
\definecolor{ptcbackground}{RGB}{212,237,252}
\definecolor{ptctitle}{RGB}{0,177,235}
\makeatletter
\renewcommand*\l@chapter[2]{%
\ifnum \c@tocdepth >\m@ne
\addpenalty{-\@highpenalty}%
\vskip 2.0em \@plus\p@
\setlength\@tempdima{1.5em}%
\begingroup
\parindent \z@ \rightskip \@pnumwidth
\parfillskip -\@pnumwidth
\leavevmode
\advance\leftskip\@tempdima
\hskip -\leftskip
\colorbox{ptctitle}{\strut%
\makebox[\dimexpr\textwidth-2\fboxsep-7pt\relax][l]{%
\color{white}\bfseries\sffamily#1%
\nobreak\hfill\nobreak\hb@xt@\@pnumwidth{\hss #2}}}\par\smallskip
\penalty\@highpenalty
\endgroup
\fi}
\makeatother
\begin{document}
\tableofcontents
\chapter{Chapter One}
\section{Section One One}
\subsection{Section One Two}
\chapter{Chapter Two}
\section{Section Two One}
\end{document}
In book
class, however, it works with no error!
book
ormemoir
. (I found these characters by copying the entire line for which I was given an error and pasting it into the "UTF8 String" field on www.isthisthingon.org/unicode, which gave me a list of all characters used.) Which editor are you using? These invisible character questions have been popping up fairly frequently recently, perhaps there's a bug in the editor. (Also, voting to close as too localized, let us know if it's not working)book.cls
, so it is clear it works there.memoir.cls
has a completely different way of defining chapters, so you can easily produce a conflict by "injecting" code frombook.cls
there. Document structure etc. are completely in the resposibility of document classes, so you need to consider which class you are using. Please modify the code frommemoir.cls
instead.persian
, that "left to right mark" characters is there. How should i do for modifying this definition of chapter?pdflatex
(I wonder whether it works with XeTeX???), but that's not the error message reported by the OP. That one really stems from transplantingbook.cls
code to memoir.