0

How do I fix the line ends drawn with circuitikz?

enter image description here

\documentclass[border=3mm]{standalone}
\usepackage[siunitx,european]{circuitikz}
\usetikzlibrary{external} 
\tikzexternalize[prefix=tikz/]

\begin{document}
\small
\begin{circuitikz}
 \draw (0,0)node[anchor=east] {(0,0)}to [L,o-o]++(2,0) node(a){}node[anchor=west] {a};

\draw (0,0) |- (1,1);
\draw (a) |- (1,1);
\end{circuitikz}

\end{document}
4
  • You have a blank node superposed with the right pole, node(a){}, which has a non-zero size; you are connecting to its border. Look at the first FAQ in the circuitikz manual. You can "fix" it by using coordinate(a), but Zarko's solution is better.
    – Rmano
    Commented Jul 28, 2023 at 8:16
  • If I use coordinate(a) 6.1.1 Transparent poles says: This is because, for simplicity of operation, the nodes are placed after the wires are drawn and have to “white-out” the underlying lines. So is the wire at (0,0) a bug?
    – skvery
    Commented Jul 28, 2023 at 8:25
  • Are |- and -| wires drawn after the poles?
    – skvery
    Commented Jul 28, 2023 at 8:33
  • 1
    The poles are drawn after the lines in the same path. You have three paths here.
    – Rmano
    Commented Jul 28, 2023 at 11:13

4 Answers 4

3

Ah, with the last comment, now I understand your problem.

Nodes are drawn after the lines in the same path. In your example you have three different paths, that are drawn in order.

So you probably (apart from the problem with the nodecoordinate thing) want just one path here:

\documentclass[border=10pt]{standalone}
\usepackage{circuitikz}

\begin{document}
\begin{tikzpicture}
    \draw (0,0)node[anchor=east] {(0,0)} 
        to [L,o-o]++(2,0) coordinate(a){}
        node[anchor=west] {a}
    (0,0) |- (1,1)
    (a) |- (1,1);
\end{tikzpicture}
\end{document}

enter image description here

1
2

It is nor entirely clear what you like to fix so I only guess that you may be after the following:

enter image description here

MWE:

\documentclass[border=3mm]{standalone}
\usepackage[siunitx,european]{circuitikz}
\usetikzlibrary{external}
\tikzexternalize[prefix=tikz/]

\begin{document}
\small
\begin{circuitikz}
\draw (0,0) coordinate[label=left:{(0,0)}] (x) to [L] ++(2,0) coordinate[label=right:a] (a)
      (x) to [short, o-] ++ (0,1) -- ++ (2,0) to [short,-o] (a);
\end{circuitikz}
\end{document}
2

If you create a named ocirc node, lines will automatically be drawn to the edges, so long as you use the name and not the center coordinates.

\documentclass[border=3mm]{standalone}
\usepackage[siunitx,european]{circuitikz}
%\usetikzlibrary{external}
%\tikzexternalize[prefix=tikz/]% redundant in standalone

\begin{document}
\small
\begin{circuitikz}
 \draw (0,0)node[left] {(0,0)}
   node[ocirc,name=o]{} to [L] ++(2,0) node[ocirc,name=a]{}
   node[right] {a};

\draw (o) |- (1,1);
\draw (a) |- (1,1);
\end{circuitikz}

\end{document}
2
  • Yep, you're right! (But also node[ocirc](a){} works, I think...). This work if you have a reasonably new version of circuitikz (I added the border anchors for all nodes in 0.9.2)
    – Rmano
    Commented Jul 28, 2023 at 14:13
  • Oops, I was adding (a) after {}. That would never work. Commented Jul 28, 2023 at 21:03
1

Another solution, but without node.

   \documentclass\[border=3mm\]{standalone}
    \usepackage\[cuteinductor\]{circuitikz}
    \begin{document}
    \begin{circuitikz}
    \draw (0,0)node\[left\] {(0,0)}--++(0,1)--++(2,0)--++(0,-1)node\[right\]{(2,0)};
    \draw (0,0)to\[L,o-o\](2,0);
    \end{circuitikz}
    \end{document}

enter image description here

1
  • Nice, fixing the issue by doing the wires first!
    – skvery
    Commented Aug 2, 2023 at 19:21

You must log in to answer this question.

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