4

I follow a convention in which I make voltages blue and currents red.

Making the current direction red is pretty simple. I just add "color=red" to the options for the specific current direction. But what about the text?

The PGF manual suggests changing the style, like so:

\begin{tikzpicture}[circuit ee IEC,every info/.style=red]
\node [resistor,info=$3\Omega$] {};
\end{tikzpicture}

The trouble with this is that it makes ALL the info labels red. I just want the current direction labels to be red.

Here is my minimal working example:

\documentclass{standalone}

\usepackage{amsmath}

\usepackage{tikz}
\usetikzlibrary{arrows,circuits.ee.IEC,positioning}

\begin{document}

\begin{tikzpicture}[circuit ee IEC,x=2cm,y=1.5cm,
small circuit symbols,
set inductor graphic=var inductor IEC graphic,
set diode graphic=var diode IEC graphic]

\foreach \contact/\x in {0/0,2/3}
{
\node [contact] (upper contact \contact) at (\x,4) {};
}
\node [coordinate] (upper right limit) at (6,4) {};
\node [coordinate] (lower right limit) at (6,0) {};

\draw (upper contact 0) to[current direction={near start,color=red,text=red,info=$\text{I}_2$},resistor={info={$\text{R}_1$}}] (upper contact 2);

\end{tikzpicture}

\end{document}

I tried adding "text=red", after I saw it in this example, but that does not work.

1 Answer 1

4

Try swapping this in:

info={\color{red}$\text{I}_2$}

enter image description here

Even shorter is Gonzalo's suggestion:

info={[red]$\text{I}_2$}
5
  • 3
    You can also use info={[red]$\text{I}_2$}. May 16, 2012 at 18:17
  • Even easier! I'll add it.
    – qubyte
    May 16, 2012 at 18:19
  • Excellent! Can anybody point me to where I would find this in the TikZ documentation? May 16, 2012 at 19:07
  • @MarkS.Everitt: is there a way to set this in a style, so that it applies only to current directions, for example? May 16, 2012 at 19:09
  • I just attempted this and then realised that you're unlikely to want the same label on the current all the time. I'm not sure of a way of making this a style without fixing the label text I'm afraid.
    – qubyte
    May 18, 2012 at 15:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .