The following mwe which includes \subsection{\colorbox{green}{Subtitle}}
does not work when %\section{\colorbox{green}{Title}}
is uncommented.
\documentclass[11pt]{book}
\usepackage[usenames,dvipsnames]{xcolor}
\begin{document}
%\section{\colorbox{green}{Title}}
\subsection{\colorbox{green}{Subtitle}}
\end{document}
The error seems to be due to the fact that LaTeX reads GREEN
instead of green
.
Best Answer
Try like this:
The problem is created by adding the colorbox inside the bookmarks and the TOC and the header...
EDIT For colorbox in TOC: