Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

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}
share|improve this answer
    
Jake to the rescue again! –  Stephen Bosch May 15 '12 at 23:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.