2

I am working on a circuits homework, and I'm trying to draw a graph.

In a graph, I'm trying to draw a curvy line with an arrow in the middle with the label. Here's what I have:

\begin{center}
    \begin{circuitikz}
        \draw (0,3) to[short,i>=$b$, o-o] (3,3) to[short,i>=$d$, o-o] (6,3);
        \draw (0,3) to[short,i>=$a$, o-o] (3,0);
        \draw (3,3) to[short,i>=$c$, o-o] (3,0);
        \draw (6,3) to[short,i>=$e$, o-o] (3,0);
        \draw (6,3) to[short, i>= $f$, o-o] [out=-90, in=0] (3, 0); \\Error
    \end{circuitikz}
\end{center}

Output: enter image description here

I realized that the curvy edge of the graph is going through the nodes instead of stopping at them. Can one help point out the error and show the correct way of drawing a curvy branch in circuitikz or show code in tikzpicture that provides the exact same result?

Superman
  • 1,615
  • 1
    The to-path commands of circuitikz only support straight lines, sorry. The solution is using decorations, like in https://tex.stackexchange.com/questions/39278/tikz-arrowheads-in-the-center – Rmano Nov 24 '23 at 22:30
  • Hi Rmano, I will try it out later when I get the chance. Thank you! – Superman Nov 25 '23 at 00:47

1 Answers1

1

The to-path handler of circuitikz does not handle curved wires. Although I understand sometimes they can be helpful, they raise the complexity too much (at least in the case of a path with a component in the middle). For wires, TikZ has the needed tools. This is an example:

\documentclass[border=10pt]{standalone}
\usepackage[T1]{fontenc}
\usepackage[siunitx, RPvoltages]{circuitikz}
% get the circuitikz arrow size, define a tip https://tex.stackexchange.com/a/549354/38080
\makeatletter
    \newdimen\ctikzAL\newdimen\ctikzAW
    \pgfmathsetlength{\ctikzAL}{ 1.7 * \pgf@circ@Rlen / \ctikzvalof{current arrow scale} + 2*\pgflinewidth}
    \pgfmathsetlength{\ctikzAW}{ 1.6 * \pgf@circ@Rlen / \ctikzvalof{current arrow scale} + 2*\pgflinewidth}
    \tikzset{c>/.tip={Triangle[length=\the\ctikzAL, width=\the\ctikzAW]}}
\makeatother
% See https://tex.stackexchange.com/a/39282/38080
\usetikzlibrary{decorations.markings}
\tikzset{->-/.style={decoration={
  markings,
  mark=at position 0.5 with {\arrow{c>}}},postaction={decorate}}}
\begin{document}
\begin{tikzpicture}[]
    \draw (0,3) to[short,i>=$b$, o-o] (3,3) to[short,i>=$d$, o-o] (6,3);
    \draw (0,3) to[short,i>=$a$, o-o] (3,0);
    \draw (3,3) to[short,i>=$c$, o-o] (3,0);
    \draw (6,3) to[short,i>=$e$, o-o] (3,0);
    % see https://tikz.dev/tutorial-nodes#sec-3.11
    \draw[->-] (6,3) to[out=-90, in=0] node[auto]{$f$} (3, 0); 
\end{tikzpicture}
\end{document}

enter image description here

References: Circuitikz Arrowhead, Tikz: Arrowheads in the center, https://tikz.dev/tutorial-nodes#sec-3.11

As you can see, the final wires start from the center of the "poles", as explained in the circuitikz manual in section 6.1. In this case, you can solve it by simply drawing the bent thing before the rest and relying on pole filling.

\begin{tikzpicture}[]
    % see https://tikz.dev/tutorial-nodes#sec-3.11
    \draw[->-] (6,3) to[out=-90, in=0] node[auto]{$f$} (3, 0); 
    \draw (0,3) to[short,i>=$b$, o-o] (3,3) to[short,i>=$d$, o-o] (6,3);
    \draw (0,3) to[short,i>=$a$, o-o] (3,0);
    \draw (3,3) to[short,i>=$c$, o-o] (3,0);
    \draw (6,3) to[short,i>=$e$, o-o] (3,0);
\end{tikzpicture}

enter image description here

Rmano
  • 40,848
  • 3
  • 64
  • 125