I would like to produce a title for a table of contents that is highlighted in yellow. However the code


does not seem to work, instead giving the error message "Use of \@undeclaredcolor doesn't match its definition." I was wondering if there is a way that I can achieve this effect.

  • 1
    Welcome to TeX.SE. Please provide a minimal working document (or that one that shows this error. Remove all unnecessary packages! Have you used \usepackage{xcolor} or \usepackage{color} at all? – user31729 Jan 14 '17 at 21:33
  • A look into minitoc documentation reveals that \mtctitle is meant to contain a mere name, not complicated setup with \colorbox etc. – user31729 Jan 14 '17 at 21:41
  • But how can I have a highlighted contents title? – wb198 Jan 14 '17 at 21:43
  • This needs some investigation into the minitoc package code, as far as I know. – user31729 Jan 14 '17 at 21:45

Setting \mtctitle to anything but some easy 'string' is not the correct way. \mtctitle should contain the real name of the title and not additional fancy typesetting and decorations ;-)

The relevant code where the minitoc title is set is in \minitoc@, within a tabular environment:


The code with \mtctitle must be replaced by the code having the colorbox, this can't be done easily without patching the code.

However, in later parts of minitoc, actually \sv@minitoc@ is used by a \let\sv@minitoc@\minitoc@ statement, so \sv@minitoc@ has to be patched actually.

For sake of nicer appearance, I used tcolorbox instead of \colorbox.




\DeclareRobustCommand{\mtctitlebox}{\begin{tcolorbox}[colback=yellow,enhanced jigsaw,sharp corners,halign=left,left=1ex,nobeforeafter,boxrule=0pt]\mtctitle\end{tcolorbox}}





\section{Foo section}

enter image description here

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.