[Tex/LaTex] Ground symbol from circuits.ee.IEC library

tikz-circuit-libtikz-pgf

I wish to draw a ground symbol in a circuit diagram using the circuits.ee.IEC TiKZ library. The example in the PGF Manual (pdf) on page 311 shows exactly what I want. However, when I try to draw it, the wire is extended beyond the ground symbol:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{circuits.ee.IEC}

\begin{document}
\begin{tikzpicture}[circuit ee IEC]
\draw (0,0) to[ground] (3,0);
\end{tikzpicture}
\end{document}

Ground symbol does not end wire

How do I fix this, so the ground symbol ends the wire as in the example?

Best Answer

You can supply pos=1 to the ground key to position the symbol at the end of the line instead of in the middle:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{circuits.ee.IEC}

\begin{document}
\begin{tikzpicture}[circuit ee IEC]
\draw (0,0) to [ground={pos=1}] (3,0);
\end{tikzpicture}
\end{document}

Or, as percusse suggested in a comment, you could place the symbol as a "proper" node instead of passing it to the to keyword. Note that you'll have to supply an empty set of brackets and use the right keyword (and an appropriate rotate option if the wire isn't going from left to right).

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{circuits.ee.IEC}

\begin{document}
\begin{tikzpicture}[circuit ee IEC]
\draw (0,0) -- (3,0) node [ground, right] {};
\end{tikzpicture}
\end{document}