I'd like to use code highlighting for LaTeX in my sectional titles. In the titles themselves it works, but the it does not in the Table of Contents. Here a minimal example:
\documentclass{scrartcl}\usepackage{minted}\begin{document}\tableofcontents\section{\mintinline{python}{print ``this''}}\mintinline{python}{print ``this''}\section{\mintinline{latex}{\documentclass[]{}}}\mintinline{latex}{\documentclass[]{}}\end{document}
and the corresponding output:
The complete error from the .toc
file reads:
\GenericError { }{LaTeX Error: Can be used only in preamble}{See the LaTeX manual or LaTeX Companion for explanation.}{Your command was ignored.\MessageBreak Type I <command> <return> to replace it with another command,\MessageBreak or <return> to continue without it.
Any ideas how to allow \mintedinline
in the ToC entries?