11

I am using the circuits.ee.IEC library. However, I cannot find any fuse symbol like this:

fuse symbol

How can I define such a symbol using circuit declare symbol? It should be just combining the resistor symbol and a line in some way, but I don't understand the syntax well enough to do this.

4
  • You can greatly simplify and use the answer in this question.
    – percusse
    Nov 26, 2011 at 22:04
  • @percusse Could you point out, how to do this, for resistor there is no IEC/before background path...
    – student
    Nov 26, 2011 at 22:18
  • @percusse: A tip: If you copy-and-paste the entire link of a question you want to link to, e.g. http://tex.stackexchange.com/questions/7438/ac-source-symbol-in-tikz-circuits-ee-iec-library, it'll automatically be shortened and people will see the question title as a hover-tooltip, which is more helpful than a "this question": tex.stackexchange.com/questions/7438/…
    – doncherry
    Nov 27, 2011 at 9:02
  • @doncherry I thought it is less disruptive but apparently the hovering is a nice functionality. Thanks!
    – percusse
    Nov 27, 2011 at 12:33

2 Answers 2

9

A different approach would be to append code after the resistor node, similar to the light emitting and direction info styles:

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{circuits.ee.IEC}

\begin{document}

\tikzset{
    fuse graphic/.style={
        append after command={% At the end of the \draw command, do the following
            \bgroup % Start a new group
                [current point is local=true, % Do not influence the current point on the path
                every fuse/.try, % If `every fuse` has been defined, use it
                #1] % Apply options supplied by user
                (\tikzlastnode.west) edge [line to] (\tikzlastnode.east) % An edge, i.e. an independent path, from the west to the east of the resistor node
            \egroup% End the group
        }
    },
    fuse/.style={resistor={fuse graphic=#1}} % The fuse is just a resistor node with the `fuse graphics` key
}


\begin{tikzpicture}[circuit ee IEC]
    \draw (0,0) to [fuse] (2,0)  to [fuse] (0,-2) to [fuse] (0,0);
  \end{tikzpicture}


\end{document}
2
  • Thanks very much! Perhaps it would be nice to add some comments to your code to make it easier to adapt it to other examples for people who doesn't have a very deep knowledge of pgf/tikz.
    – student
    Nov 27, 2011 at 9:24
  • @user4011: Done
    – Jake
    Nov 27, 2011 at 9:40
7

You can use annotations as described in the TikZ/PGF manual in Section 29.2.5 Declaring and Using Annotations to add the horizontal line over the symbol:

Annotations are quite similar to info labels. The main difference is that they generally cause something to be drawn by default rather than some text to be added (although an annotation might also add some text).

Here is an example of resistor and the fuse that you want:

enter image description here

Notes:

  • This is my first attempt with annotations, and I am not sure about the coordinates used in the edge operation below. As per the comment by @GonzaloMedina, I have tweaked the coordinates by (0,-0.5\pgflinewidth) to adjust for the width of the rule. However, this still seems a bit of hack and feel that there should be a better way.
  • The transform shape option is what makes the fuse points along the path.

Code:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{circuits.ee.IEC}

\tikzset{circuit declare annotation=
    {HorizontalAnnotation}
    {0pt}
    {edge[to path={[-]
            ($(-0.5,-0.5\tikzcircuitssizeunit)+(0,-0.5\pgflinewidth)$) 
        --  ($( 0.5,-0.5\tikzcircuitssizeunit)+(0,-0.5\pgflinewidth)$)}] ()}
}

\tikzset{circuit declare symbol=fuse, 
    set fuse graphic={
        draw,
        circuit symbol size=width 4 height 1, 
        HorizontalAnnotation
    }, 
    transform shape}

\begin{document}
  \begin{tikzpicture}[circuit ee IEC]
    \draw (0,1.0) to [resistor] (3,1.0) node [right] {resistor};
    \draw (0,0.5) to [fuse]     (3,0.5) node [right] {fuse};
    \draw (0,0.5) to [fuse] (0,-2) to [fuse] (3,0.5);
  \end{tikzpicture}
\end{document}
6
  • You forgot to take into account the width of the rule, so using something like ($(-0.5,-0.5\tikzcircuitssizeunit)+(0,-0.4pt)$) -- ($(0.5,-0.5\tikzcircuitssizeunit)+(0,-0.4pt)$)}] ()} would be better (of course, loading the calc library). Nov 27, 2011 at 1:51
  • Or using -\pgflinewidth instead of -0.4pt above. Nov 27, 2011 at 1:57
  • @GonzaloMedina: Thanks. Had to use exactly half the value you suggested to get this to work. Nov 27, 2011 at 2:05
  • @PeterGrill Thanks, however It doesn't work for me if I draw a vertical path, see my edit above.
    – student
    Nov 27, 2011 at 8:08
  • @user4011: See updated solution. Adding the transform shape allows the node to point along the path. Nov 27, 2011 at 17:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.