6

I have two scenarios where I use arrows with a super-scripted asterisk: math mode and tikz-cd diagrams. I would like to be able to show such an arrow in both scenarios such that the arrows look the same, i.e., with respect to positioning of the asterisk.

Consider the below MWE. This is how I would like the arrow to look.

MWE

\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz-cd}

\newcommand*\dirinfsymname{Rightarrow}
\newcommand*\directdatacolourname{PineGreen}
\newcommand*\directdatacolour{\textcolor{\directdatacolourname}}
\newcommand*\dirinfsym{\mathbin{\directdatacolour{\Rightarrow}}}

\newcommand{\pathdirinfsym}[1][]{\mathrel{
  \vphantom{\dirinfsym{#1}}
  \smash{\dirinfsym{#1}}
  \vphantom{\to}^{\textcolor{PineGreen}{*}}}
}

\begin{document}

$a \pathdirinfsym b$

\end{document}

This outputs:

enter image description here

Now, consider this MWE.

MWE

\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz,tikz-cd}
\usetikzlibrary{shapes,fit}
\usetikzlibrary{positioning}
\usetikzlibrary{decorations.pathmorphing}

\newcommand*\dirinfsymname{Rightarrow}
\newcommand*\directdatacolourname{PineGreen}
\newcommand*\directdatacolour{\textcolor{\directdatacolourname}}
\newcommand*\dirinfsym{\mathbin{\directdatacolour{\Rightarrow}}}

\begin{document}

\begin{tikzcd}[
    column sep=small,
    cells={nodes={draw=black, ellipse, anchor=center, minimum height=2em}}
]
    a  \arrow[\dirinfsymname, \directdatacolourname, bend left]{rrrrr}{*} & a \arrow[\dirinfsymname, \directdatacolourname]{r}{*}  & a  & |[draw=none]|a\vphantom{1}  & a  & a
\end{tikzcd}

\end{document}

This outputs:

enter image description here

Notice how the two arrows have the asterisk positioned in the middle of the stem. I would like the asterisk positioned in the same position as in the first diagram.

Furthermore, I would like this to work for more than just \Rightarrow. I would like like to be able to do the same for \rightarrow.

12
+50

tizk-cd has the possibility to use glyphs for arrowheads and arrows.meta allows us to patch arrows together. Here is a more TikZy and shorter code which also has \to-type arrow.

\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz-cd}
\usetikzlibrary{shapes.geometric,arrows.meta}

\newcommand{\mysym}{\vphantom{\to}^{*}}

\begin{document}

\tikzset{
startip/.tip={Glyph[glyph math command=mysym]},
Rightarrow*/.style={PineGreen,double equal sign distance,>={Implies},->.startip},
to*/.style={PineGreen,->.startip}}
\begin{tikzcd}[
    column sep=small,
    cells={nodes={draw=black, ellipse, anchor=center, minimum height=2em}}
]
    a \arrow[r,Rightarrow*] 
    \arrow[Rightarrow*, bend left]{rrrrr}{m} & a \arrow[Rightarrow*,r] & a
    \arrow[to*,r] &
    |[draw=none,rectangle,inner sep=1pt]|a\vphantom{1} \arrow[Rightarrow*,r] & a \arrow[Rightarrow*,r] & a
\end{tikzcd}
\end{document}

enter image description here

Note that you do not have to stop here, using this you can patch together any symbols and use them as arrows. (Of course, at a given point you may want to use bending.)

This is the older version which uses your macros.

\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz-cd}
\usetikzlibrary{shapes.geometric,arrows.meta}

\newcommand*\dirinfsymname{Rightarrow}
\newcommand*\directdatacolourname{PineGreen}
\newcommand*\directdatacolour{\textcolor{\directdatacolourname}}
\newcommand*\dirinfsym{\mathbin{\directdatacolour{\Rightarrow}}}

\newcommand{\pathdirinfsym}[1][]{\mathrel{
  \vphantom{\dirinfsym{#1}}
  \smash{\dirinfsym{#1}}
  \vphantom{\to}^{\textcolor{PineGreen}{*}}}
}
\newcommand{\mysym}{\hspace{1em}\vphantom{\to}^{\textcolor{PineGreen}{*}}}
\usetikzlibrary{arrows}

\begin{document}

\tikzset{
fancy/.tip={Glyph[glyph math command=mysym]},
pft/.style={\directdatacolourname,double equal sign
distance,>={Implies},->.fancy}
}
\begin{tikzcd}[
    column sep=small,
    cells={nodes={draw=black, ellipse, anchor=center, minimum height=2em}}
]
    a \arrow[r,pft] 
    \arrow[pft, bend left]{rrrrr}{m} & a \arrow[pft,r] & a \arrow[pft,r] &
    |[draw=none,rectangle,inner sep=1pt]|a\vphantom{1} \arrow[pft,r] & a \arrow[pft,r] & a
\end{tikzcd}

\end{document}

enter image description here

  • Thank you! This is excellent. Out of curiosity, the arrow head has lines either side (a continuation of the arrow stem?) - is it possible to remove these? – David Poxon May 26 at 2:54
  • @DavidPoxon Good point! (The fix is also to add a point. ;-) – marmot May 26 at 3:20
  • Thank you so much! This is excellent. One question: how might I re-purpose this for a regular \rightarrow? I'm thinking I need to modify pft but I'm at a bit of a loss. – David Poxon May 26 at 3:36
  • 1
    @DavidPoxon It is just \tikzset{pfft/.style={\directdatacolourname,->.fancy}} and then a \arrow[pfft,r] in the diagram. You can patch all sorts of things together with this trick. – marmot May 26 at 3:38
  • 2
    @DavidPoxon I only combine what is written in section ** 16.5 Reference: Arrow Tips** of the pgfmanual v3.1.3 and in section 4.4 of the tikz-cd manual. And if you get stuck somewhere you can ask another question, or if you give me an idea what you want to generalize/change here I will be happy to give it a shot (but I may be hibernating ;-). – marmot May 26 at 4:07

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.