3

Please forgive me if the answer to this question should be obvious. I have read the TikZ manual, and ordinarily one would address this issue with cycle, but cycle behaves funny with the circuits library.

When I have a circuit with a fork in it, I have to draw the forked section in two steps. The trouble is that the second path never actually contacts the path which is actually on the node I am referencing.

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,
every info/.style={font=\footnotesize},
small circuit symbols,
set inductor graphic=var inductor IEC graphic,
set diode graphic=var diode IEC graphic,
set make contact graphic= var make contact IEC graphic]

\foreach \contact/\x in {0/0,2/3}
{
\node [contact] (upper contact \contact) at (\x,4) {};
\node [contact] (lower contact \contact) at (\x,0) {};
}
\draw (upper contact 0) to [current direction={near start,info=$I_1$},resistor={info={$\text{R}_1$}},inductor={near end,info={$\text{jX}_1$}}] (upper contact 2);
\draw (upper contact 2) to[inductor={info={$\text{jX}_2$}}] (5,4)
    to[resistor={info={$\frac{\text{R}_2}{\text{s}}$}}] (5,0)
    to (lower contact 2)
    to ++(0,1) node (lower fork) {}
    -- ++(-1,0) to[resistor={info={$\text{R}_\text{m}$}}] ++(0,2)
    to ++(1,0) node (upper fork) {}
    to (upper contact 2);
\draw (upper fork) -- ++(1,0)
    to[inductor={info={$\text{jX}_\text{m}$}}] ++(0,-2)
    to (lower fork);

\end{tikzpicture}

\end{document}

enter image description here

I could draw over existing lines and do the same thing on the way down that I did on the way up, but like the solution offered in this post, that just seems like a kludge. What is the right way to solve this problem? Does a "right way" even exist?

1 Answer 1

4

When specifying coordinates, don't use empty \nodes, but use \coordinate (<name>) (or, equivalently, \node [coordinate] (<name>) {}). Empty nodes still contain some white space, caused by the inner sep and outer sep, so your lines don't join properly.

In your code, the line

to ++(0,1) node (lower fork) {}

could be replaced by either of

to ++(0,1) coordinate (lower fork)

or

to ++(0,1) node [coordinate] (lower fork) {}

or

to ++(0,1) node [inner sep=0pt, outer sep=-\pgflinewidth] (lower fork) {}

I'd recommend the first version.

\documentclass{standalone}

\usepackage{amsmath}

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

\begin{document}

\begin{tikzpicture}[circuit ee IEC,x=2cm,y=1.5cm,
every info/.style={font=\footnotesize},
small circuit symbols,
set inductor graphic=var inductor IEC graphic,
set diode graphic=var diode IEC graphic,
set make contact graphic= var make contact IEC graphic]

\foreach \contact/\x in {0/0,2/3}
{
\node [contact] (upper contact \contact) at (\x,4) {};
\node [contact] (lower contact \contact) at (\x,0) {};
}
\draw (upper contact 0) to [current direction={near start,info=$I_1$},resistor={info={$\text{R}_1$}},inductor={near end,info={$\text{jX}_1$}}] (upper contact 2);
\draw (upper contact 2) to[inductor={info={$\text{jX}_2$}}] (5,4)
    to[resistor={info={$\frac{\text{R}_2}{\text{s}}$}}] (5,0)
    to (lower contact 2)
    to ++(0,1) coordinate (lower fork)
    -- ++(-1,0) to[resistor={info={$\text{R}_\text{m}$}}] ++(0,2)
    to ++(1,0) coordinate (upper fork)
    to (upper contact 2);
\draw (upper fork) -- ++(1,0)
    to[inductor={info={$\text{jX}_\text{m}$}}] ++(0,-2)
    to (lower fork);

\end{tikzpicture}

\end{document}
1
  • Jake to the rescue again! Commented May 15, 2012 at 23:01

You must log in to answer this question.

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