1

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}
4

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

  • Note that modifying files inside the distribution TDS is very likely to lead to disasters with any distribution (TeXlive/MikTeX/MacTeX) update. You should make a local copy of the tile and modify this copy. – yo' Oct 25 '15 at 23:52
  • This method is very bad, I'm afraid: an update to TikZ/PGF by the distribution will remove all modifications. – egreg Oct 25 '15 at 23:55
  • @egreg, true. Actually I've tried to do in the preamble but to be honest I don't know how to do it. Feel free to modify the answer. – CroCo Oct 25 '15 at 23:58
  • @CroCo I don't understand: the last code produces the image without any of the suggested modifications to the system files. – egreg Oct 26 '15 at 0:04
  • @egreg, I do believe the circuitikz package you have has ohmmeter but the new update doesn't have this component. – CroCo Oct 26 '15 at 0:07
3

Just for fun:

new ohm meter

\documentclass{standalone}
\usepackage{circuitikz}

\makeatletter
% ************************* analog meter **************************

\ctikzset{bipoles/meter/height/.initial=.80}
\ctikzset{bipoles/meter/width/.initial=.80}
\ctikzset{bipoles/meter/logo/.initial=$\Omega$}

\pgfcircdeclarebipole{}
  {\ctikzvalof{bipoles/meter/height}}
    {meter}
    {\ctikzvalof{bipoles/meter/height}}
    {\ctikzvalof{bipoles/meter/width}}
{
    \pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
    \pgfextractx{\pgf@circ@res@right}{\northeast}
    \pgfextractx{\pgf@circ@res@left}{\southwest}
    \pgfextracty{\pgf@circ@res@up}{\northeast}
  \pgfextracty{\pgf@circ@res@down}{\southwest}
%
    \pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}
    \pgfusepath{draw}
  \pgfpathcircle{\pgfpointorigin}{2\pgfstartlinewidth}
  \pgfusepath{fill}
  \pgfscope
    \pgfsetlinewidth{\pgfstartlinewidth}
        \pgftransformrotate{-\pgf@circ@direction}
    \pgfmoveto{\pgfpoint{0.7\pgf@circ@res@left}{0}}
    \pgflineto{\pgfpoint{0.9\pgf@circ@res@left}{0}}
    \pgfmoveto{\pgfpoint{0.566\pgf@circ@res@left}{0.411\pgf@circ@res@up}}
    \pgflineto{\pgfpoint{0.728\pgf@circ@res@left}{0.529\pgf@circ@res@up}}
    \pgfmoveto{\pgfpoint{0.216\pgf@circ@res@left}{0.666\pgf@circ@res@up}}
    \pgflineto{\pgfpoint{0.278\pgf@circ@res@left}{0.856\pgf@circ@res@up}}
    \pgfmoveto{\pgfpoint{0.216\pgf@circ@res@right}{0.666\pgf@circ@res@up}}
    \pgflineto{\pgfpoint{0.278\pgf@circ@res@right}{0.856\pgf@circ@res@up}}
    \pgfmoveto{\pgfpoint{0.566\pgf@circ@res@right}{0.411\pgf@circ@res@up}}
    \pgflineto{\pgfpoint{0.728\pgf@circ@res@right}{0.529\pgf@circ@res@up}}
    \pgfmoveto{\pgfpoint{0.7\pgf@circ@res@right}{0}}
    \pgflineto{\pgfpoint{0.9\pgf@circ@res@right}{0}}
    \pgfusepath{draw}
    \endpgfscope
    \pgfscope
        \pgftransformrotate{-\pgf@circ@direction}
    \pgfsetarrowsend{latex}
    \pgfmoveto{\pgfpointorigin}
    %\pgfmoveto{\pgfpoint{.1414\pgf@circ@res@left}{.1414\pgf@circ@res@up}}
    \pgflineto{\pgfpoint{.6363\pgf@circ@res@left}{.6363\pgf@circ@res@up}}
        \pgfusepath{draw}
    \endpgfscope
  \pgfscope
    \pgftransformrotate{-\pgf@circ@direction}
    \pgftransformyshift{0.5\pgf@circ@res@down}
    \pgftext{\ctikzvalof{bipoles/meter/logo}}
  \endpgfscope
}

% create meter to-path style

\def\meterpath#1{\pgf@circ@bipole@path{meter}{#1}}
\compattikzset{meter/.style = {\circuitikzbasekey, /tikz/to path=\meterpath, \circuitikzbasekey/bipole/is voltage=true, v=#1}}
\makeatother

\begin{document}
\begin{circuitikz}
\draw (0,0) to[meter,o-*] (2,0);
\draw (3,-1) to[meter,o-*] (3,1);
\end{circuitikz}
\end{document}

BTW, you can change the logo using \ctikzset{bipoles/meter/logo=Amp} for example.

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.