Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I use $\xrightarrow{f}$ a lot and I found myself in need of the corresponding commands \xmapsto and \xhookrightarrow quite a few times and I was wondering if there is anything like it. I'd like to produce

(i) a labeled hookrightarrow

(ii) a labeled mapsto

Thanks in advance for any help.

share|improve this question
1  
A tip: you can highlight commands and small portions of code by enclosing it between two backticks `` Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. –  Christian Hupfer Jun 27 at 10:41
add comment

2 Answers 2

up vote 5 down vote accepted

I am not sure, whether you mean those commands with labels, but I think they could provide the relevant symbols:

\xmapsto{label}, \xhookrightarrow, all from mathtools package.

\documentclass[12pt]{article}
\usepackage{mathtools}

\begin{document}


\begin{align*}
\xmapsto{\text{Look here}} &&  x\\
\xrightarrow{\text{Something}} && y \\
\xhookrightarrow{\text{Something completely different}} && z 
\end{align*}

\end{document}

enter image description here

Please have also a look on http://mirrors.ctan.org/info/symbols/comprehensive/symbols-a4.pdf, which provides a (perhaps not complete, but near to it) overview of symbols in LaTeX

share|improve this answer
    
Ooh! mathtools was exactly what I needed! : ) Thank you very much for this helpful answer. It does make one wonder though why xrightarrowdoes not need the same package included as the other two commands. –  Matt N. Jun 27 at 11:08
1  
@MattN. \xrightarrow is a command already available by ususal amsmath and perhaps redefined/improved in mathtools (I did not check for it now), but not \xmapsto and \xhookrightarrow (as far as I know). To make it work. If you include both amsmath and mathtools, amsmath must come before the other one. –  Christian Hupfer Jun 27 at 11:11
1  
mathtools does not touch \xrightarrow, we only provide the extra ones. –  daleif Jun 27 at 11:16
    
@daleif: Ok, I already guessed that, therefore I wrote perhaps. Thank you. –  Christian Hupfer Jun 27 at 11:17
    
@ChristianHupfer Thank you for pointing that out to me. –  Matt N. Jun 27 at 12:09
add comment

A minimal implementation if you do not wish to import mathtools

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\providecommand*{\xmapstofill@}{%
  \arrowfill@{\mapstochar\relbar}\relbar\rightarrow
}
\providecommand*{\xmapsto}[2][]{%
  \ext@arrow 0395\xmapstofill@{#1}{#2}%
}
\makeatother

\begin{document}
\[
  A \xmapsto[under]{over} B
\]
\end{document}

AMSmath's \ext@arrow is the command that generates the extensible arrow composed of the chars defined in its fifth argument, in this case \xmapstofill@; in turn this defines the arrow to start with \mapstochar\relbar (|-) then repeat \relbar (-) as many times as needed to fit the label, then end with \rightarrow (->).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.