I am trying to use the titlesec and xcolor packages together (well, actually, the tufte-book class is, but that's another story.)
Here is a minimal LaTeX file that illustrates my problem:
\documentclass{book}
\usepackage{titlesec}
\usepackage[usenames]{xcolor}
\usepackage{textcase}
\titleformat{\part}[block]{}{\thepart}{1em}{\textcolor{darkgray}\MakeTextUppercase}
\begin{document}
\part{A Tale of Two Cities}
\end{document}
The 5th argument of \titleformat is supposed to add the section heading as an argument to the last command, so it should end up with \MakeTextUppercase{A Tale of Two Cities}. But running LaTeX on this file produces the following output:
! Argument of \MakeTextUppercase has an extra }.
Runaway argument?
! Paragraph ended before \MakeTextUppercase was complete.
However, if I remove \textcolor{darkgray} then everything works as expected. Also, if I insert \\ between \textcolor{darkgray} and \MakeTextUppercase, then everything also works as expected. But not if I put \\ before \textcolor{darkgray}.
Can anyone explain what is going on here?