# Differences among commands in coloring node labels in tikz

I wonder if there are fundamental differences among the following label coloring procedures in TiKZ (aside from defining a style as mentioned in the manual) since they seem to produce the same effect, or is it just a matter of coding style?

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\begin{tikzpicture}
\node (m1) at (0,0) (0,-2mm) [label={[red]right:$A$}]{First method}; %
\node (m2) [below=of m1] [label=right:\textcolor{red}{$A$}]{Second method};
\node (m3) [below=of m2] [label=right:{\color{red}$A$}]{Third method};
\end{tikzpicture}

\end{document}


-

The last two belong to xcolor package. From its manual:

• \color{<color>}[<model-list>]{<spec-list>} Switches to the color given either by name/expression or by model/specification. This color will stay in effect until the end of the current TeX group.

• \textcolor{<color>}{<text>}[<model-list>]{<spec-list>}{<text>} are just alternative syntax for \color, in which the groups are added implicitly. Thus <text> appears in the specified color, but then the color reverts to its previous value. Additionally, it calls \leavevmode to ensure the start of horizontal mode.

The first one is TikZ related and it recognizes the color name. Then, sets

fill=red,draw=red,text=red


This command doesn't operate on the text inside the box and lets the regular mechanism work for the color change. Others operate directly inside the node text box.

Example:

\begin{tikzpicture}
\node[blue] (a) {\color{red}This should be blue};
\end{tikzpicture}


-

To see the differences, look at this modified example:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\node (m1) [label={[red]right:@$A$B}]{First method}; %
\node (m2) [below=of m1] [label=right:@\textcolor{red}{$A$}B]{Second method};
\node (m3) [below=of m2] [label=right:{@\color{red}$A$B}]{Third method};
\end{tikzpicture}
\end{document}


With first method, the whole text is red.

With second method, it's just $A$.

With third method, the text is red from the call to \color to the end of the label (or another call to \color).

-