I'm loving using tikz-cd to draw compiler correctness diagrams, but I can't manage to get quite the same arrows for relations that I'm using in the text. In particular, I'm not sure how to get \Mapsto in a tikz-cd diagram.

I did try combining arrow options to get \Mapsto to work:




  M \rar[Rightarrow] \dar[maps to] & N \dar[maps to, Rightarrow] \\
  M' \rar[Rightarrow, maps to] & N'


But this wound up less than satisfactory (on TeXLive 2013):

Garbled arrows

As you can see, depending on the order I give the arguments, the bar is either missing (there should be one on the N-to-N' arrow) or comically huge. I assume this is a bug? Any known workaround?

  • 1
    tikz-cd doesn’t provide a maps to arrow for a doubled line, the arrows | and cm | (which is internally used here) does use the “doubled” line width and not the simple one. Looks like you need either to correct the arrow code for cm |/|` or introduce a new arrow. Sep 26, 2013 at 17:53
  • Well, according to the tikz-cd manual, the arrows with alternate names (one of which is mapsto/maps to) “can be superimposed with other arrows.” If it's not intended that I can mix the maps to and Rightarrow options, I think that's a documentation bug at any rate. In any case, I guess I'm shy about diving into arrow code and hoping there's a simpler way. Also IIUC there's an impedance mismatch between tikz-cd arrows, which combine the specification of the path with that of the arrow tip (I guess this is the source of the maybe-bug?), and tikz arrows (really just tips?). Sep 26, 2013 at 18:04

2 Answers 2


I’ve taken a look at the \Mapsto arrow from the stmaryrd package which I have used as the model for the redefinition of the cm | arrow that obeys a double line.

The 3.3 value is approximated so that the vertical line is as wide as the implies arrow (similar to how \Mapsto looks). The original maps to arrow as seen in the example has a rather short bar.


\expandafter\let\csname pgf@arrow@code@cm |\endcsname\relax
\pgfarrowsdeclare{cm |}{cm |}{%
\pgfqkeys{/tikz/commutative diagrams}{
  Maps to/.style={
    /tikz/commutative diagrams/Rightarrow,
    /tikz/commutative diagrams/maps to},
  Maps from/.style={
    /tikz/commutative diagrams/Leftarrow,
    /utils/exec=\pgfsetarrowsend{cm |}}
  M  \rar[Maps from] \dar[maps to]  & N \dar[Maps to] \\
  M' \rar[Maps to]    & N'


enter image description here

  • Cool, thanks! It's probably a bit much to ask that I be able to understand the code fully :-) but I take it the crux is checking \pgfinnerlinewidth, which will be zero for a single arrow (line) but positive for a double? Sep 26, 2013 at 18:22
  • 1
    @LukeMaurer Oh, me stupid. I have used \ifx where I should have used \ifdim to compare dimens. With the updated code, the single line maps to bar is the same as before (still a little shorter in comparison with the doubled one but well …). Sep 26, 2013 at 19:12
  • This doesn't work as of tikz 3.0.1a, but (see my new answer) there's a much easier solution: tikz-cd 0.9 has Mapsto built in. Mar 22, 2017 at 6:27

As of version 0.9c (if not earlier), tikz-cd now provides a Mapsto arrow.

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.