11

I cannot get a circuit that I'm trying to recreate to have both the label of the resistor (e.g. R1, R2, etc.) and its value (e.g. 1.0kΩ, 5.6kΩ, etc.) to be displayed on either side of the resistor, like so:

enter image description here

My current circuit and related package statement:

\usepackage[siunitx, american]{circuitikz}

\begin{center}
    \begin{circuitikz}\draw
        (0,0) to[V=12<\volt>] (0,4) -- (0,6)
              to[R=$R_1$, l=1.0<\kilo\ohm>] (8,6) -- (8,4)
              to[R=$R_L$, l=1.0<\kilo\ohm>, *-*] (8,0)
              to[R=$R_5$, l^=1.0<\kilo\ohm>] (4,0)
              to[R=$R_4$, l^=1.0<\kilo\ohm>] (0,0);
        \draw
        (0,4) to[R=$R_2$, l=1.0<\kilo\ohm>] (4,4)
              to[R=$R_3$, l=1.0<\kilo\ohm>] (8,4);
        \draw (4,4) to[R=$R_6$, l=5.6<\kilo\ohm>] (4,0);
        \draw (0,-1) -- node[ground]{} (0,0);
    \end{circuitikz}
\end{center}

enter image description here

As far as I can tell, I've constructed my resistors just like every other example I've found online so far, but it still isn't showing the second label.

Am I simply missing a package, or have I misunderstood something here?

On a side note, you might notice that the labels for the two resistors along the bottom edge aren't being forced above the resistor like my LaTeX is telling it to do.

2

3 Answers 3

5

With lot of manual tweak in defining labels positions ...

\documentclass[border=3mm,
               many,
               prewiev]{standalone}
\usepackage[siunitx]{circuitikz}

    \begin{document}
    \begin{circuitikz}\draw
        (0,0) to[V=12<\volt>] (0,4) -- (0,6)
              to[R=$R_1$]       node[pos=0.05,below left=1.5ex] {\SI{1.0}{\kilo\ohm}} (8,6) -- (8,4)
              to[R=$R_L$, *-*]  node[pos=-0.05,above left=1.5ex] {\SI{1.0}{\kilo\ohm}}    (8,0)
              to[R=$R_5$]       node[pos=0.1,above right=1.5ex] {\SI{1.0}{\kilo\ohm}} (4,0)
              to[R=$R_4$]       node[pos=0.1,above right=1.5ex] {\SI{1.0}{\kilo\ohm}} (0,0);
        \draw
        (0,4) to[R=$R_2$]       node[pos=0.1,below left=1.5ex] {\SI{1.0}{\kilo\ohm}} (4,4)
              to[R=$R_3$]       node[pos=0.1,below left=1.5ex] {\SI{1.0}{\kilo\ohm}} (8,4);
        \draw (4,4) to[R=$R_6$] node[pos=-0.05,above left=1.5ex] {\SI{1.0}{\kilo\ohm}}  (4,0);
        \draw (0,-1) -- node[ground]{} (0,0);
    \end{circuitikz}
    \end{document}

enter image description here

3

For occasional usage, it can be done without manual positioning tweaks by naming the bipole and later attaching another label node to the bipole's anchors:

\documentclass[border=2mm]{standalone}
\usepackage[siunitx,american]{circuitikz}

\begin{document}
\begin{circuitikz}
  % for one-off usage:
  \draw (0,0) to[R=1.0<\kilo\ohm>,n=R1] ++(2,0) (R1.s) node[below] {$R_1$};
\end{circuitikz}
\end{document}

enter image description here

However, this is not very convenient usage. Because of the way circuitikz is implemented, I have not succeeded in finding a way to add both labels at the time the bipole is drawn.

You could package this into a convenience macro if you plan to use it more often. With more information about your desired syntax, I may be able to help with this.

2
  • .s = south or one of the ends?
    – Jason S
    Dec 23, 2018 at 19:44
  • @JasonS in this case, it's south. These anchors are not well-documented, but I found the definitions in pgfcircbipoles.tex. Dec 24, 2018 at 1:45
2

I am not sure that you can have two labels (one able and the other below), but you can combine them into one label as I have done to the one in red:

enter image description here

To move the ones ion blue to be on top you need to use the underscore since you are drawing from right to left.

Notes:

Code:

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

\begin{document}

\begin{center}
    \begin{circuitikz}\draw
        (0,0) to[V=12<\volt>] (0,4) -- (0,6)
              to[R, l=\mbox{$R_1=\SI{1.0}{\kilo\ohm}$}, red] (8,6) -- (8,4)
              to[R=$R_L$, l=2.0<\kilo\ohm>, *-*] (8,0)
              to[R=$R_5$, l_=3.0<\kilo\ohm>, blue] (4,0)
              to[R=$R_4$, l_=4.0<\kilo\ohm>, blue] (0,0);
        \draw
        (0,4) to[R=$R_2$, l=5.0<\kilo\ohm>] (4,4)
              to[R=$R_3$, l=6.0<\kilo\ohm>] (8,4);
        \draw (4,4) to[R=$R_6$, l=5.6<\kilo\ohm>] (4,0);
        \draw (0,-1) -- node[ground]{} (0,0);
    \end{circuitikz}
\end{center}
\end{document}
2
  • This is a nice solution since creating two labels for one component is distracting. I don't know why the OP wants two labels.
    – CroCo
    Mar 1, 2016 at 19:34
  • 1
    Sometimes the OP just wants what the OP wants.
    – Jason S
    Dec 23, 2018 at 19:35

You must log in to answer this question.

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