# Titlesec and xcolor not playing nicely?

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?

-

\textcolor requires two arguments and with your code the first is darkgray and the second is \MakeTextUppercase, which is wrong.

However, the title is typeset in a group, so

\titleformat{\part}[block]{}{\thepart}{1em}{\color{darkgray}\MakeTextUppercase}


will do (and probably you want to apply the coloring also to \thepart).

-
Excellent. My fault for assuming I knew what \textcolor does... –  ptomato Sep 3 '12 at 11:35