Arrow with superscript in tikz-cd

I need my tikz-cd diagrams to have arrows (vertical and horizontal) that mimic \mapsto^* to match the relation in the text. The closest I've managed is to add a label {*} at [pos=1]:

\documentclass{article}
\usepackage{tikz,tikz-cd,stmaryrd}

\begin{document}
$\begin{tikzcd} M \dar \rar[maps to] & N \dar[maps to][pos=1]{*} \\ M' \rar[maps to][pos=1]{*} & N' \end{tikzcd}$
$M' \longmapsto^* N'$
\end{document}


Not horrible, but definitely off. I can get it closer by using pos=1.1, but I'd prefer a less fiddly solution (that won't break if the arrow's length changes, for instance). It would be especially helpful if I can define a /.style for this arrow so that I can change my existing ones (they already use a custom style).

• I can think to the decoration TikZ library. But it's just an idea. Oct 6, 2013 at 10:11
• Instead of pos=1 replace {*} with {} and try label={[pos=1,inner sep=0,outer sep=0]45:${}^*$} in the second one. To be honest the tikz version is better in my opinion. Oct 6, 2013 at 12:21
• Does star next to arrowhead in tikz help? Oct 6, 2013 at 14:01
• Ah! Guess I didn't hit on the right search keywords :-) Maybe this is a duplicate? (Unless there are tikz-cd-specific issues. Or maybe I'll end up editing the question to be specifically about a solution I can put in a style.) At any rate, I like the idea in your comment about making just “*” an arrowhead and combining it with the other; that sounds to me like the Right Thing. How would that work? Oct 6, 2013 at 19:20
• @percusse It doesn't seem to work unless I give the label= as part of the label options, which defeats the purpose since I don't want to have a label at all (unless there's a real label). Oct 9, 2013 at 1:04

I realized I could add shorten >=2.5pt to each starred arrow to make the diagram arrow match the text arrow better:
This meets my criterion that the code doesn't depend on the length of the arrow. I still have to add a label manually to each arrow, however, so I still can't define a mapsto* style that encapsulates this.