# Dynamically size arrow \mapsto in function definition

I have the following diagram:

However, this looks a bit ugly, I would like a version that looks a little bit better. For example, size the last arrow such that the T_\phi is moved to the right.

This is the code which I am using to do this:

\begin{align*}
\xi \colon &\lb \to \mathcal{L}(\hh)\\
&\phi \mapsto T_\phi.
\end{align*}


Where \lb and \hh just give the names for those spaces. Does anybody have a suggestion how I would improve the look of this function definition?

-

Personaly, I think it is better to use:

\begin{align*}
\xi \colon L^\infty(T) &\to \mathcal{L}(H^2)\\
\phi &\mapsto T_\phi.
\end{align*}


Anyway, you can obtain what you want through

\documentclass{article}

\usepackage{amsmath}

\newcommand\phantomarrow[2]{%
\setbox0=\hbox{$\displaystyle #1\to$}%
\hbox to \wd0{%
$#2\mapstochar \cleaders\hbox{$\mkern-1mu\relbar\mkern-3mu$}\hfill \mkern-7mu\rightarrow$}%
\,}

\begin{document}

\begin{align*}
\xi \colon &L^\infty(T) \to \mathcal{L}(H^2)\\
&\phantomarrow{L^\infty(T)}{\phi} T_\phi.
\end{align*}

\end{document}


-
Thanks. You're right, the first suggestion looks the best (at least to me). I will try to figure out how the second one works, might turn out to be useful. –  Jonas Teuwen Oct 19 '11 at 12:17
The second one is rather tricky. You needn't know how it works if you don't want to become a developer of LaTeX packages. For more information for this, see the implementation of \xrightarrow in amsmath package, and the definition of \mapsto. –  Leo Liu Oct 19 '11 at 12:24

You may also want to try mathtools:

\documentclass{article}
\usepackage{amsmath}
\usepackage{mathtools}

\begin{document}

\begin{align*}
\xi \colon &L^\infty(T) \to \mathcal{L}(H^2)\\
&\phi \xmapsto{\phantom{L^\infty(T)}} T_\phi
\end{align*}

\end{document}


The output looks like:

-
Sorry for resurrecting the post. But, found this code really shorter. –  kan Aug 9 '12 at 15:37
Thanks. This a nice answer. I use mathtools already, so I will remember this. –  Jonas Teuwen Aug 9 '12 at 15:44