1

I'm trying to adap the answer here to add current flowing path to my circuit.
Unfortunately, the result is not same as in the reference above. I want to shift the current path up a bit.
How can I do that?

enter image description here

Does every node has all anchors such as north, south, east, west, north east, etc?
I saw this but couldn't make it works.

Also I would be much appreciated if you can help me change the arrow to something nicer. This \arrow{>=stealth} does not work as probably I don't understand how to use that.

\documentclass[border=1mm]{standalone} 
\usepackage[american,siunitx,RPvoltages]{circuitikz} 
\usetikzlibrary{decorations.markings} 
\usetikzlibrary{backgrounds}

\begin{document}

\begin{tikzpicture}

\ctikzset{ inductors/scale=0.5, capacitors/scale=0.5, sources/scale=0.5, switches/scale=0.5 }

\draw  (0,0) coordinate (start)  node[ocirc]{} to [cute open switch]
++(1,0)  to [cute inductor, l^=$L$] ++(1,0) to [short]++(0.5,0) node[ocirc]{} coordinate (end);


 % adding current \begin{scope}[on background layer, very thick, decoration = {
        markings,
        mark = at position 0.2 with {\arrow{>}}} ]  \draw[line width = 2pt, red!40, postaction = {decorate}] (start.north)--(end.north);   \end{scope}

\end{tikzpicture}


\end{document}

1 Answer 1

2

All nodes has anchors such as north, south, east, west, north east, etc. A coordinate as you use here has no size, so all the anchors are at the same location. It is better to use arrows from arrows.meta than the old ones (Notice Stealth not stealth).

\documentclass[tikz, border=1cm]{standalone} 
\usepackage[american, siunitx, RPvoltages]{circuitikz} 
\usetikzlibrary{decorations.markings, arrows.meta} 
\usetikzlibrary{backgrounds}

\begin{document}

\begin{tikzpicture}
\ctikzset{inductors/scale=0.5, capacitors/scale=0.5, sources/scale=0.5, switches/scale=0.5}
\draw  (0,0) coordinate (start)  node[ocirc]{} to [cute open switch]
++(1,0)  to [cute inductor, l^=$L$] ++(1,0) to [short]++(0.5,0) node[ocirc]{} coordinate (end);
\begin{scope}[on background layer, decoration={
markings, mark=at position 0.2 with {\arrow{Stealth[scale=0.8]}}} ]  
\draw[ultra thick, red!40, postaction={decorate}] ([yshift=1pt]start) -- ([yshift=1pt]end);   
\end{scope}
\end{tikzpicture}
\end{document}

A small circuit wit red arrow in background

Or as in comments:

\draw[ultra thick, red!40, postaction={decorate}, transform canvas={yshift=1pt}] (start) -- (end);
8
  • Very nice, thank you! If the path is not straight lines, do I have to specify the shift for every points? I'm thinking if I'll have to add xshift or yshift for every points. I still don't get how does that work for the reference one but not here. I think the reference one also nodes with no size?
    – internet
    Commented Dec 14, 2022 at 13:28
  • 1
    You could use \draw[ultra thick, red!40, postaction={decorate}, transform canvas={yshift=1pt}] (start) -- (end); to move the whole path. This comes with its own limitations and dangers. Commented Dec 14, 2022 at 13:33
  • Yeah, that is shorter but I can only do that with straight line. Probably I could define node instead of coordinate so I can make it simple as in the link.
    – internet
    Commented Dec 14, 2022 at 13:40
  • No you can do that with any path: \draw[transform canvas={yshift=1pt}] (0,0) -- (1,0) -- (1,1); Commented Dec 14, 2022 at 13:45
  • 1
    It does work, but your ground coordinate is not where you want it, you could name the node instead like this: ... node[ground] (ground) {};. If you need further help, then please edit your question or ask a new question. Commented Dec 14, 2022 at 14:04

You must log in to answer this question.

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