[Tex/LaTex] Supply rails in circuitikz

circuitikz

I am trying to draw the circuit below, however I am having difficulty in drawing the connections to the supply rails. I've abused the sground node since it is the same as the typical symbol for power supply connections.

As you can see, the
JFET Differential Amplifier

For the node labelled VSS, I can use the sground node without any problem, but for nodes labelled VDD, I have to invert it, which I am doing by setting the y-axis scale to -1. This has the side-effect of inverting the associated label:

(0, 10) node [sground, yscale = -1] () {$V_{DD}$}

How can I achieve this without inverting the text?


The full source is below.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% JFET differential Amplifier
%

\documentclass[10pt, a4paper] {article}
\usepackage[siunitx, americanvoltages] {circuitikz}

\begin{document}
\begin{tikzpicture}

\draw[color = black, thick]

(0, 10) node [sground, yscale = -1] () {$V_{DD}$}
(0, 8) to [R, l = $R_{D1}$] (0, 10) {}
(0, 8) to [short, *-o] (1, 8) {}
(0, 7) to [Tnjfet, l = $Q_1$] (0, 8) {}
(-0.9, 7.23) to [short, -o] (-1.5, 7.23) {}
(0, 7) to [short] (0, 6)

(4, 10) node [sground, yscale = -1] () {$V_{DD}$}
(4, 8) to [R, l = $R_{D2}$] (4, 10) {}
(4, 8) to [short, *-o] (3, 8) {}
(4, 7) to [Tnjfet, mirror, l = $Q_2$] (4, 8) {}
(4.9, 7.23) to [short, -o] (5.5, 7.23) {}
(4, 7) to [short] (4, 6)    

(0, 6) to [short] (4, 6)
(2, 6) node [circ] () {}
(2, 6) to [R, l = $R_{SS}$] (2, 4)
(2, 4) node [sground] () {$V_{SS}$}

;

\end{tikzpicture}
\end{document}

Best Answer

This happens because the ground nodes and their variants are not really designed to have node text anchored to them: in addition to the upside down text, in both the inverted and non-inverted sground nodes in your example, the spacing is less than optimal when compared with the spacing around other node texts. Notice that, in the package manual, every use of ground (or its variants) comes with an empty node text ({}).

What I always do is leave the node texts empty for ground nodes and simply add another node (to the right or left or any other direction as appropriate) right at the same spot, which will then be spaced out from the circuit a little better.

Also, I'd suggest that instead of typing sground,yscale=-1 for each of these, define in one spot something like:

\tikzset{srail/.style={sground,yscale=-1}}

This way, you can simply use srail for all of these components and it's easier to update if you change your mind about the style of this component later. (You could even change your mind and decide to declare an entirely new shape with this method.)

Here's how I would approach it:

\documentclass[tikz]{standalone}
\usepackage[siunitx, americanvoltages] {circuitikz}
\tikzset{srail/.style={sground,yscale=-1}}

\begin{document}
\begin{tikzpicture} \draw
  node [srail] {} 
  node[right] {$V_{DD}$}
  to[R=1.8<\kilo\ohm>] ++(0,-2)
  node [sground] {}
  node[right] {$V_{SS}$}
;\end{tikzpicture}
\end{document}

enter image description here

Related Question