3

I'd like to make an arrowhead that is a filled circle surrounded by an arc. I can make this by putting an Arc Barb and a Circle on each other, but the problem is their spacing breaks up depending on the arrowhead is at the start or at the end:

\documentclass[margin=3mm,tikz]{standalone}

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

\newcommand*{\ioport}{[sep=1mm]{Arc Barb}[reversed,scale=1.6,sep=-1mm]{Circle}}

\tikzset
  { >={direction ee}
  }

\pgfsetarrowoptions{direction ee}{5pt}
\begin{document}

\begin{tikzpicture}
  \draw[{\ioport<}-{<\ioport}] (0,0) -- (10,0);
  \draw[{\ioport>}-{>\ioport}] (10,-1) -- (0,-1);
\end{tikzpicture}

\end{document}

As the result shows, the arrowhead is exactly as I'd like at the end of lines, but it falls apart at the start of lines:

enter image description here

I'd like to change \ioport so that it can be used at both ends of edges.

One horrible workaround I've found is to create two distinct commands for the two line-ends:

\newcommand*{\ioportstart}{[sep=1mm]{Circle}[sep=0mm]{Arc Barb}[reversed,sep=-1mm,scale=1.6]} 
\newcommand*{\ioportend}{[sep=1mm]{Arc Barb}[reversed,sep=-1mm,scale=1.6]{Circle}[sep=0mm]}

but I really want to avoid having to use a different name at the two line-ends.

3 Answers 3

3

I am not sure which ones of the arrows you want, but for example, looking at page 210 of the manual, I came up with this:

\documentclass[margin=3mm,tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{circuits.ee.IEC}
\tikzset{myr/.tip = {<[sep=1mm]{Arc Barb}[scale=1.6,sep=0mm]{Circle}},
    my-my/.tip = {myr[reversed]},
    >={direction ee},
    }
\pgfsetarrowoptions{direction ee}{5pt}
\begin{document}
\begin{tikzpicture}
  \draw[my-] (0,-2) -- ++(10,0) node[midway, fill=white]{1};
  \draw[-my] (0,-3) -- ++(10,0) node[midway, fill=white]{2};
  \draw[my-my] (0,-4) -- ++(10,0) node[midway, fill=white]{3};
  \draw[my-] (10,-5) -- ++(-10,0) node[midway, fill=white]{4};
  \draw[-my] (10,-6) -- ++(-10,0) node[midway, fill=white]{5};
  \draw[my-my] (10,-7) -- ++(-10,0) node[midway, fill=white]{6};
\end{tikzpicture}
\end{document}

enter image description here

Basically, you define the right-to-left tip (I think, don't trust me on left-right statements!) and then the my-my trick does the extension to the three basic forms.

4
  • 1
    +1. I am not sure, that the "my-my trick" does anything (other than you use reversed, that can also be used directly in the tip definition). I do not think that the manual describe this in a good way. Jul 1, 2021 at 14:25
  • @hpekristiansen Yes, I agree (I +1ed yours too). I just tried ;-)
    – Rmano
    Jul 1, 2021 at 14:33
  • But I don't want to bake in the </> arrowhead into the my arrowhead, I want to be able to write my>->my or my<-<my etc, i.e. combine them freely.
    – Cactus
    Jul 3, 2021 at 6:29
  • Ah, sorry, I didn't understand it. No idea if it's possible; probably you need to define all possible combinations...
    – Rmano
    Jul 3, 2021 at 8:26
3

This is just an extension of @Rmano excellent answer. By trail, it seems that it is not needed to first define one tip, and then extend it to both directions. -it works with just one tip:

\documentclass[margin=3mm,tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{circuits.ee.IEC}
\tikzset{my/.tip = {>[sep=1mm]{Arc Barb}[scale=1.6, reversed, sep=-1mm]{Circle}}, >={direction ee}
    }
\begin{document}
\begin{tikzpicture}
 \draw[my-] (0,-2) -- ++(10,0) node[midway, fill=white]{1};
  \draw[-my] (0,-3) -- ++(10,0) node[midway, fill=white]{2};
  \draw[my-my] (0,-4) -- ++(10,0) node[midway, fill=white]{3};
  \draw[my-] (10,-5) -- ++(-10,0) node[midway, fill=white]{4};
  \draw[-my] (10,-6) -- ++(-10,0) node[midway, fill=white]{5};
  \draw[my-my] (10,-7) -- ++(-10,0) node[midway, fill=white]{6};
\end{tikzpicture}
\end{document}

Arrows

2

The nuclear option is to give up on composing arrows, and draw it myself:

\pgfarrowsdeclare{io}{io}
 {
  \pgfarrowsleftextend{-8\pgflinewidth}
  \pgfarrowsrightextend{8\pgflinewidth}}
 {
   \pgfpathcircle{\pgfpoint{8\pgflinewidth}{0}}{4\pgflinewidth}
   \pgfusepathqfill
   \pgfpathmoveto{\pgfpoint{8\pgflinewidth}{-8\pgflinewidth}}
   \pgfpatharc{270}{90}{8\pgflinewidth}
   \pgfusepathqstroke
 }

\newcommand*{\ioport}{[sep=1mm]{io}[sep=1mm]}

enter image description here

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.