Extended \Mapsto with text above
The mathtools
package provides nearly everything you need to construct this, and stmaryrd
has the extra pieces of symbols. Putting these together gives
\documentclass{article}
\usepackage{centernot}
\usepackage{mathtools}
\usepackage{stmaryrd}
\makeatletter
\newcommand{\xMapsto}[2][]{\ext@arrow 0599{\Mapstofill@}{#1}{#2}}
\def\Mapstofill@{\arrowfill@{\Mapstochar\Relbar}\Relbar\Rightarrow}
\makeatother
\begin{document}
\begin{gather*}
\mapsto \qquad \xmapsto[A]{sdfkjhsdf} \\
\Mapsto \qquad \xMapsto[A]{sdfkjhsdf}
\end{gather*}
\end{document}
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.
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.
\documentclass{article}
\usepackage{stackengine}
\usepackage{scalerel}
\usepackage{fp}
\def\clipeq{\kern -.65pt\mathrm{=}\kern -1pt}
\def\Lla{\rule[-.1ex]{.3pt}{1.3ex}}
\def\Lra{\kern -3.5pt\Longrightarrow}
\newcount\argwidth
\newcount\clipeqwidth
\savestack\tempstack{\stackon{$\clipeq$}{}}%
\clipeqwidth=\wd\tempstackcontent\relax
\newcommand\xMapsto[2]{%
\savestack\tempstack{\stackon{$\scriptstyle#1$}{$\scriptstyle#2$}}%
\argwidth=\wd\tempstackcontent\relax%
\FPdiv\scalefactor{\the\argwidth}{\the\clipeqwidth}%
\FPsub\scalefactor{\scalefactor}{1.5}% <---CAN PLAY WITH THIS VALUE
\FPmax\scalefactor{\scalefactor}{.05}%
\mathrel{%
\stackunder[2pt]{\stackon[3pt]{$\Lla\hstretch{\scalefactor}{\clipeq}\Lra$}%
{$\scriptstyle#1~$}}{$\scriptstyle#2~$}%
}%
}
\parskip 1ex
\begin{document}
$X \xMapsto{ABC}{defghi} Y$
$\xMapsto{}{}$
$\xMapsto{a}{}$
$\xMapsto{ab}{}$
$\xMapsto{abc}{}$
$\xMapsto{abcd}{}$
$\xMapsto{abcde}{}$
\end{document}