1

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

Prevost
  • 345

1 Answers1

3

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

Bernard
  • 271,350
  • 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 06 '18 at 04:36
  • There are ways, with enumitem, which depend on the list type. I think it's better to ask a new question. – Bernard Jul 06 '18 at 08:03