Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to draw a Wheatstone Bridge and this is the code I have so far:

\documentclass[12pt]{article}
\usepackage[americanvoltages,fulldiodes,siunitx]{circuitikz}
\usepackage[pdftex]{graphicx}
\usepackage[width=16.00cm, height=22.00cm]{geometry}
\usepackage{letltxmacro}
\begin{document}

 \begin{circuitikz}[scale=2.5]\draw
  (0,0) to[battery1, l=$V$] (0,2) -- (2,2)
  to[R=$R_1$,*-*] (1,1)
  to[R=$R_3$, *-*] (2,0) -- (0,0);

 \draw (2,2) to[R=$R_2$, *-*] (3,1)
        to[R=$R_4$, *-*] (2,0);
 \draw (1,1) to[R=$R_5$, *-*] (3,1);

 \draw[>=latex,->,color=magenta,text=black, thick] (0.6,1.9) 
      to[out=-0,in=-0] (1.4,1.9) to[out=8,in=70] (0.8,1)node[anchor=east]{$I_a$}
      to[out=-70,in=-0] (1.4,0.1) to[out=-0,in=-0] (0.5,0.1);

  \draw[>=latex,->,color=magenta,text=black, thick](1.7,1.3)arc(220:-50:0.4 and 0.15);

  \draw[>=latex,<-,color=magenta,text=black, thick](1.7,0.8)arc(-220:50:0.4 and 0.15);

 \filldraw[fill=black] (2,1.5) circle(0pt)node[anchor=south]{$I_b$};
 \filldraw[fill=black] (2,0.78) circle(0pt)node[anchor=north]{$I_c$};
 \end{circuitikz}

And this is what it produces:

enter image description here

Note how huge the labels for the diagonal resistors are!

Question 1: How can I make the font size of these labels back to normal (i.e. the same size as $R_5$ and $V$)? I don't want to use font size editors like \tiny or \small; I already did that and even \tiny still makes the font size slightly larger than normal. There should be a more natural way for the font size not to increase and just stay the way it's supposed to, no?

Question 2: The long curved arrow for $I_a$ has a sharp corner near the middle that I want to smooth out (to make it a smooth curve), and the top and bottom corners of the arrow don't seem to be very naturally transitioning (i.e. you can see that there is a bit of a jaggedness, the curved line doesn't naturally flow into the flat line). Is there an easy way to fix these top/middle/bottom corners instead of having to individually tweak all the in/out angles, and if so, how?

Thank you!

share|improve this question
    
Clearly the tikzpicture scale gets applied to the labels of the resistors. –  Henri Menke Mar 18 at 20:08
    
Interesting, it doesn't normally though. Any idea why this only applies to the diagonal resistors? –  Alborz Mar 18 at 20:10

2 Answers 2

up vote 11 down vote accepted

Question 1

Instead of scaling the circuit, you can use x=<length>, y=<length>, so labels, for example, won't be affected.

Question 2

You can simply use -- and rounded corners to easily produce the smooth cuved path. In the example below, instead of

     \draw[>=latex,->,color=magenta,text=black, thick] (0.6,1.9) 
          to[out=-0,in=-0] (1.4,1.9) to[out=8,in=70] (0.8,1)node[anchor=east]{$I_a$}
          to[out=-70,in=-0] (1.4,0.1) to[out=-0,in=-0] (0.5,0.1);

I used

    \draw[>=latex,->,color=magenta,text=black, thick,rounded corners=7pt]   
     (0.6,1.9) -- (1.6,1.9) -- 
     (0.7,1) node[anchor=east]{$I_a$} --
     (1.6,0.1) -- (0.5,0.1);

The code; I also used a scope at the end to simplify the code and placed I_b and I_c as nodes to the arc paths (this produces the right positioning without manual intervention and simplifies the code):

\documentclass[12pt]{article}
\usepackage[americanvoltages,fulldiodes,siunitx]{circuitikz}
\usepackage{graphicx}
\usepackage[width=16.00cm, height=22.00cm]{geometry}
\usepackage{letltxmacro}

\begin{document}

\begin{circuitikz}[x=2.5cm,y=2.5cm]
\draw
  (0,0) to[battery1, l=$V$] (0,2) -- (2,2)
  to[R=$R_1$,*-*] (1,1)
  to[R=$R_3$, *-*] (2,0) -- (0,0);

\draw 
  (2,2) to[R=$R_2$, *-*] (3,1)
  to[R=$R_4$, *-*] (2,0);

\draw 
  (1,1) to[R=$R_5$, *-*] (3,1);

\begin{scope}[>=latex,color=magenta,thick,text=black]
\draw[->,rounded corners=7pt]   
   (0.6,1.9) -- (1.6,1.9) -- 
   (0.7,1) node[anchor=east]{$I_a$} --
   (1.6,0.1) -- (0.5,0.1);

\draw[->]
  (1.7,1.3)  arc(220:-50:0.4 and 0.15) 
  node[pos=0.5,above] {$I_b$};

\draw[<-]
  (1.7,0.8) arc(-220:50:0.4 and 0.15) 
  node[midway,above] {$I_c$};
\end{scope}
\end{circuitikz}

\end{document}

enter image description here

share|improve this answer
    
Thank you once again Mr. Medina! I'm just wondering, where do you obtain this information (i.e. for question 2)? Before posting here I extensively searched Google and StackExchange for my answer to no avail, but your code is so much simpler and intuitive, is there some sort of beginner's resource I'm missing (aside from the TikZ & PGF Manual for Version 2.10-CVS, and the CircuiTikZ 0.3.0 Manual)? –  Alborz Mar 19 at 15:30
    
@Alborz Sorry for not answering before. You are welcome! I am afraid the resources are the manuals and, in some cases, the code of the packages and TikZ has grown enormously in the past years (by the way, PGF is now officially in version 3.0.0). –  Gonzalo Medina Mar 21 at 0:19

If you can live without appyling the coordinate transformation to the nodes I can offer a patch. The author probably forgot to get the current trafo independent from the rotation. It is kind of tedious to protect all possible shapes inside the scopes etc. so I just turned off the trafo.

\documentclass[12pt]{article}
\usepackage[americanvoltages,fulldiodes,siunitx]{circuitikz}

\usepackage[width=16.00cm, height=22.00cm]{geometry}
\usepackage{letltxmacro}
\makeatletter
\def\pgf@circ@drawrotlabel{
    \pgfextra{
        % calcolo rotazione label
        \def\pgf@circ@temp{\ctikzvalof{bipole/label/position}} %%% àncora label
        \edef\pgfcirclabrot{\pgf@circ@direction} % primo e quarto quadrante
        \edef\pgfcircmathresult{\expandafter\pgf@circ@stripdecimals\pgf@circ@direction\pgf@nil}
        \ifnum \pgfcircmathresult > 90 \ifnum \pgfcircmathresult < 270 % terzo e secondo
            \pgfmathsubtract{\pgf@circ@direction}{180}
            \edef\pgfcirclabrot{\expandafter\pgf@circ@stripdecimals\pgfmathresult\pgf@nil}
            \pgfmathadd{\pgf@circ@temp}{180} %%%
            \edef\pgf@circ@temp{\expandafter\pgf@circ@stripdecimals\pgfmathresult\pgf@nil} %%%
        \fi\fi

        \ifnum \ctikzvalof{mirror value} = -1
            \pgfmathadd{\pgf@circ@temp}{180}
            \edef\pgf@circ@temp{\expandafter\pgf@circ@stripdecimals\pgfmathresult\pgf@nil}
        \fi
    }
    coordinate (labelcoor) at ($(\ctikzvalof{bipole/name})!2!(\ctikzvalof{bipole/name}.north)$)
    (labelcoor) node [transform shape=false, rotate=\pgfcirclabrot] {\pgf@circ@finallabel{}}
}

\begin{document}

\begin{circuitikz}[scale=2.5]
\draw (0,0) to[battery1, l=$V$] (0,2) -- (2,2) to[R,l=$R_1$] (1,1) to[R,l=$R_3$, *-*] (2,0) -- (0,0);
\draw (2,2) to[R=$R_2$, *-*] (3,1)to[R=$R_4$, *-*] (2,0);
\draw (1,1) to[R=$R_5$, *-*] (3,1);

\draw[>=latex,->,color=magenta,text=black, thick] (0.6,1.9) 
      to[out=-0,in=-0] (1.4,1.9) to[out=8,in=70] (0.8,1)node[anchor=east]{$I_a$}
      to[out=-70,in=-0] (1.4,0.1) to[out=-0,in=-0] (0.5,0.1);

\draw[>=latex,->,color=magenta,text=black, thick](1.7,1.3)arc(220:-50:0.4 and 0.15);
\draw[>=latex,<-,color=magenta,text=black, thick](1.7,0.8)arc(-220:50:0.4 and 0.15);
\filldraw[fill=black] (2,1.5) circle(0pt)node[anchor=south]{$I_b$};
\filldraw[fill=black] (2,0.78) circle(0pt)node[anchor=north]{$I_c$};
\end{circuitikz}
\end{document}

enter image description here

share|improve this answer
    
Thank you for your answer, it works great, only problem is I'd rather not have this entered in the preamble of every document I make, do you know which .sty file for CircuiTikZ I can put this extra code in for it to be universal? –  Alborz Mar 19 at 15:34
    
You should make your own .sty file or .cls file rather than edit the CircuiTikZ files. Your changes to CircuiTikZ files will be overwritten if you upgrade. –  Alex Hirzel Apr 21 at 15:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.