[Tex/LaTex] How to rotate the ammeter in circuitikz so that the ‘A’ in symbol uses horizontal baseline

circuitikz

I have just started to use Latex. I am using circuitikz package. Whenever I draw a voltmeter or ammeter on a vertical section, the 'A' or 'V' is rotated. How do I make it to use the horizontal baseline? Also, How do I remove the arrow in ammeter or voltmeter?

\documentclass{article}
\usepackage[american,siunitx,smartlabels]{circuitikz}

\begin{document}
\begin{figure}
\begin{circuitikz}
\draw (0,0)
to [sV=5V] (0,2)
to [R,l=$R_s$] (0,4)
to [C,l=$C$] (4,4)
to [short] (6,4);
\draw (6,0)
to [D] (6,4);
\draw (6,4)
to [short] (8,4)
to [R,l=$R_m$] (8,2)
to [ammeter] (8,0)
to [short] (0,0);

\end{circuitikz}
\end{figure}
\end{document}

enter image description here

Best Answer

This is a possible solution. Comments in the code help to understand the methodology:

\documentclass[border=10pt]{standalone}
\usepackage[american,siunitx,smartlabels]{circuitikz}

\ctikzset{bipoles/ammeter/text rotate/.initial=0,% <=new key
rotation/.style={bipoles/ammeter/text rotate=#1},% style for ease introduction in code
}

% code from pgfcircbipoles.sty
\makeatletter
\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/ammeter/height}}{ammeter}{\ctikzvalof{bipoles/ammeter/height}}{\ctikzvalof{bipoles/ammeter/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}{.9\pgf@circ@res@up}
            \pgfusepath{draw}       
        \endpgfscope    

    \pgftransformrotate{\ctikzvalof{bipoles/ammeter/text rotate}}% <= magic line
    \pgfsetlinewidth{\pgfstartlinewidth}

    \pgfsetarrowsend{latex}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@other}{\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{-\pgf@circ@res@other}{\pgf@circ@res@up}}
    \pgfusepath{draw}
    \pgfsetarrowsend{}


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


    \pgfnode{circle}{center}{\textbf{A}}{}{}
}
\makeatother

\begin{document}
\begin{circuitikz}
\draw (0,0)
to [sV=5V] (0,2)
to [R,l=$R_s$] (0,4)
to [C,l=$C$] (4,4)
to [short] (6,4);
\draw (6,0)
to [D] (6,4);
\draw (6,4)
to [short] (8,4)
to [R,l=$R_m$] (8,2)
to [ammeter,rotation=90] (8,0)% introducin rotation
to [short] (0,0);

\end{circuitikz}
\end{document}

The result:

enter image description here

Related Question