2

I'm using LaTeX with the circuitikz package to draw circuit diagrams, specifically using the American-style components. I would like to customize the length of the arrow of a current source, but I'm unsure how to achieve this.

I'm aware that the issue arises from using a higher thickness for the bipole and scaling it, but I really need to maintain this thickness because the image will be used in a context where it's necessary for visibility.

This is the code that I have so far:

\documentclass{standalone}
\usepackage[american]{circuitikz}
\usepackage{bm}

\begin{document}
\begin{circuitikz}[scale=3, transform shape]

\ctikzset{bipoles/thickness=1.3}

\draw[line width=3mm]
(0,0) to[I,l=\LARGE $\bm{U_{0}}$] (0,2);

\end{circuitikz}
\end{document}

The resulting image looks like this:

enter image description here

As you can see, the arrow touches the borders of the circle, which is not the desired result that I look for.

Any suggestions on how to customize the length of the arrow while maintaining the thickness of the bipole would be greatly appreciated. Thank you!

2
  • 1
    I think that basically you need to modify the shape; your case is quite extreme... The other possibility is to use an empty source and add a custom arrow afterward.
    – Rmano
    Commented Jun 6 at 17:43
  • Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers.
    – Rmano
    Commented Jul 3 at 8:46

1 Answer 1

2

Your conditions are a bit extreme. The easiest way is probably to modify the shape. I take the occasion to explain how to do it (relatively) easily.

If you look at the manual, you will find that the shape-name of the component is isourceAMshape. That means it is defined as a bipole named isourceAM.

Go to the source file pgfcircbipoles.tex (somewhere in your path; you can find it by using the command kpsewhich pgfcircbipoles.tex); find the definition, and copy it in your file in the preamble, after loading circuitikz, enclosed in a pair of \makeatletter...\makeatother.

Now you can start playing with the low-level pgf code that draws the component. I marked the changes here with a %%% comment.

\documentclass[border=2.78mm]{standalone}
\usepackage[american]{circuitikz}
\usepackage{bm}
\makeatletter
%% Independent current source - American
\pgfcircdeclarebipolescaled{sources}
{}
{\ctikzvalof{bipoles/isourceam/height}}
{isourceAM}
{\ctikzvalof{bipoles/isourceam/height}}
{\ctikzvalof{bipoles/isourceam/width}}
{
    \pgfpointorigin
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}
    \pgf@circ@draworfill

    \pgfpathmoveto{\pgfpoint{.7\pgf@circ@res@left}{\pgf@circ@res@zero}}
    %%% changing .7 to .3
    \pgfpathlineto{\pgfpoint{.3\pgf@circ@res@right}{\pgf@circ@res@zero}}
    \pgfusepath{draw}
    \pgfscope
        %%% changing .5 to .2 
        \pgftransformshift{\pgfpoint{.2\pgf@circ@res@right}{\pgf@circ@res@zero}}
        \pgfnode{currarrow}{center}{}{}{\pgfusepath{stroke}}
    \endpgfscope
}
\makeatother
\begin{document}
\begin{circuitikz}[scale=3, transform shape]

\ctikzset{bipoles/thickness=1.3}

\draw[line width=3mm]
(0,0) to[I,l=\LARGE $\bm{U_{0}}$] (0,2);

\end{circuitikz}
\end{document}

enter image description here

Finally, I think that using

(0,0) to[I,l=\LARGE $\bm{U_{0}}$, label distance=1cm] (0,2);

will lead to a better look.

enter image description here

2

You must log in to answer this question.

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