10

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}

MWE output

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).

David Carlisle
  • 757,742
  • I can think to the decoration TikZ library. But it's just an idea. – egreg Oct 06 '13 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. – percusse Oct 06 '13 at 12:21
  • 2
  • 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? – Luke Maurer Oct 06 '13 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). – Luke Maurer Oct 09 '13 at 01:04
  • @LukeMaurer Have you seen my remark about the \pgftext inside the arrow code in the linked question? This works only for the first time (I guess because the arrow picture is stored away and the next time the TeX box is somehow lost and/or overwritten). For very easy paths, the easiest may to add a node at the end of the path (but hidden in a style as in the linked question). Not an arrow tip but it doesn’t seem so easy to use text in an arrow tip. :( – Qrrbrbirlbel Oct 11 '13 at 00:31
  • Urk. I dug into it, and it looks like what goes wrong is that the “protocolling” mechanism that caches arrows stores the /literal text/ that the driver outputs to draw it (so, the primitive PDF drawing primitives, etc.). All well and good, but then it only caches drawing primitives, not general TeX or even just a TeX saved box. So the caching simply has no way of capturing a \pgfqbox (the low-level operation behind \pgftext) at all, so it's not done when the protocol is used to draw an arrow. – Luke Maurer Oct 16 '13 at 01:53
  • Oh dear. I just had a really evil thought for how to bypass the arrow caching mechanism. It would eat up memory and be ridiculous. But it would work … – Luke Maurer Oct 16 '13 at 01:55

1 Answers1

5

I realized I could add shorten >=2.5pt to each starred arrow to make the diagram arrow match the text arrow better:

Output

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.