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.

Using this code in circuitkz I get this circuit

enter image description here

 \begin{circuitikz}[american]
    \ctikzset {voltage/distance from node=1};
    \draw 
     (0,0) to[battery,l=V] (0,2)
     to[R,l^=$R_1$,v=$V_1$] (4,2)
     to[R,l=$R_2$,v=$V_2$] (4,0)
     (4,0) -- (0,0)
    ;
    \end {circuitikz}

How can I move V1 and V2 labels to the left and down, both the label themselves and the poles? It's so nasty to get the poles overlapping the resistors!!

share|improve this question

3 Answers 3

Adjust the value of \ctikzset {voltage/distance from node=0.5}, say 0.5 or 0.8.

enter image description here

Code

\documentclass{article}
\usepackage[american,siunitx]{circuitikz}
\begin{document}
    \ctikzset {voltage/distance from node=0.5}
 \begin{circuitikz}%[american]
    \draw 
     (0,0) to[battery,l=V] (0,2)
     to[R,l^=$R_1$,v=$V_1$] (4,2)
     to[R,l=$R_2$,v=$V_2$] (4,0)
     (4,0) -- (0,0)
    ;
    \end{circuitikz}
\end{document}
share|improve this answer
    
This seems to fix just the poles overlapping. I'd need to displace V labels as well. Thnx. –  agrgal May 14 at 6:24
    
A tricky solution was to define "opens" in the circuit: \begin{circuitikz}[american] \ctikzset {voltage/distance from node=0.8}; \draw (0,0) to[battery,l=V] (0,4) to[R,l^=$R_1$] (6,4) to[R,l=$R_2$] (6,0) (2,3.5) to[open,v=$V_1$] (4,3.5) (5.5,3) to[open,v=$V_2$] (5.5,1) (6,0) -- (0,0) ; \end {circuitikz} –  agrgal May 14 at 6:25
    
Ya, use the open circuit skill with different coordinates, but still need distance from node=0.8, right? Did you try distance from node=1 with the tricky solution? –  Jesse May 14 at 6:55
    
Sorry, you had two follow-ups. As to the first question, here is my solution -- Use of raisebox and hspace skills. For example to[R,l^=$R_1$,v=\raisebox{-20pt}{$V_1$}] (4,2) to[R,l=$R_2$,v=\hspace{-20pt} $V_2$] (4,0). You may need to change the -20pt to suit your needs. Or further reading tex.stackexchange.com/a/161476/34618 –  Jesse May 14 at 7:04
    
both distance from nodeand \raisebox \hspace worked well! Now it looks much better!! Anyway, I noticed poles don't move down \ left as the voltage labels do. They don't seem to be affected by \hspace or \raisebox. Can they move along the voltage labels? –  agrgal May 14 at 14:00

A PSTricks solution:

\documentclass{article}

\usepackage{pst-circ}

\begin{document}

\psset{dipolestyle = zigzag}
\begin{pspicture}(-0.8,0)(10.75,6.75)
  \pnodes{P}(0,0)(0,6)(4,5.7)(6,5.7)(10,6)(9.7,4)(9.7,2)(10,0)
  \battery[labeloffset = -22pt](P1)(P0){$V$}
  \resistor[labeloffset = 16pt](P1)(P4){\large $R_{1}$}
  \resistor[labeloffset = -17pt](P1)(P4){\large $V_{1}$}
  \rput(P2){$+$}
  \rput(P3){$-$}
  \resistor[labeloffset = 16pt](P4)(P7){\large $R_{2}$}
  \resistor[labeloffset = -17pt](P4)(P7){\large $V_{2}$}
  \rput(P5){$+$}
  \rput(P6){$-$}
  \wire(P7)(P0)
\end{pspicture}

\end{document}

output

share|improve this answer
1  
1. No need to reinvent the wheel. Tension label and polarity sign are already provided by the package. 2. The polarity of the battery must be reversed. –  Who is crazy first May 13 at 20:53

Reducing the number of keystrokes used in the existing PSTricks answer.

\documentclass[pstricks,border=12pt,12pt]{standalone}
\usepackage{pst-circ}

\psset
{
    dipolestyle=zigzag,
    labeloffset=.8,
    tensionstyle=pm,
    tensionoffset=-.8,
    tensionlabeloffset=-.8,
}

\begin{document}

\begin{pspicture}(8,6)
    \pnodes{P}(1,0)(1,5)(7,5)(7,0)
    \vdc[labeloffset=-.8](P1)(P0){$V$}
    \resistor[tensionlabel=$V_1$](P1)(P2){$R_1$}
    \resistor[tensionlabel=$V_2$](P2)(P3){$R_2$}
    \wire(P3)(P0)
\end{pspicture}

\end{document}

enter image description here

Notes

If you want to use PSTricks rather than TikZ, make sure you compile it with either

  • xelatex or

  • latex followed by dvips followed by ps2pdf.

At the end, you will get a diagram (in PDF) which you can import from within your main TeX file via \includegraphics and the main TeX file can be compiled with pdflatex.

share|improve this answer
    
Thanks for the answer. Excuse me, I'm newbiw in Latex. So, Must I change package circuitikz by pst-circ? Couldn't I do using circuitikz? –  agrgal May 14 at 6:28

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.