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!
Best Answer
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:
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.