\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?


2 Answers 2


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.

  • 1
    I was about to post the same answer. ;-)
    – egreg
    Aug 13, 2013 at 12:50
  • why do i get an error saying that mathtools does not exists? MicTex 2.9 X64, Win7 X64. Oct 18, 2014 at 15:12
  • @ChenStatsYu That sounds like a completely separate question. May be tex.stackexchange.com/q/187725/15925 helps. Oct 18, 2014 at 18:01
  • when i type \xmapsto{A} then there is a normal rightarrow with a 7 at the start.. Jul 7, 2018 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. Jul 10, 2018 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .