9

Why isn't the wire centered in the connector located at the point (2.5,0)?

\documentclass[]{article}

\usepackage{tikz}

\usetikzlibrary{circuits.logic.IEC}
\tikzset{circuit declare symbol = ammeter}
\tikzset{set ammeter graphic ={draw,generic circle IEC, minimum size=5mm,info=center:A}}
\tikzset{circuit declare symbol = vmmeter}
\tikzset{set vmmeter graphic ={draw,generic circle IEC, minimum size=5mm,info=center:V}}

\begin{document}
\begin{tikzpicture}[circuit ee IEC,every info/.style=red,
set resistor graphic=var resistor IEC graphic]

\draw (0,0) 
to[battery] (0,2) to [make contact](3,2)
to [ammeter] (3,0)--(2.5,0)
to [vmmeter] (.5,0)--(0,0);
\draw (0,0)--(.5,0) to[contact={at start}] (.5,-2) to[resistor={info={R ($\Omega$)}}] (2.5,-2) to[contact={at end}] (2.5,0)--(3,0);\end{tikzpicture}
\end{document}

enter image description here

  • 1
    It's a rounding problem. You can use \draw (.5,0) to[contact={at start}] (.5,-2) to[resistor={info={R ($\Omega$)}}] (2.5,-2) to[contact={pos=0.99999}] (2.5,0);. Notice also that you had some spurious paths in your \draw command. – Gonzalo Medina Mar 28 '14 at 0:06
7

It shouldn't be like that but I don't understand why. Here is a work around.

\documentclass[]{article}

\usepackage{tikz}
\usetikzlibrary{circuits.ee.IEC}
%\usetikzlibrary{circuits.logic.IEC}
\tikzset{circuit declare symbol = ammeter}
\tikzset{set ammeter graphic ={draw,generic circle IEC, minimum size=5mm,info=center:A}}
\tikzset{circuit declare symbol = vmmeter}
\tikzset{set vmmeter graphic ={draw,generic circle IEC, minimum size=5mm,info=center:V}}

\begin{document}
\begin{tikzpicture}[circuit ee IEC,every info/.style=red,
set resistor graphic=var resistor IEC graphic]

 \draw (0,0)
to[battery] (0,2) to [make contact](3,2)
to [ammeter] (3,0)--(2.5,0)
to [vmmeter] (.5,0)--(0,0);
\draw (0,0)--(.5,0) to[contact={at start}] (.5,-2) to[resistor={info={R ($\Omega$)}}] (2.5,-2) to (2.5,0)node[contact] {}--(3,0);
\end{tikzpicture}
\end{document}

enter image description here

1

A PSTricks solution:

\documentclass{article}

\usepackage{pst-circ}
\usepackage{siunitx}
\newcommand*\device[3]{%
  \circledipole[labeloffset = 0](#1)(#2){\textcolor{red}{\si{#3}}}}


\begin{document}

\begin{pspicture}(-0.5,-0.25)(6.5,7.5)
  \pnodes{P}(1,0)(5,0)(0,4)(1,4)(5,4)(6,4)(0,7)(6,7)
 {\psset{arrows = -*}
  \wire(P0)(P3)
  \wire(P1)(P4)}
  \resistor[dipolestyle = zigzag](P0)(P1){\textcolor{red}{$R$~(\si{\ohm})}}
  \device{P3}{P4}{\V}
  \device{P5}{P7}{\A}
  \wire(P2)(P3)
  \wire(P4)(P5)
  \battery(P2)(P6){}
  \newSwitch[ison = false](P6)(P7){}
\end{pspicture}

\end{document}

output

Note that pst-circ is used for the electrical diagram itself and siunitx is used for the units.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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