1

Since I am drawing a Wheatstone bridge, I would like to indicate that the current going through G is zero. Here is my code:

\documentclass[12pt]{article}
\usepackage{pgfplots}
\usepackage{float}
\pgfplotsset{compat=1.17}
\usepackage[RPvoltages, american,siunitx]{circuitikz}
\usetikzlibrary{shapes, arrows.meta, automata, positioning, matrix, calc}
\usepackage[margin=1in]{geometry} 
\begin{document}    
    \begin{figure}[H]
        \centering
        \begin{circuitikz}[declare function = {hypo = 4; x = 1; r ={1/2};}]
            \ctikzset{label/align = straight}
            \draw({hypo*sqrt(2) + 2},0) to [battery , l_= $V_\textrm{in}$] ++({-hypo*sqrt(2) - 2},0);
            \draw(0,0) to[short, i = $I$] ++(0, -5) to[short, -*] ++(1, 0) node[label={below:$C$}](C){} to [R, l^= $R_1$, -*] ++(45:hypo) node[label={above:$A$}](A){} to[R, l^=$R_2$, -*] ++(-45:hypo) node[label = {below:$D$}](D){} to [short] ++(1, 0) to [short, i = $I$] ++(0,5);
            \draw(C) to[R, l_= $R_k$, -*] ++(-45:hypo) node[label = {below:$B$}](B){} to [R, l_=$R_x$] ++(45:hypo);
            \draw(A) to [rmeter, t=G, i=$I_\textrm{G} = 0$] (B);
            \draw($(A) + (-x,0)$) -- ++(45:{x*sqrt(2) - r}) coordinate(arcBeforeA);
            \draw(arcBeforeA) arc(135:45:r) node[pos = 0.5, label = {above:$I_A$}]{} coordinate(arcAfterA);
            \draw(arcAfterA) -- ++(-45:{x*sqrt(2) - r}) node[currarrow, rotate=-45, anchor=tip]{};
            \draw($(B) + (-x,0)$) -- ++(-45:{x*sqrt(2) - r}) coordinate(arcBeforeB);
            \draw(arcBeforeB) arc(-135:-45:r) node[pos = 0.5, label = {below:$I_B$}]{} coordinate(arcAfterB);
            \draw(arcAfterB) -- ++(45:{x*sqrt(2) - r}) node[currarrow, rotate=45, anchor=tip]{};
        \end{circuitikz}
    \end{figure}
\end{document}

Output:

enter image description here

I am trying to draw I_\textrm{G} = 0, but I keep on getting an error because of the = 0 part.

The error is:

Extra }, or forgotten $. ...) to [rmeter, t=G, i=$I_\textrm{G} = 0$] (B)

How to fix it? Or is there a more conventional way of indicating that the current through G is zero?

1 Answer 1

2

I think you have found an issue. Your code yields an error. It does not like the =. Normally one might think that adding braces fixes this, but not even

\draw(A) to [rmeter, t=G,i={{{$I_\textrm{G} = 0$}}}] (B);

fixes the problem. As a workaround, you can define some macro that expands to an = sign.

\documentclass[12pt]{article}
\usepackage{float}
\usepackage{tikz}
\usepackage[RPvoltages, american,siunitx]{circuitikz}
\usepackage{caption}
\usetikzlibrary{calc}
\usepackage[margin=1in]{geometry} 
\begin{document}    
    \begin{figure}[H]
        \centering
        \begin{circuitikz}[declare function = {hypo = 4; x = 1; r ={1/2};}]
            \def\myeq{=}
            \ctikzset{label/align = straight}
            \draw({hypo*sqrt(2) + 2},0) to [battery , l_=$V_\textrm{in}$] ++({-hypo*sqrt(2) - 2},0);
            \draw(0,0) to[short, i = $I$] ++(0, -5) to[short, -*] ++(1, 0) node[label={below:$C$}](C){} to [R, l^= $R_1$, -*] ++(45:hypo) node[label={above:$A$}](A){} to[R, l^=$R_2$, -*] ++(-45:hypo) node[label = {below:$D$}](D){} to [short] ++(1, 0) to [short, i = $I$] ++(0,5);
            \draw(C) to[R, l_= $R_k$, -*] ++(-45:hypo) node[label = {below:$B$}](B){} to [R, l_=$R_x$] ++(45:hypo);
            \draw(A) to [rmeter, t=G,i=$I_\textrm{G} \myeq 0$] (B);
            \draw($(A) + (-x,0)$) -- ++(45:{x*sqrt(2) - r}) coordinate(arcBeforeA);
            \draw(arcBeforeA) arc(135:45:r) node[pos = 0.5, label = {above:$I_A$}]{} coordinate(arcAfterA);
            \draw(arcAfterA) -- ++(-45:{x*sqrt(2) - r}) node[currarrow, rotate=-45, anchor=tip]{};
            \draw($(B) + (-x,0)$) -- ++(-45:{x*sqrt(2) - r}) coordinate(arcBeforeB);
            \draw(arcBeforeB) arc(-135:-45:r) node[pos = 0.5, label = {below:$I_B$}]{} coordinate(arcAfterB);
            \draw(arcAfterB) -- ++(45:{x*sqrt(2) - r}) node[currarrow, rotate=45, anchor=tip]{};
        \end{circuitikz}
    \end{figure}
\end{document}

enter image description here

5
  • Nice workaround! Thank you!
    – Superman
    Jun 16, 2020 at 4:10
  • 2
    @Superman You can make the fonts smaller with \draw(A) to [rmeter, t=G,nodes={font=\tiny},i=$I_\textrm{G} \myeq 0$] (B);. I am sure there is a better solution but I fail to find it.
    – user194703
    Jun 16, 2020 at 4:25
  • I actually made a follow-up query. Thanks, though!
    – Superman
    Jun 16, 2020 at 4:28
  • 1
    Yes, it's an issue. But as a partial defense, it's explained in the manual. section 4.1 (labels and annotation), around page 110 (starting with "caveat:"). Sometimes it will be fixed, I hope (see github.com/circuitikz/circuitikz/issues/346), but for now, @Schrödinger'scat solution is the best one.
    – Rmano
    Jun 16, 2020 at 8:35
  • 1
    @Schrödinger'scat about the label style and size, you can change it setting the style bipole current style (see manual section 4.7, "changing the style of labels and text ornaments).
    – Rmano
    Jun 16, 2020 at 8:40

You must log in to answer this question.

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