3

I wish to add a current label on a dashed line, using a current arrow. But when I do this, the borders of my arrows are also dahsed and it really looks bad.

Here is my code :

\begin{circuitikz}
    \draw (0,0) to[V={\small $V_{CC}$}] (0,2) to (5,2) to[R, l={\rotatebox[origin=c]{-90}{{\small $Charge$}}}] (5,0) to (0,0); 
    \draw[color=red, thick] (3,2) to[short, *-] (2.75,0.75) to (3.25, 1.25) to[short, -*] (3,0);
    \draw[color=red, thick, dashed] (0.1,1.9) to[short, i={\small $i_{d\acute efaut}$}] (2.65,1.9) to (2.65,0.1) to (0.1,0.1) to (0.1,1.9);
\end{circuitikz}

And what it looks like : Image of a short-circuit error on a DC circuit with a visual issue on the short-circuit current arrow

And I'd like it to look like this : Image of a short-circuit error on a DC circuit with no more issue

I don't really know what to try to make it look as I'd like. I already tried to add solid, dash=solid or dash pattern=on to the short object but it didn't work.

2
  • 1
    Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. Jan 6 at 11:44
  • 2
    Thank you for this tip, I'll think of it if I have others questions Jan 6 at 13:56

1 Answer 1

5

Yep, you got bitten by the fact that the dash is inherited down by the drawing routine that draws the currarrow node. Changing the dash mode to the short element does not work (the dashing is global to the path, you can look at the discussion in the FAQ in the manual).

You have two solutions:

  1. (if you want this just for one current arrow): use advanced currents and voltages (section 5.6 for now) for this one;

  2. (if you like to make all the current arrows undashed), you can use the component hook for currarrow (look in the manual at section 9.3.1), which I suppose is what you want:

\documentclass[margin=3mm]{standalone}
\usepackage[american,siunitx,RPvoltages]{circuitikz}
\makeatletter
    \newcommand{\ctikz@hook@start@draw@component@currarrow}{\pgfsetdash{}{0pt}}
\makeatother

\begin{document}

\begin{circuitikz}
    \draw (0,0) to[V={\small $V_{CC}$}] (0,2) -- (5,2)
    to[R, l={\small\textit{Charge}}, label/align=rotate] (5,0)
        -- (0,0);
    \draw[color=red, thick] (3,2) to[short, *-] (2.75,0.75)
        -- (3.25, 1.25) to[short, -*] (3,0);
    \draw[color=red, thick, dashed] (0.1,1.9) 
        to[short, i={\small $i_{\textit{défaut}}$}] (2.65,1.9)
        -- (2.65,0.1) -- (0.1,0.1) -- (0.1,1.9);
\end{circuitikz}

\end{document}

enter image description here

I also took the liberty to change the plain to to just lines, and to re-write the labels in what I think is more correct (don't use math mode for just italic text: look carefully at the spacing around f in défaut!).

By the way, if you find yourself to add \small for all the labels, voltage, etc., you can define your own style (see section 5.6):

\documentclass[margin=3mm]{standalone}
\usepackage[american,siunitx,RPvoltages]{circuitikz}
\makeatletter
    \newcommand{\ctikz@hook@start@draw@component@currarrow}{\pgfsetdash{}{0pt}}
\makeatother

\ctikzset{bipole label style/.style={font=\small}}
\ctikzset{bipole annotation style/.style={font=\small}}
\ctikzset{bipole voltage style/.style={font=\small}}
\ctikzset{bipole current style/.style={font=\small}}

\begin{document}

\begin{circuitikz}
    \draw (0,0) to[V=$V_{CC}$] (0,2) -- (5,2)
    to[R, l={\textit{Charge}}, label/align=rotate] (5,0)
        -- (0,0);
    \draw[color=red, thick] (3,2) to[short, *-] (2.75,0.75)
        -- (3.25, 1.25) to[short, -*] (3,0);
    \draw[color=red, thick, dashed] (0.1,1.9)
    to[short, i=$i_{\textit{défaut}}$] (2.65,1.9)
        -- (2.65,0.1) -- (0.1,0.1) -- (0.1,1.9);
\end{circuitikz}

\end{document}
4
  • 2
    +1 for setting défaut in text mode - the spaces around the f nearly made me cry :) Jan 6 at 12:05
  • @samcarter_is_at_topanswers.xyz Yes, I noticed that too! Once you see it, you can't unsee it... On the topic of this question, though, I am wondering if the hook should be the default behavior...
    – Rmano
    Jan 6 at 12:10
  • That's one of the biggest risks of using latex - one now sees such things :) Jan 6 at 12:16
  • 1
    Thank you for this answer, it really helped me. Jan 6 at 13:24

You must log in to answer this question.

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