# Why does \color{blue} after \paragraph{...} color the paragraph title blue?

\paragraph is set at the start of the next paragraph. The next paragraph starts with the first letter O of Only after \color{blue}.

Fixes:

• \leavevmode to explicitly start the paragraph before the color change:

\paragraph{Why am I blue?}
\leavevmode
{\color{blue} Only I am supposed to be blue!}

• \textcolor to limit the scope of the color setting:

\paragraph{Why am I blue?}
\textcolor{blue}{Only I am supposed to be blue!}


The result in both cases with updated text:

To complement Heiko’s (as usual) fine answer, some more words about the workings of \paragraph.

The command is defined in terms of \@startsection with a certain set of parameters, one of which is taken as the given title; one of the parameters tells LaTeX that the heading should be typeset inline, so the title is momentarily stored away.

It will be reinserted when the following paragraph starts. This allows a more free syntax: the input

\paragraph{Title} Some text


produces the same result as

\paragraph{Title}

Some text


and adding a \label after \paragraph{Title} doesn't insert unwanted spaces.

In both cases, \paragraph{Title} doesn't start a (text) paragraph (the unfortunate name clash might be distracting). The next paragraph start is triggered by S (it could also be \indent, \noindent, \leavevmode or \hspace, essentially what the TeXbook calls a horizontal command).

When TeX sees this S it backs it up, inserts parskip glue and the indentation box. After this it inserts whatever has been stored away, which is not only the title, but also

1. instructions to remove the indentation box;
2. the stored title, possibly preceded or followed by the paragraph number;
3. instructions for correct spacing the title from the following text and for avoiding that a page break occurs immediately following the line with the title.

In particular, the title is inserted as part of the current (text) paragraph. After this the S that triggered the action is reinserted back and TeX continues reading the text for later break it into lines.

In your case the horizontal command is O, which is already under the scope of \color{blue}, so also the title is typeset blue.

As a general rule, avoid \color before starting a (text) paragraph.

Instead of the arcane \leavevmode you can also use \indent, \noindent or \hspace{0pt}.

\documentclass{article}
\usepackage{xcolor}

\begin{document}

\paragraph{Test}

{\color{blue}XXXX}

\paragraph{Test}

\indent{\color{blue}XXXX}

\paragraph{Test}

\noindent{\color{blue}XXXX}

\paragraph{Test}

\hspace{0pt}{\color{blue}XXXX}

\paragraph{Test}

\leavevmode{\color{blue}XXXX}

\paragraph{Test}

\textcolor{blue}{XXXX}

\end{document}