What's the best way to draw $\to^*$ arrows in TikZ drawings? The best I've managed to come up with so far is
\draw[->] (A) to node[very near end] {$*$} (B);
What's the best way to draw $\to^*$ arrows in TikZ drawings? The best I've managed to come up with so far is
\draw[->] (A) to node[very near end] {$*$} (B);
Here some ideas.
The first, a to path with an extra node consisting of $ {} ^ * $.
The second introduces two to arrows, namely to* and *to. As the arrow will get transformed I have added the *to arrow for the start line where the asterisk should appear on the left side of the line.
The code has—commented out—a solution with an original $\scriptstyle *$ inside a \pgftext command which does not work when the arrow is used more than once in the document.
\documentclass{article}
\usepackage{tikz}
\usepgflibrary{plotmarks}
\tikzset{
to*/.style={
shorten >=.25em,#1-to,
to path={-- node[inner sep=0pt,at end,sloped] {${}^*$} (\tikztotarget) \tikztonodes}
},
to*/.default=
}
\makeatletter
\pgfarrowsdeclare{to*}{to*}
{
\pgfutil@tempdima=-0.84pt%
\advance\pgfutil@tempdima by-1.3\pgflinewidth%
\pgfutil@tempdimb=0.21pt%
\advance\pgfutil@tempdimb by.625\pgflinewidth%
\advance\pgfutil@tempdimb by2.5pt%
\pgfarrowsleftextend{+\pgfutil@tempdima}
\pgfarrowsrightextend{+\pgfutil@tempdimb}
}
{
\pgfutil@tempdima=0.28pt%
\advance\pgfutil@tempdima by.3\pgflinewidth%
\pgfsetlinewidth{0.8\pgflinewidth}
\pgfsetdash{}{+0pt}
\pgfsetroundcap
\pgfsetroundjoin
\pgfpathmoveto{\pgfqpoint{-3\pgfutil@tempdima}{4\pgfutil@tempdima}}
\pgfpathcurveto
{\pgfqpoint{-2.75\pgfutil@tempdima}{2.5\pgfutil@tempdima}}
{\pgfqpoint{0pt}{0.25\pgfutil@tempdima}}
{\pgfqpoint{0.75\pgfutil@tempdima}{0pt}}
\pgfpathcurveto
{\pgfqpoint{0pt}{-0.25\pgfutil@tempdima}}
{\pgfqpoint{-2.75\pgfutil@tempdima}{-2.5\pgfutil@tempdima}}
{\pgfqpoint{-3\pgfutil@tempdima}{-4\pgfutil@tempdima}}
\pgfusepathqstroke
\begingroup
\pgftransformxshift{2.5pt}
\pgftransformyshift{2pt}
\pgftransformscale{.7}
\pgfuseplotmark{asterisk}
\endgroup
% \pgftext[left,y=2pt]{$\scriptstyle *$}
}
\pgfarrowsdeclare{*to}{*to}
{
\pgfutil@tempdima=-0.84pt%
\advance\pgfutil@tempdima by-1.3\pgflinewidth%
\pgfutil@tempdimb=0.21pt%
\advance\pgfutil@tempdimb by.625\pgflinewidth%
\advance\pgfutil@tempdimb by2.5pt%
\pgfarrowsleftextend{+\pgfutil@tempdima}
\pgfarrowsrightextend{+\pgfutil@tempdimb}
}
{
\pgfutil@tempdima=0.28pt%
\advance\pgfutil@tempdima by.3\pgflinewidth%
\pgfsetlinewidth{0.8\pgflinewidth}
\pgfsetdash{}{+0pt}
\pgfsetroundcap
\pgfsetroundjoin
\pgfpathmoveto{\pgfqpoint{-3\pgfutil@tempdima}{4\pgfutil@tempdima}}
\pgfpathcurveto
{\pgfqpoint{-2.75\pgfutil@tempdima}{2.5\pgfutil@tempdima}}
{\pgfqpoint{0pt}{0.25\pgfutil@tempdima}}
{\pgfqpoint{0.75\pgfutil@tempdima}{0pt}}
\pgfpathcurveto
{\pgfqpoint{0pt}{-0.25\pgfutil@tempdima}}
{\pgfqpoint{-2.75\pgfutil@tempdima}{-2.5\pgfutil@tempdima}}
{\pgfqpoint{-3\pgfutil@tempdima}{-4\pgfutil@tempdima}}
\pgfusepathqstroke
\begingroup
\pgftransformxshift{2.5pt}
\pgftransformyshift{-2pt}
\pgftransformscale{.7}
\pgfuseplotmark{asterisk}
\endgroup
% \pgftext[left,y=-2pt]{$\scriptstyle *$}
}
\makeatother
\newcommand*{\testtostar}[1]{%
\tikz[baseline=(A.base)]{
\node (A) {$A$}; \node at (1,0) (B) {$B$};
\draw[arrows=#1] (A) -- (B);}%
}
\begin{document}
$ A \to^* B$
\tikz[baseline=(A.base)]{
\node (A) {$A$}; \node at (1,0) (B) {$B$};
\path (A) edge[to*] (B);}
\testtostar{-to*}
\testtostar{to*-}
\testtostar{to*-to*}
\testtostar{-*to}
\testtostar{*to-}
\testtostar{*to-*to}
\testtostar{*to-to*}
\testtostar{to*-*to}
\end{document}

* and combine that with > so that >* can be used similar to >| and the > option. See also TikZ arrow tip is displaced.
– Qrrbrbirlbel
Oct 06 '13 at 14:12
\tikz{\draw[->,semithick] (0,0) -- (.35,0) node[above right, xshift=-.8ex,yshift=-.5ex] {\scriptsize $*$};}– jub0bs Mar 24 '13 at 20:33to*as an arrow. Could you post either a MWE or a picture of how the star should be aligned in relation to the arrow? – Qrrbrbirlbel Mar 24 '13 at 20:51