How can two tikz arrow tips be superimposed

tikz-arrowstikz-pgf

I'm like two superimposed two arrow heads in tikz, e.g. given the arrow tips Latex and Circle, have a way of getting a new arrow tip SuperposeLatexCircle such that \draw [-{SuperposeLatexCircle}] (A) -- (B) is equivalent to \draw [-{Latex}] (A) -- (B); \draw [-{Circle}] (A) -- (B).

I think this should be doable using sep, e.g. \draw [-{Latex[sep=-1pt]Circle}] (A) -- (B) with 1pt replaced by a better value. The relevant values should be:

I tried taking sep=-3.88pt -4.8 0.9 (the first two components are -0.88pt-3pt and -.3-4.5 respectively, and I did not know what to put for the third one so I put the average of 1 and .8. This does not work but is fairly close when replacing Circle by Diamond.

The problem with Circle is probably that its length is very different from the lengths of Latex, so we probably also need the default length of Circle:


Candidate methods before I had before thinking about sep:

Any of the following would help (in decreasing order of preference):

  • A way of combining arrows without needing to predeclare them, e.g. \draw [-{Superpose[first=Latex, second=Circle]}] (A) -- (B);

Edit: I'm stating to think that it is possible to do this with a negative sep, e.g. -{Latex[sep=-1pt]Circle}, but I'm not sure how to compute the correct sep automatically.

  • A way of declaring combinations without copying and pasting, e.g. using pgfarrowsdeclarecombine plus some shifting to cancel the movement between the two arrows, or something like
\pgfdeclarearrow{
  name=CombineLatexCircle,
  % ...
  drawing code={
    \pgf@ar@code@Latex
    \pgf@ar@code@Circle
  },
  % ...
}

(This seems hard to do for some components of the definition)

  • Some systematic way of copying and pasting that allows to combine two \pgfdeclarearrow declarations, e.g. "Concatenate the drawing codes, discard the defaults, change all names in setup and drawing code to avoid clashes, …"

Best Answer

Here's one way to do this. Define a style that places the circle tip at the end of the segment and call it with the Latex arrow.

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{decorations.markings}

\tikzset{
    circarr/.style={
        decoration={
            markings,
            mark=at position 1 with {\arrow{Circle}}
        },
        postaction={decorate}
    }
}

\begin{document}

\begin{tikzpicture}
\draw [-{Latex}] (0,0) -- (1,0); \draw [-{Circle}] (0,0) -- (1,0);
\draw [-{Latex}, circarr] (0,.5) -- (1,.5);
\end{tikzpicture}

\end{document}

enter image description here

Alternatively, you could have circarr draw both arrowheads:

\tikzset{
    circarr/.style={
        decoration={
            markings,
            mark={at position 1 with {\arrow{Circle}}, at position 1 with {\arrow{Latex}}}
        },
        postaction={decorate}
    }
}

Which creates the same output as above using \draw [circarr] (0,.5) -- (1,.5);. You could make another style for the arrows at the beginning of the segment using position 0 and \arrowreversed instead of \arrow.

Here is a MWE with circarrb (beginning) and circarre (end) both implemented:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{decorations.markings}

\tikzset{
    circarre/.style={
        decoration={
            markings,
            mark={at position 1 with {\arrow{Circle}}, at position 1 with {\arrow{Latex}}}
        },
        postaction={decorate}
    },
    circarrb/.style={
        decoration={
            markings,
            mark={at position 0 with {\arrowreversed{Circle}}, at position 0 with {\arrowreversed{Latex}}}
        },
        postaction={decorate}
    }
}

\begin{document}

\begin{tikzpicture}
\draw [circarre] (0,0) -- (1,0);
\draw [circarrb] (0,.5) -- (1,.5);
\draw [circarrb,circarre] (0,1) -- (1,1);
\end{tikzpicture}

\end{document}

enter image description here