4

I'm trying to position the labels for (european) resistors in circuitikz inside the resistors, What I want but it automatically positions them besides the boxes and I get this:

What I get:

\documentclass[12pt,a4paper]{article}
\usepackage{circuitikz}
\begin{document}

\begin{circuitikz}[scale = 0.5,european]
            % start points
            \coordinate[label=above:B] (B) at (0,0);
            \coordinate[label=above:A] (A) at (0,5);
            \foreach \i in {A,B} {
                \fill (\i) circle (2pt);
            }
            \draw (B) to (4,0) to (4,-1) to[R, label={$2R$}] (8,-1) to (8,0);
            \draw (4,0) to (4,1) to[R, label={$2R$}] (8,1) to (8,0) to (12,0) to[R, l_={$R$}] (12,5) to[] (11,5);
            \draw (A) to[] (1,5) to (1,3) to[R, label={$2R$}] (11,3) to[] (11,5);
            \draw (1,5) to[R, label={$R$}] (6,5) to[R, label={$R$}] (11,5);
        \end{circuitikz}

\end{document}
4

Well, this is not really supported. It would be wrong with most of the components, and the idea of circuitikz is that you can switch from european to american and still have a valid circuit...

But you can trick it into working:

\documentclass[12pt,a4paper]{article}
\usepackage[RPvoltages]{circuitikz}
\begin{document}

\begin{circuitikz}[scale = 0.5,european]
            % start points
            \coordinate[label=above:B] (B) at (0,0);
            \coordinate[label=above:A] (A) at (0,5);
            \foreach \i in {A,B} {
                \fill (\i) circle (2pt);
            }
            % name the node, and...
            \draw (B) to (4,0) to (4,-1) to[R, name=R1] (8,-1) to (8,0);
            % add the thing
            \node  at (R1.center) {$R$};
            \draw (4,0) to (4,1) to[R, label={$2R$}] (8,1) to (8,0) to (12,0) to[R, l_={$R$}] (12,5) to[] (11,5);
            \draw (A) to[] (1,5) to (1,3) to[R, label={$2R$}] (11,3) to[] (11,5);
            \draw (1,5) to[R, label={$R$}] (6,5) to[R, label={$R$}] (11,5);
        \end{circuitikz}
\end{document}

enter image description here

You can also automate them, using a consistent naming scheme:

\documentclass[12pt,a4paper]{article}
\usepackage[RPvoltages]{circuitikz}
\begin{document}
\begin{circuitikz}[scale = 0.5,european]
            % start points
            \coordinate[label=above:B] (B) at (0,0);
            \coordinate[label=above:A] (A) at (0,5);
            \foreach \i in {A,B} {
                \fill (\i) circle (2pt);
            }
            % name the nodes Rx for R and 2Rx for 2R, and...
            \draw (B) to (4,0) to (4,-1) to[R, name=R1] (8,-1) to (8,0);
            \draw (4,0) to (4,1) to[R, name=2R1] (8,1) to (8,0) to (12,0) to[R, name=R2] (12,5) to[] (11,5);
            \draw (A) to[] (1,5) to (1,3) to[R, name=2R2] (11,3) to[] (11,5);
            \draw (1,5) to[R, name=R3] (6,5) to[R, name=R4] (11,5);
            % add labels
            \foreach \n in {1,...,4} \node at (R\n.center) {$R$};
            \foreach \n in {1,2} \node at (2R\n.center) {$2R$};
        \end{circuitikz}
\end{document}

enter image description here

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.