2

I am trying to use CircuiTikz to draw resistor network circuits. For example, I am using the following latex code.

\documentclass{article}
\usepackage[american voltages, american currents,siunitx]{circuitikz}
\begin{document}



\begin{circuitikz}
% Node syntax: (X,Y)

%%% From top :
%% 1st row  ==>
% the voltage source and the resistor   
   \draw  (0,3)  to [R=\SI{}{R_H}, o-o, color=red] (3,3);

% resistors connected; lattce point: x=1, y=Ly 

   \draw [R, o-] (3,3) to (6,3);
   \draw [R, o-] (3,3) to (3,0);
   \draw [R, o-o] (3,0) to (3,-3);

% dashed implying many connections
   \draw [dashed] (6,3) to (9,3);

% resistor continuing after dashed line
   \draw [R, -o] (9,3) to (12,3);

% next resistor 
   \draw [R] (12,3) to (15,3); 
    \draw (15,3) to (15,2.5) node [ground]{};



\end{circuitikz}


\end{document}

This gives the following output. enter image description here

Now

1) Can I add a text "V" to the top left corner (left of the resistor labelled by R_H) without inserting a new node? In fact, can I add a text at any coordinate without using a node or path?

2) Using coloring and labelling each resistor, can I redifine a circuit element (e.g. the newly defined resistor will always have label R_H and color red)?

3) Is there any alternative way to the labelling R=\SI{}{R_H}? I suspect \SI is redundant.

4) Can I directly construct resistors in a series instead of mentioning coordinates for them each time?

I apologize for the numbers of questions. But I guess, they all are connected and relevant.

Thanks in advance.

1
  • 1
    Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. Mar 13, 2014 at 15:10

1 Answer 1

3

It's always better to ask separate questions even if the issues are small/minor, because it leads to more canonical answers that are of use to a wide audience. The question titles then also more accurately reflect the contents of the question and eventual answers.

Question 1:

I suspect you're referring to not creating another circuit node, not another TikZ node, but you can place the text as a TikZ node (using the above key to place it above the circuit node) along the resistor path, like so: \draw (0,3) node[above] {V} to[newR] (3,3);. This snippet contains other elements from the answers to your other questions, so read on below. :-)

Question 2:

You can do this with TikZ styles, which are very powerful. You define a style at the beginning of the circuitikz environment like so: \begin{circuitikz}[newR/.style={R=$R_H$, o-o, color=red}]. Now the style newR is defined with red color, open nodes at both ends, and a resistor labelled $R_H$, so any path with this style specified will have these attributes applied. We use the style like this: \draw (0,3) to[newR] (3,3);, which says that the path from (0,3) to (3,3) shall have style newR (I've left out the previously-specified node here for illustrative purposes).

Question 3:

Your suspicion is correct. \SI{<number>}{<unit>} is a command for typesetting physical quantities with units. For a resistance R_H as a mathematical variable, it might be better to use $R_H$ to typeset the value in math mode, which is what I've done in my solution here. If the resistor value is to be specified on the diagram, then \SI is appropriate, and you could use \SI{330}{\ohm} to typeset the value.

Question 4:

There are a number of ways to do this. I have shown two example methods in my solution.

The first method involves using relative coordinates and collapsing multiple \draw commands into a single connected chain: \draw (3,3) to[R, o-] ++(0,-3) to[R, o-o] ++(0,-3);. Notice that I moved the style specification onto the to command so each segment of the path can have a different style (resistor, capacitor, etc.) and the ++ syntax is used for relative coordinates.

The second method uses relative coordinates again, but now also named coordinates: \draw [R, -o] (9,3) to (12,3) coordinate (node1); labels the coordinate at the end of the path as node1 (you can name coordinates anything you please). Then we can use that location in later \draw commands, like so: \draw (node1) to[R, o-] ++(3,0) coordinate (node2);, and so on.

Complete Code:

\documentclass{standalone}
\usepackage[american voltages, american currents,siunitx]{circuitikz}
\begin{document}
\begin{circuitikz}[newR/.style={R=$R_H$, o-o, color=red}]
% Node syntax: (X,Y)

%%% From top :
%% 1st row  ==>
% the voltage source and the resistor   
   \draw  (0,3) node[above] {V} to[newR] (3,3);

% resistors connected; lattce point: x=1, y=Ly 

   \draw [R, o-] (3,3) to (6,3);
   \draw  (3,3) to[R, o-] ++(0,-3) to[R, o-o] ++(0,-3); % method 1 for series resistors

% dashed implying many connections
   \draw [dashed] (6,3) to (9,3);

% resistor continuing after dashed line
   \draw [R, -o] (9,3) to (12,3) coordinate (node1); % method 2 for series connections

% next resistor 
   \draw (node1) to[R, o-] ++(3,0) coordinate (node2); 
   \draw (node2) to ++(0,-0.5) node [ground]{};
\end{circuitikz}
\end{document}

Output

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .