6

I'm making the next circuit:

enter image description here
based on the next one
enter image description here
but the resistor has a straight line across. I understand that I am giving the command but I don't understand where.

And by the way, can someone please explain how to work with the nodes, the lines, the cursors, etc? It takes me a lot of work to have done codes like this and perhaps I don't fully grasp if this is working because it's correct or by luck.

\documentclass[tikz,border=3.14]{standalone}
\usepackage{pgf,tikz,pgfplots}
\usepackage[american]{circuitikz}
\usepgfplotslibrary{fillbetween}

\begin{document}
\begin{tikzpicture}

\begin{circuitikz} \draw
 (0,0) node[anchor=east]{$v^{-}_{N}$}
  to[short, o-*] (1,0)
  to[R, l=$R_I$, *-*] (1,2)
  %to [R, v=$v_x$, l=$10\ohm$] (3,2)
 % to[short] (4,2) to[cV, i=$\frac{\siemens}{5}v_x$, *-*] (4,0)
 %  to[short] (3,0) to[R, l=$5\ohm$, *-*] (3,2)

% (3,0) -- (1,0)
 (1,2) to[short, o-*] (0,2)
  node[anchor=east]{$v^{+}_{P}$}
 (3,1) node[anchor=east,xshift=3cm]{$v_O$}  to[R,l=$R_O$, ] (3.5,1) 
  to[short,] (2,1) to[cV, i=$\frac{}{}v_x$, o-] (2,-1) -- (2,-1) node [] {}
 
%  to[short, -] (2,-1)
% (2,0) node [-] {}
  to node[ground]{}(2,-0.5)







;
%    \draw  (2,1) -- node[sloped,currarrow,pos=1] {}  (3,1) ;
\end{circuitikz}



\end{tikzpicture}
\end{document}
4
  • 2
    Hi, I really advise reading the tutorials in the circuitikz manual (in the tutorial introduction, you'll find a pointer to the tutorials/sections you need to read of the TikZ manual). In your code, there are lots of things that are not correct or equivalent to doing nothing (like (2,-1) -- (2,-1) node [] {}).
    – Rmano
    Sep 12, 2021 at 9:06
  • 2
    Never nest tikzpicture environments like you do (circuitikz environment is the same as tikzpicture, and in a standalone you have to use the latter). You will get ll the bounding boxes (picture margins) completely off.
    – Rmano
    Sep 12, 2021 at 9:08
  • 2
    Finally, the wire overwriting your resistor is because this: (3,1) to[R,l=$R_O$, ] (3.5,1) to[short,] (2,1) : you ask to put a resistor in a 0.5cm spot (it will not fit, you need at least 1.5cm with default sizes) and then you draw a line through right to left.
    – Rmano
    Sep 12, 2021 at 9:09
  • 2
    @Rmano, great advise, thanks; indeed , I have checked the manual and see somethings were unadecuated.
    – riccs_0x
    Sep 12, 2021 at 15:19

1 Answer 1

8

For the first image:

enter image description here

\documentclass[border=3.14]{standalone}
\usepackage[american]{circuitikz}

\begin{document}
    \begin{circuitikz} 
\draw   (0,0)   node[left]  {$v^{-}_{N}$}
                to [short,  o-*] ++ ( 1,0) coordinate (aux)
                to [R=$R_I$, -*] ++ ( 0,2)
                to [short,   -*] ++ (-1,0)
                node[left]  {$v^{+}_{P}$}
        (aux)   ++ (3,1)  node[right] {$v_o$}
                to [R,a=$R_0$,o-]++ (-2,0)
                to [cV, l=$v_x$] ++ (0,-2) ++ (0,0.4)
                node[ground]{};
\end{circuitikz}
\end{document}

Note: I didn't investigate, why you have line over resistor. Apparently you draw it. Your code is unnecessary complicated (to me), so it was simpler that I redraw circuit from scratch.

It is not clear, if you like to get a solution for the second image too. From above solution to it is quite simple way: by use of fit library you can draw triangle in the background of above image.

Edit: Code for image should be self-explanatory :-).

Circuit is drawn in two loops. Coordinate for dipoles are determined relatively to beginning of loops ((0,0) for input and (aux) for output) using syntax determined in tikz (on which circuitikz is based) ++. For example \draw (0,0) to [short, o-*] ++ (1,0) means draw line form (0,0) to the right for 1cm with circle on beginning of line and black circle on the end, and (aux) ++ (3,1) is determined a coordinate, which is apart from aux for 3cm to left and 1cm above.

For more details see `TikZ & PGF manual (v3.1.9a), section 13.4 Relative and Incremental Coordinates, page 146.

Edit (1): Improved MWE: added output voltage $v_o$. Edit (2): Considered @Rmano comment.

5
  • 2
    Thanks I would like to be explained about the draw command, how to use it with the node, the lines, the -- or ++ operators, I dont understand quite well.
    – riccs_0x
    Sep 12, 2021 at 4:40
  • 4
    @riccs_0x, see edited answer. To make you more familiar with drawing circuits, I recommend to read documentations for packages circuitikz (relative short) and for TikZ (which is huge, so for start should sufficient to read the first tutorial and content of part III,
    – Zarko
    Sep 12, 2021 at 4:59
  • 2
    Thanks again, Im starting to study how to draw and make nodes from scratch too.
    – riccs_0x
    Sep 12, 2021 at 6:41
  • 3
    I think in the last line of code ++(0,0.5) can be safely deleted
    – js bibra
    Sep 12, 2021 at 8:35
  • 3
    @jsbibra, you are right. It is there that ground is closer to voltage source.
    – Zarko
    Sep 12, 2021 at 9:35

You must log in to answer this question.

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