## LaTeX forum ⇒ Page Layout ⇒ What is wrong with tocloft ? Topic is solved

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Cham
Posts: 830
Joined: Sat Apr 02, 2011 4:06 pm

### What is wrong with tocloft ?  Topic is solved

I'm having troubles just for adding dots in the ToC, using the tocloft package. It's clashing with my header. Here's a MWE that reproduces my problem :

\documentclass[11pt,letterpaper,twoside]{article}\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}% For the ToC :\usepackage{tocloft}\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}}  % Add . . . for sections.% For headers :\usepackage[pagestyles,medium]{titlesec}\titleformat*{\subsubsection}{\bfseries\sffamily} % Header :\newpagestyle{principal}{	\sethead[\thepage][][\slshape\footnotesize\MakeUppercase{Name on right}]{\slshape{\footnotesize{Name on left}}}{}{\thepage}	\headrule} \begin{document} \pagestyle{principal} \tableofcontents \newpage\section{Title 1} \newpage\section{Title 2} \newpage\section{Title 3} \end{document}

Compiling this code gives an error : "Undefined control sequence".

What is wrong with this code ?

EDIT : Hmm, changing the order of \pagestyle{principal} and \tableofcontents appears to solve the issue, but I don't understand what is happening here.

Johannes_B
Site Moderator
Posts: 3644
Joined: Thu Nov 01, 2012 4:08 pm
Use the package that is shipped with titlesec.

\documentclass[11pt,letterpaper,twoside]{article}\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}% For the ToC :\usepackage{titletoc}\dottedcontents{section}[3.8em]{}{2.3em}{1pc} \usepackage[pagestyles,medium]{titlesec}\titleformat*{\subsubsection}{\bfseries\sffamily} % Header :\newpagestyle{principal}{\sethead[\thepage][][\slshape\footnotesize\MakeUppercase{Name on right}]{\slshape{\footnotesize Name on left}}{}{\thepage}\headrule} \begin{document} \pagestyle{principal} \tableofcontents \newpage\section{Title 1} \newpage\section{Title 2} \newpage\section{Title 3} \end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Cham
Posts: 830
Joined: Sat Apr 02, 2011 4:06 pm
Why titletoc ? The ToC style is now vastly different. The spacing is too dense, and the section titles should be in bold.

Stefan Kottwitz
Posts: 8708
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:
Something is not perfect with tocloft, but here's a quick fix for your preamble:

\makeatletter\let\ttl@savemark\relax\makeatother

It just creates the still undefined macro so that error does not happen, as a workaround.

Stefan