8

Is there a longer version of \mapsto, like with \rightarrow and \longrightarrow? I found an ugly solution by inserting a couple of \quads on top of \xmapsto, but it's not very elegant.

touhami
  • 19,520
  • 7
    there is \longmapsto – touhami Jun 30 '16 at 08:52
  • Thanks for the answers. I have no idea what happened. I think I tried \longmapsto, but it failed, or something. When I tried to write my own \longmapsto, latex complained, and said it already existed. In essence, I messed up. – LetGBeTheGraph Jun 30 '16 at 09:00

1 Answers1

5

I once needed some special integral signs and sort of 'faked' them using TikZ. You could do the same thing for your arrow. Here is an example:

\def\mylongmapsto#1{%
\begin{tikzpicture}
\draw (0,0.5mm) -- (0,-0.5mm);
\newlength\mylength
\setlength{\mylength}{\widthof{#1}}
\draw[->] (0,0) -- (1.2\mylength,0) node[above,midway] {#1};
\end{tikzpicture}
}

\mylongmapsto{hello world}

\mylongmapsto{this is another long mapsto arrow}

it allows you to place text on top of your arrow and automatically scales it accortingly. Gives me the following results:

enter image description here

T. Pluess
  • 1,040
  • 2
    It appears that this works in text mode. How would one make this work in math mode, like the align environment, for example? – BSplitter Mar 28 '18 at 16:38
  • 5
    @BSplitter You can use \xmapsto{Hello world} with \usepackage{mathtools}. Maybe \xmapsto{\phantom{Hello world}} if you only want the big arrow without the text. – nowhere dense May 14 '18 at 21:33