Note: It turns out that this is an issue with circuitikz 1.0 and is apparently not a problem in the current version. A workaround would still be helpful, but it means the question isn't very urgent - I'll find a way to work around it for now and then update later.
I'm trying to draw some diagrams that mix circuit symbols with other notation. To do this I'm attempting to use circuitikz. However, it seems that when I attempt to add a circuit symbol to a path, it causes the path to overlap the nodes it's drawn between. Here's a minimal example - the only thing different between these paths is the use of [R]
to draw a resistor.
Is there a way I can prevent this from happening, so that the second diagram will look like the first, except with a resistor drawn in the middle of the line?
I know that I could fill the nodes and draw them after the line, and will do if I have to. However, in my actual document this is drawn with a series of macros and I'd have to change a lot to accomplish that. So I'm looking for an easier solution, if one exists.
Because it's drawn with macros, the solution needs to be automatic - it will be a lot of work for me if I manually need to specify things like A.east
and B.west
. In addition, the nodes aren't necessarily all directly above/below or left/right of each other in the real diagram.
Here's the mwe code:
\documentclass{article}
\usepackage{circuitikz}
% make the resistor a suitable size
\ctikzset{bipoles/resistor/height=0.1}
\ctikzset{bipoles/resistor/width=0.3}
\begin{document}
% two squares with a line between them
\begin{tikzpicture}
\node at (0,0) [draw] (A) {};
\node at (1,0) [draw] (B) {};
\draw (A) to (B);
\end{tikzpicture}
% the same but with a resistor drawn on the line
\begin{tikzpicture}
\node at (0,0) [draw] (A) {};
\node at (1,0) [draw] (B) {};
\draw (A) to[R] (B);
\end{tikzpicture}
\end{document}
\draw (A.east) to[R] (B.west)
.circuitikz
(version 1.2.3 (2020/08/07) I can't reproduce your result. As line as resistors start and end at nodes' bodes borders. Check if you have the recent version ofcircuitikz
.\pgfcircversion
displays "1.0", so I guess my version is out of date. I don't really want to mess with my TeX installation at the moment though, due to an upcoming deadline. So I will edit to specify that I need a solution for 1.0.