# How can I circumvent this TikZ circuits bug when placing symbols at start or at end?

In the following MWE (essentially taken from page 603 of the pgf manual), when I try to place the symbols at start and at end, two unintended effects occur:

1. In each symbol there is an extra line extending from its center to its edge.
2. The the to path connects to the left side of the symbol at end. (I assume that TikZ "forgets" to transform the symbol coordinate system in order to make its x axis align with the path.)
\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{circuits}

\begin{document}

\begin{tikzpicture}[transform shape,circuit]
\draw (0,0) to [circuit handle symbol={draw,shape=rectangle,near start},
circuit handle symbol={draw,shape=circle,near end}] (0,3);
\begin{tikzpicture}[transform shape,circuit]
\draw (0,0) to [circuit handle symbol={draw,shape=rectangle,at start},
circuit handle symbol={draw,shape=circle,at end}] (0,3);
\end{tikzpicture}

\end{document}


There is a bug report about this issue. It is, however, from early 2017 which does not make me hopeful that this will be fixed in the near future.

Since I need to typeset documents now: Is there a way for me to fix this locally while preserving the TikZ syntax? (I would like the drawings to be able to be typeset with TikZ once the bug is fixed.)

• How about \begin{tikzpicture}[transform shape,circuit] \draw (0,0) to [circuit handle symbol={draw,shape=rectangle,pos=0.05}, circuit handle symbol={draw,shape=circle,pos=0.95}] (0,3); \end{tikzpicture}? I am not sure I would call this a bug. After all this is a circuit and you are essentially moving stuff out of it. – user121799 May 8 '19 at 14:14
• @marmot: I absolutely disagree. Placing a symbol at the end of a path does not mean placing it outside a circuit. ground, for example, only ever makes sense at the end of a path. However, your comment led me to tinker around a bit and I found that pos=1.0 works (while pos=1 does not). I don't know why this is, but it is just the workaround I was looking for. – schtandard May 8 '19 at 16:55

Update: The Bug has been fixed in the latest release of pgf (version 3.1.3).

I do not know why, but

\tikzset{
at start/.style={pos=0.0},
at end/.style={pos=1.0},
}


seems to solve the problem. (The original definition is with pos=0 and pos=1.)

• How is that conceptually different from my comment? And I would never overwrite the standard TikZ definitions. – user121799 May 8 '19 at 17:01
• Well, in your comment you suggested to place the symbol close to (but not at) the start/end of the path. It turned out that one can actually correctly place a symbol at the end of a path by saying pos=1.0 instead of pos=1. I think those are conceptually different assertions. I still believe this to be a bug (after all 1.0 should not be treated differently here than 1; indeed the default definition expects 1 to work). – schtandard May 8 '19 at 17:08
• Regarding your concern about overwriting standard definitions: While I agree in principle, in this particular case (replacing 0 with 0.0 and 1 with 1.0) I am not very worried at all. (Though in general an append style would be safer, of course.) – schtandard May 8 '19 at 17:11
• OK, let's agree that we disagree with each other's judgement. I made a proposal that works, you say that you do not like the numerical values I used. (My proposal was also motivated by tex.stackexchange.com/a/431765/121799.) Not much I can do. You say there is a bug, I do not see that. You say that replacing the integers by floats should be fine, but at the same time you see that this can have important consequences. I guess each of us can defend their view, so it is best if we depart peacefully. ;-) – user121799 May 8 '19 at 17:23
• You do not have to agree with me, of course. But maybe this example will help you understand: \documentclass{article} \usepackage{tikz} \usetikzlibrary{circuits.ee.IEC} \begin{document} \begin{tikzpicture}[circuit ee IEC] \foreach \p [count=\i] in {0.9, 0.95, 0.99, 0.999999, 1, 1.0} { \draw (\i,0) node [above] {\p} to[resistor={near start}, ground={pos=\p}] (\i,-3); } \end{tikzpicture} \end{document} If you still see no bug and still propose using a numerical value close(ish) to 1, then I guess we disagree. – schtandard May 8 '19 at 18:53