LaTeX forum ⇒ Page LayoutWhat 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).
User avatar
Cham
Posts: 820
Joined: Sat Apr 02, 2011 4:06 pm

What is wrong with tocloft ?  Topic is solved

Postby Cham » Sat Oct 14, 2017 6:09 pm

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 :

  1. \documentclass[11pt,letterpaper,twoside]{article}
  2. \usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
  3. % For the ToC :
  4. \usepackage{tocloft}
  5. \renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}} % Add . . . for sections.
  6. % For headers :
  7. \usepackage[pagestyles,medium]{titlesec}
  8. \titleformat*{\subsubsection}{\bfseries\sffamily}
  9.  
  10. % Header :
  11. \newpagestyle{principal}{
  12. \sethead[\thepage][][\slshape\footnotesize\MakeUppercase{Name on right}]{\slshape{\footnotesize{Name on left}}}{}{\thepage}
  13. \headrule
  14. }
  15.  
  16. \begin{document}
  17.  
  18. \pagestyle{principal}
  19.  
  20. \tableofcontents
  21.  
  22. \newpage
  23. \section{Title 1}
  24.  
  25. \newpage
  26. \section{Title 2}
  27.  
  28. \newpage
  29. \section{Title 3}
  30.  
  31. \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.

User avatar
Johannes_B
Site Moderator
Posts: 3587
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Sun Oct 15, 2017 9:12 am

Use the package that is shipped with titlesec.

  1. \documentclass[11pt,letterpaper,twoside]{article}
  2. \usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
  3. % For the ToC :
  4. \usepackage{titletoc}
  5. \dottedcontents{section}[3.8em]{}{2.3em}{1pc}
  6.  
  7. \usepackage[pagestyles,medium]{titlesec}
  8. \titleformat*{\subsubsection}{\bfseries\sffamily}
  9.  
  10. % Header :
  11. \newpagestyle{principal}{
  12. \sethead[\thepage][][\slshape\footnotesize\MakeUppercase{Name on right}]{\slshape{\footnotesize Name on left}}{}{\thepage}
  13. \headrule
  14. }
  15.  
  16. \begin{document}
  17.  
  18. \pagestyle{principal}
  19.  
  20. \tableofcontents
  21.  
  22. \newpage
  23. \section{Title 1}
  24.  
  25. \newpage
  26. \section{Title 2}
  27.  
  28. \newpage
  29. \section{Title 3}
  30.  
  31. \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.

User avatar
Cham
Posts: 820
Joined: Sat Apr 02, 2011 4:06 pm

Postby Cham » Sun Oct 15, 2017 6:25 pm

Why titletoc ? The ToC style is now vastly different. The spacing is too dense, and the section titles should be in bold.

User avatar
Stefan Kottwitz
Site Admin
Posts: 8544
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Mon Oct 16, 2017 12:22 am

Something is not perfect with tocloft, but here's a quick fix for your preamble:

  1. \makeatletter
  2. \let\ttl@savemark\relax
  3. \makeatother


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

Stefan
Site admin


Return to “Page Layout”

Who is online

Users browsing this forum: No registered users and 5 guests