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 just learning how to use CircuitTikZ to draw circuits, and I am trying to draw a good looking BJT biasing circuit. But I am having making the resistors across from each other look even, and since there are no examples of combining tripoles with bipoles in the documentation I'm a little confused about whether or not I am doing this the best way. Here is my code:

\documentclass{article}
\usepackage{circuitikz}
\usepackage{amsmath}
\usepackage{SIunits}
\usepackage{circ}

\begin{document} 

Single Transistor discrete BJT biasing circuit:
\begin{center}
\begin{circuitikz}[scale=1.4]
\draw (0,0) node[ground] {};
\draw (0,0) to[R=$R_2$] (0,2);
\draw (0,2) to[R=$R_1$, *-] (0,4) -- (2,4);
\draw (2,2) node[pnp] (pnp) {}
    (pnp.B) -- (0,2);
\draw (2,4) to[R=$R_C$] (pnp.E);
\draw (2,0) node[ground] {};
\draw (2,0) to[R=$R_E$] (pnp.C);
\end{circuitikz}
\end{center}

\end{document}

I would like to have the top and bottom resistors at the same height if possible. Any help would be greatly appreciated!

share|improve this question
    
Welcome to tex.sx! Note that you don't have to (and in fact shouldn't) sign with your name since it automatically appears in the lower right corner of your post. –  Hendrik Vogt Feb 13 '11 at 10:08
    
quite cool, do have an idea to get rid off the scale approach? Without this the wires are to close to the upper resistors. The scale approach looks like an hot fix for for me therefore. With scale the whole graphics/grid scales bigger an may bring other problems later –  oltx Dec 12 '11 at 13:51

2 Answers 2

The components in circuitikz are always placed midway between the coordinates of the paths they belong to, so you have to make sure the parallel paths start and end on the same heights in order to get identical vertical placement of the components.

The "dirty" way to do this is to just add additional points on the paths:

\documentclass{article}
\usepackage{circuitikz}
\usepackage{amsmath}
\usepackage{siunitx} % Preferred over SIunits
\begin{document} 

Single Transistor discrete BJT biasing circuit:
\begin{center}
\begin{circuitikz}[scale=1.4]
\draw (0,0) node[ground] {};
\draw (0,0) to[R=$R_2$] (0,1.4) -- (0,2);
\draw (0,2) -- (0,2.6) to[R=$R_1$] (0,4) -- (2,4);
\draw (2,2) node[pnp] (pnp) {}
    (pnp.B) [short,-*] to (0,2); % "short" is a plain wire
\draw (2,4) to[R,l_=$R_C$] (2,2.6) -- (pnp.E); % Switch label side
\draw (2,0) node[ground] {};
\draw (2,0) to[R=$R_E$] (2,1.4) -- (pnp.C);
\end{circuitikz}
\end{center}

\end{document}

enter image description here

A more "proper" way would be to use the \let \p<number> = (<coordinate>) in ..., which saves a coordinate in a local variable and lets you access the x and y components through \x<number> and \y<number>. You can then save the emitter and collector coordinates and use their y components in the end points for the wires with the resistors.

\documentclass{article}
\usepackage{circuitikz}
\usepackage{amsmath}
\usepackage{siunitx}
\begin{document} 

Single Transistor discrete BJT biasing circuit:
\begin{center}
\begin{circuitikz}[scale=1.4]
\draw (2,2) node[pnp] (pnp) {}
    (pnp.B) [short,-*] to (0,2);
\draw let \p1=(pnp.C),\p2=(pnp.E) in 
  (0,0) node [ground] {}
  to [R=$R_2$] (0,\y1) -- (0,2) -- (0,\y2) 
  to [R=$R_1$] (0,4) -- (2,4);
\draw (2,4) to [R,l_=$R_C$] (pnp.E);
\draw (2,0) node[ground] {};
\draw (2,0) to [R=$R_E$]  (pnp.C);
\end{circuitikz}
\end{center}

\end{document}
share|improve this answer

Emitter Resistor has wrong indicator in the schematic...

corrected version:

\begin{center}
\begin{circuitikz}[scale=1.4]
\draw (0,0) node[ground] {};
\draw (0,0) to[R=$R_2$] (0,1.4) -- (0,2);
\draw (0,2) -- (0,2.6) to[R=$R_1$] (0,4) -- (2,4);
\draw (2,2) node[pnp,] (pnp) {}     (pnp.B) [short,-*] to (0,2);% "short" is a plain wire
\draw (2,4) to[R,l_=$R_E$] (2,2.6) -- (pnp.E); % Switch label side
\draw (2,0) node[ground] {};
\draw (2,0) to[R=$R_C$] (2,1.4) -- (pnp.C);
\end{circuitikz}
\end{center}
share|improve this answer
2  
Welcome to TeX.SX! You should always provide a complete example. Like this, it is not compilable and the OP has to guess the packages and so on. You can take a glance on Jakes answer in order to see how such an "MWE" should look like. Thank you. PS: And of course a screen-shot of the result is always handy. –  LaRiFaRi Jul 30 at 13:26

Your Answer

 
discard

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