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 want to label an \rightarrowtail, but the arrow is too short for my label. So I want an extensible version of this arrow. I've tried the extpfeil package, but am not sure how to use it to create my arrow. At present, I would know how if I had an arrow-like symbol that looked like the following:

" >-- "

However, I am unaware of any such symbol. Detexify and the symbol list don't seem to have it either. How should I make my arrow?

share|improve this question
    
Another option would be to use \xhookrightarrow from mathtools (not the arrow that you wish, but commonly used for injections). –  Caramdir Jan 28 '11 at 16:58
add comment

3 Answers

up vote 1 down vote accepted

Another option would be to use TikZ to define an \xrightarrowtail macro:

\documentclass{amsart}
\usepackage{tikz}

\makeatletter
\newbox\xrat@below
\newbox\xrat@above
\newcommand{\xrightarrowtail}[2][]{%
  \setbox\xrat@below=\hbox{\ensuremath{\scriptstyle #1}}%
  \setbox\xrat@above=\hbox{\ensuremath{\scriptstyle #2}}%
  \pgfmathsetlengthmacro{\xrat@len}{max(\wd\xrat@below,\wd\xrat@above)+.6em}%
  \mathrel{\tikz [>->,baseline=-.75ex]
                 \draw (0,0) -- node[below=-2pt] {\box\xrat@below}
                                node[above=-2pt] {\box\xrat@above}
                       (\xrat@len,0) ;}}
\makeatother

\begin{document}
  \[ f : G \xrightarrowtail[{\star}]{\text{\textbf{Grp}}} H \]
\end{document}

This produces the output

An extensible right arrow with a tail drawn with TikZ.

(The amsart document class is only used to get \text, and not used in the macro definition.)

Edit: I realize I should probably explain what's going on here. It's not too complicated: we allocate boxes \xrat@below and \xrat@above to store the text we're going to place above and below, and we fill them with our arguments set as script-style math. We then set \xrat@len, which will be the arrow length, to the larger of the two widths plus .6 ems for padding on either side. We then simply draw the arrow, placing the below box below and above box below. It's worth noting that the values in +.6em, baseline=.75ex, below=-2pt, and above=-2pt are all completely arbitrary, and result from me tinkering briefly; changing them might give better results for your use case. The baseline option moved the arrow up to the middle, instead of having it trail along the ground, and the below and above options set the text closer to the arrow, which is desired in this context.

A better solution would probably be to figure out how to use amsmath's \ext@arrow command (which it uses to define \xleftarrow and \xrightarrow, and which other packages for similar commands seem to use as well), but I can't figure out how it works. Strike that, this would require the missing \arrowtail (>--) macro which you were asking about in the first place (since extpfeil uses \ext@arrow under the hood as well). I suppose the best bet might be to create such a character in Metafont or some such, but I'm not sure how to do that.

share|improve this answer
add comment

Something like one of these 3, or a variant thereof:

\documentclass{article}
\usepackage{extpfeil}
\newextarrow{\injecta}{5599}{\succ\relbar\relbar}
\newextarrow{\injectb}{5599}{>\relbar\relbar}
\newextarrow{\injectc}{5599}{\succ\relbar\rightarrow}
\begin{document}
  \[x\injecta[under]{above}y\]
  \[x\injectb[under]{above}y\]
  \[x\injectc[under]{above}y\]
\end{document}

Edit: here is the output:

enter image description here

share|improve this answer
add comment

something like this?

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\makeatletter
\newcommand\xlongrightarrow[2][]{\ext@arrow 0055{\longrightarrowfill@}{#1}{#2}}
\def\longrightarrowfill@{\arrowfill@{>\mkern3mu}\relbar\relbar}
\makeatother
\begin{document}

$\xlongrightarrow[foo]{\text{looooong}}$

\end{document}

enter image description here

share|improve this answer
1  
The arrow should probably also have a head (\rightarrowtail has one). –  Caramdir Jan 28 '11 at 16:59
    
then he can replace the right \relbar with \rightarrow –  Herbert Jan 28 '11 at 17:05
    
Okay, I don't know what that means. I can do \package{extpfeil}\newextarrow{\xmono}{500{40}}{>\relbar\rightarrow} as easily, but the head of the arrow then looks way different from the tail. And doing {>\relbar >} instead results in an arrow that is internally consistent, but which is ugly and looks like none of my other arrows. –  jdc Jan 28 '11 at 17:59
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.