Asked
Active
Viewed 163 times
1 Answers
2
I take this as a TikZ exercise during my free time.
\documentclass[tikz,margin=3mm]{standalone}
\usepackage{siunitx}
\usetikzlibrary{decorations.markings,calc}
\tikzset{
resistor/.style={
postaction=decorate,
decoration={
markings,
mark=at position 0.5 with {
\begin{scope}[scale=2]
\fill[white] (-7pt,1pt) rectangle (7pt,-1pt);
\draw (-7pt,0) -- (-6pt,0) -- (-5pt,2pt) -- (-3pt,-2pt) -- (-1pt,2pt) -- (1pt,-2pt) -- (3pt,2pt) -- (5pt,-2pt) -- (6pt,0) -- (7pt,0);
\coordinate (x) at (-6pt,0);
\coordinate (y) at (0,0);
\end{scope}
}
}
},
->-/.style={
postaction=decorate,
decoration={
markings,
mark=at position #1 with {\arrow{>}}
}
},
->-/.default=0.5
}
\begin{document}
\begin{tikzpicture}[>=latex]
\draw[resistor] (0,0) -- (3,0);
\draw[->-=0.7] (0,0) -- (x);
\path (y) node[above=3pt] {$I_2$} node[below=3pt] {$R_2=\SI{2}{\ohm}$};
\draw[->-] (3,0) -- (6,0);
\draw (6,-2) -- (6,2);
\draw[->-] (6,2) -- (3.1,2);
\draw (3,2.25) -- (3,1.75) (3.1,2.08) -- (3.1,1.92) (3.05,2) node[above=0.25cm] {\SI{7}{\volt}};
\draw[resistor] (3,2) -- (0,2);
\path (y) node[above=3pt] {$I_1$} node[below=3pt] {$R_1=\SI{3}{\ohm}$};
\draw[->-] (0,2) -- (0,0);
\draw[->-] (0,-2) -- (0,0);
\draw[resistor] (0,-2) -- (3,-2);
\path (y) node[above=3pt] {$I_3$} node[below=3pt] {$R_3=\SI{4}{\ohm}$};
\draw (3,-2.25) -- (3,-1.75) (3.1,-2.08) -- (3.1,-1.92) (3.05,-2) node[below=0.25cm] {\SI{8}{\volt}};
\draw[->-] (6,-2) -- (3.1,-2);
\node[circle,draw,fill=cyan!30] at (0,0) {1};
\node[circle,draw,fill=cyan!30] at (6,0) {2};
\draw[->,cyan] ($(5,1)+(45:0.8)$) arc (45:315:0.8) node[midway,left,black] {Path 1};
\draw[->,cyan] ($(5,-1)+(-45:0.8)$) arc (-45:-315:0.8) node[midway,left,black] {Path 2};
\end{tikzpicture}
\end{document}
I know this code is still too long and can be improved. Any suggestions welcome!
-
-
@BlackMild Yes, there are many other ways to draw this. First, of course, is using
circuitikz. And my answer: take some post-actions on paths. Or your comment: usepic(which I'm not really familiar of). Or I can even draw the resistors manually. Or I think it is even possible to usenodefor the resistors (untested). TikZ is awesome because there are thousands of solutions to only one problem :D – Apr 13 '19 at 18:21


just-do-it-for-mesite. IMO: you can begin with https://tex.stackexchange.com/questions/15779/materials-for-learning-tikz, and http://www.pirbot.com/mirrors/ctan/graphics/pgf/contrib/circuitikz/doc/circuitikzmanual.pdf. – Raaja_is_at_topanswers.xyz Apr 11 '19 at 15:51\begin{document} \begin{circuitikz} \draw (0,0) node[op amp] (opamp) {} (opamp.-) node[left] {$2$} to [short,*-] ++(0,4) to [short,*-] ++(0,2) to R={$R1$} {} (opamp.out) node[right, anchor=north] {$6$} to (1.5,0) to R={$R1$} {} (opamp.up) --++(0,1.5) node[anchor=east, *-o]{\textnormal{-Vcc}} (-0.2,1.3) node[anchor=east]{\textnormal{4}};
\draw (8,0) node [op amp] {};
\end{circuitikz} \end{document}
– Adeleye Adekunle Apr 11 '19 at 16:07circuitikz, you can start from there... https://circuitikz.github.io/circuitikz/ – Rmano Apr 11 '19 at 17:38just-do-it-for-mequestion. – Raaja_is_at_topanswers.xyz Apr 12 '19 at 11:27