0

This question already has an answer here:

As per the tocloft package documentation, we should be able to use \renewcommand{\cftsecpresnum}{something} to insert some text before the section number in the table of contents (for example, should work for list of tables, list of figures, and a custom list using \newlistof).

However, when I use that command the I want to insert before the section heading entry in the table of contents overlaps with the section heading text. See MWE. Am I missing something here? I did not immediately see an answer to address this, specifically as to whether or not the \cftsecpresnum command from the tocloft works or not. As per below I would have to use \cftsecindent as a work around, but that was not mentioned in the package documentation and not sure if that is the intent.

Thanks in advance!

\documentclass{report}

\usepackage{tocloft}
\renewcommand{\cftsecpresnum}{Something }

\begin{document}

\tableofcontents

\section{what}
  Bananas

\section{is the deal}
  Apples

\end{document}

enter image description here

marked as duplicate by Werner, Phelype Oleinik, vonbrand, Kurt, Stefan Pinnow Jul 6 '18 at 18:57

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Related/duplicate: Roman numerals become “too wide” in table of contents – Werner Jul 5 '18 at 23:01
  • That question would have provided me with a solution, and in my mind is the same. But is it acknowledged that it isn't specified (or isn't required to be specified) in the documentation? I have similar comment below as well...how would this be achieved for a custom list? Or new question? – Prevost Jul 6 '18 at 4:38
  • I agree that the link provided gives an answer to the question I asked. I would not object if this question is closed. – Prevost Jul 17 '18 at 15:07
2

You have to increase the value if \cftsecnumwidth. here is a solution, using calc:

\documentclass{report}
\usepackage{calc}
\usepackage{tocloft}
\renewcommand{\cftsecpresnum}{Something }
\setlength{\cftsecnumwidth}{\widthof{Something\hspace{2.5em}}}
\setlength{\cftsecindent}{0pt}
\begin{document}

\tableofcontents

\section{what}
  Bananas

\section{is the deal}
  Apples

\end{document} 

enter image description here

  • Thank you. That would work and I didn't know/think of calc...is there a way to adjust the equivalent of \cftsecnumwidth for a custom list or would that be a new question? – Prevost Jul 6 '18 at 4:36
  • There are ways, with enumitem, which depend on the list type. I think it's better to ask a new question. – Bernard Jul 6 '18 at 8:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.