Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

\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).

share|improve this answer
    
Excellent. My fault for assuming I knew what \textcolor does... –  ptomato Sep 3 '12 at 11:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.