\usepackage{ stmaryrd }

    $\xmapsto{sdfkjhsdf}$ % This is similar to what I want

    $\Mapsto$ % however I need this kind of arrow

    %$\xMapsto{sdfkjhsdf}$ % does not exist - results in error

Output of the first two:


I want an extensible mapsto with writing on top like the first, but with an arrow like the second. Is there a way to do this from the existing packages?

  • 1
    Is \Longmapsto enough for you? – Sigur Aug 13 '13 at 12:08
  • 1
    Should be \longmapsto, it exists. – Yan King Yin Nov 15 '15 at 9:01

The mathtools package provides nearly everything you need to construct this, and stmaryrd has the extra pieces of symbols. Putting these together gives

Sample output



\newcommand{\xMapsto}[2][]{\ext@arrow 0599{\Mapstofill@}{#1}{#2}}

   \mapsto \qquad \xmapsto[A]{sdfkjhsdf} \\
 \Mapsto \qquad \xMapsto[A]{sdfkjhsdf}

The parameters 0599 are for the placement of the labels and how much the arrow extends over them. I have use the same numbers as mathtools does for \xmapsto. \Mapstochar is the short bar at the beginning, from the stmaryrd package, \Relbar is the double line which fits with final \Rightarrow. The internal macros names include the @ character, so have to be included in a \makeatletter / \makeatother pair.

It might have been nice to use the extpfeil package for this, but unfortunately it loads stmaryrd with clashing options.

  • I was about to post the same answer. ;-) – egreg Aug 13 '13 at 12:50
  • why do i get an error saying that mathtools does not exists? MicTex 2.9 X64, Win7 X64. – Chen Stats Yu Oct 18 '14 at 15:12
  • @ChenStatsYu That sounds like a completely separate question. May be tex.stackexchange.com/q/187725/15925 helps. – Andrew Swann Oct 18 '14 at 18:01
  • when i type \xmapsto{A} then there is a normal rightarrow with a 7 at the start.. – Lillien Sabrina Gluch Jul 7 '18 at 13:21
  • @LillienSabrinaGluch I can not reproduce that; it works fine for me. Perhaps you could ask a separate question posting the code you try. – Andrew Swann Jul 10 '18 at 11:00

The fp package is used to calculate the appropriate width of the arrow. The kerns will be important if you change fonts. It's set up to provide an arrow length of a certain minimum width, regardless of the over/underset. THen, as the over/underset grows, the arrow width will grow with it.

\def\clipeq{\kern -.65pt\mathrm{=}\kern -1pt}
\def\Lra{\kern -3.5pt\Longrightarrow}
  \FPsub\scalefactor{\scalefactor}{1.5}% <---CAN PLAY WITH THIS VALUE
\parskip 1ex
$X \xMapsto{ABC}{defghi} Y$







enter image description here

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.