2

I am using pst-circ to draw a circuit. For this I want to draw a voltmeter, so I use newCircDipole to define a new element (MWE):

\documentclass{standalone}
\usepackage{pst-circ}
\newCircDipole{pscircmeter}
\makeatletter
\def\pst@draw@pscircmeter{%
    \pnode(-0.3,0){dipole@1}
    \pnode(0.3,0){dipole@2}
    \psline[fillstyle=none,linewidth=1.5\pslinewidth,arrowinset=0]{->}%
        (-0.4,-0.4)(0.45,0.45)
    \pscircle[linewidth=1.5\pslinewidth,fillstyle=solid](0,0){0.3}
}
\makeatother
\def\voltmeter{\pscircmeter[labeloffset=0]}
\begin{document}
\begin{pspicture}[showgrid=false](-1,-1)(1,1)
    \pnodes(0,-1){A}(0,1){B}
    \voltmeter(B)(A){V}
\end{pspicture}
\end{document}    

and then use it as \voltmeter(A)(B){V}. Clearly I am going for this:

circuit voltmeter

My question is about rotating this construct. If the nodes A and B are on top of each other, the pscircmeter gets rotated with the arrow, see the MWE above. However, I want to retain the direction of the arrow (down-left to top-right) similar to the correct alignment of the text label (up).


I realise there might be cases where the wire and the arrow align, but I am willing to risk that.


While we are at it: Is it possible to change the default label to V so that I can use it as \voltmeter(A)(B){} an still get the V printed?

1 Answer 1

2
\documentclass{standalone}
\usepackage{pst-circ}
\newCircDipole{pscircmeter}
\makeatletter
\def\pst@draw@pscircmeter{%
    \pnode(-0.3,0){dipole@1}
    \pnode(0.3,0){dipole@2}
    \pscircle[linewidth=1.5\pslinewidth,fillstyle=solid](0,0){0.3}
}
\makeatother
\def\voltmeter{%      
    \psline[linewidth=1.5\pslinewidth,arrowinset=0]{->}(-0.4,-0.4)(0.45,0.45)
    \pscircmeter[labeloffset=0]}
\begin{document}
\begin{pspicture}[showgrid=false](-1,-1)(1,1)
    \pnodes(0,-1){A}(0,1){B}
    \voltmeter(B)(A){V}
\end{pspicture}
\begin{pspicture}[showgrid=false](-1,-1)(1,1)
  \pnodes(-1,0){A}(1,0){B}
  \voltmeter(B)(A){V}
\end{pspicture}
\end{document} 

enter image description here

Drawing the label V by default is possible but not really easy to solve.

1
  • Nice! It does fail, however, if I attempt to use the parallel option. (So for my ammeter this will work perfectly.)
    – fborchers
    Feb 13, 2019 at 19:44

You must log in to answer this question.

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