[Tex/LaTex] Setting text color in TikZ without changing line color; conflict with double

colortikz-pgf

I have a certain TikZ style that I would like to use over and over again (so I'd like to use it as a scope). Namely, I want the color of the curves to be red, with white borders (to give a "crossing over" effect when the curves go over each other), and I want the color of the text to be red too. Currently I am using the double effect to accomplish this, like so:

\tikzset{curveinscope/.style={
    every path/.style={
        draw=white, double distance=1pt, line width=2pt, double=red, color=red}
    }
}

However this clashes with the double effect: setting color=red to make the text color red sets the drawing color of the first line in the double to also be red, which messes up the effect (it needs to be white).

How can I fix this?

Best Answer

You should set the color using text=red instead of color=red:

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}

\tikzset{curveinscope/.style={every path/.style={draw=white, double distance=1pt, line width=2pt, double=red, text=red}}}

\begin{scope}[curveinscope]
\node at (1,0) {X};
\draw (0,0) -- (2,2);
\draw (2,1) -- (0,1);
\end{scope}

\end{tikzpicture}
\end{document}