[Tex/LaTex] No drawing of ohmmeter or multimeter using circuitikz

circuitikzsymbols

I can't draw an ohmmeter in a simple electric circuit, although I am using circuitikz. If I replace ohmmeter by voltmeter or ammeter, it works fine, otherwise, not. Also, is there any symbol for multimeter?

My circuit is

\begin{circuitikz}[american] 
\draw
(0,0) to[battery] (0,4)
(0,4) to[short, o-o] (2,4) 
(2,0) to[short,o-o] (0,0)
(3,4) to[R, o-o] (3,0)
(3,4) -- (4,4) 
   to[ohmmeter] (4,0)
(4,0) to[short,o-o] (3,0)
\end{circuitikz}

Best Answer

It seems ohmmeter not defined even though it is in the documentation. However, since ohmmeter is identical to voltmeter except the text letter, you can define the symbol as follows.

\documentclass[border={5pt}]{standalone}


\usepackage[american voltages,siunitx]{circuitikz}


\makeatletter
\def\pgf@circ@myvoltmeter@path#1{\pgf@circ@bipole@path{myvoltmeter}{#1}}
\tikzset{ohmmeter/.style = {\circuitikzbasekey, /tikz/to
                               path=\pgf@circ@myvoltmeter@path}}
\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/voltmeter/height}}{myvoltmeter}
    {\ctikzvalof{bipoles/voltmeter/height}}{\ctikzvalof{bipoles/voltmeter/width}}
{
  \def\pgf@circ@temp{right}
  \ifx\tikz@res@label@pos\pgf@circ@temp
    \pgf@circ@res@step=-1.2\pgf@circ@res@up
  \else
    \def\pgf@circ@temp{below}
    \ifx\tikz@res@label@pos\pgf@circ@temp
      \pgf@circ@res@step=-1.2\pgf@circ@res@up
    \else
      \pgf@circ@res@step=1.2\pgf@circ@res@up
    \fi
  \fi

  \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}     
  \pgfpointorigin   \pgf@circ@res@other =  \pgf@x
  \advance \pgf@circ@res@other by -\pgf@circ@res@up
  \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{\pgf@circ@res@zero}}
  \pgfusepath{draw}

  \pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}
                   \pgfstartlinewidth}

  \pgfscope
    \pgfpathcircle{\pgfpointorigin}{\pgf@circ@res@up}
    \pgfusepath{draw}       
  \endpgfscope  

  \pgfsetlinewidth{\pgfstartlinewidth}
  \pgftransformrotate{90} % rotate the label
  \pgfpathmoveto{\pgfpoint{-\pgf@circ@res@other}{.8\pgf@circ@res@up}}
  \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{.8\pgf@circ@res@down}}
  \pgfusepath{draw}
  \pgfnode{circle}{center}{\textbf{\Large \si{\ohm}}}{}{}
  \pgfscope
     \pgftransformshift{\pgfpoint{-\pgf@circ@res@other}{.8\pgf@circ@res@up}}
     \pgftransformrotate{45}
     \pgfnode{currarrow}{center}{}{}{\pgfusepath{stroke}}
  \endpgfscope

  \pgfpathmoveto{\pgfpoint{-\pgf@circ@res@other}{\pgf@circ@res@zero}}
  \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@zero}}
  \pgfusepath{draw}

  \pgfusepath{stroke}   
}
\makeatother




\begin{document}
\begin{circuitikz}[thick]
\draw
(0,4) to[battery] (0,0)
(0,4) to[short, o-o] (2,4) 
(2,0) to[short,o-o] (0,0)
(3,4) to[R, o-o] (3,0)
(3,4) -- (4,4)  to[ohmmeter](4,0);
\end{circuitikz}
\end{document}

The result is

enter image description here

Related Question