As you can guess from the title, I am using the package tocloft to customize the table of contents of a document, which, by the way, I am compiling with LuaTeX.

The final result that I would like to get can be simplified as follows:

desired TOC

The feature that I am not able to implement on my own is the black background of the part title. Please ignore the other design features of the picture I have posted that may differ from the standard latex TOC (e.g. the missing page number).

Do you know how can I achieve such look? Thanks.


You might want to look into titletoc, it allows to use \colorbox without hacks.

If you really want to keep using tocloft you can use a hack: Capture the title in a \hbox, which you \unhbox later in the colorbox:

\part{Teil 1}
\chapter{Kapitel 1}
\section{Abschnitt 1}
\part{Teil 2}
\chapter{Kapitel 2}
\section{Abschnitt 2}

enter image description here

  • it works perfectly! thanks. I think I am going to keep using tocloft simply because I have some other customized features which I do not have time to move to titletoc. Would you in general suggest, for the next times, to move to titletoc? – oibaFox Apr 19 '18 at 13:45
  • 1
    I don't have enough experience with either of them to give a really qualified recommendation, but it looks like titletoc is probably better if you not only just want to change some details. For small changes there is a significant advantage for tocloft through: You can change some separated settings instead of having to change all parameters at one go. – Marcel Krüger Apr 19 '18 at 14:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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