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
(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.
I have no idea why your example doesn't work, but specifying the arrow tip with ->, >=triangle 60
instead works for me.
\documentclass[a4paper,abstracton,11pt]{scrreprt}
\usepackage{tikz}
\usetikzlibrary{automata}
\usetikzlibrary{arrows}
\begin{document}
\begin{tikzpicture}
\node (loop-node) at (0,0) {node};
\node (path-start) at (2,0) {start};
\node (path-end) at (2,2) {goal};
\path (path-start) edge [-triangle 60] node {path} (path-end)
(loop-node) edge [loop above,->, >=triangle 60] node {edge} ();
\end{tikzpicture}
\end{document}
Best Answer
It's possible to use arrows in non-math style using the
textcomp
package. It defines some arrows:Edit
Here is some addition with unicode support within (pdf)latex: Some (but not yet all) unicode characters can be just copied or entered with some code into the
.tex
document and compiled, if\usepackage[utf8]{inputenc}
is used. (The symbol → can be typed directly or copied from a character table application (Windows Symbol map) or KCharSelect on KDE on Linux etc., for example)However, not any copied or entered character is yet recognized. With
\newunicodechar
from Enrico Gregorio's (egreg!!!) packagenewunicodechar
it's possible to prepare the document to use the direct symbol. See the example for it's usage.The unicode characters usually have a symbolic representation (the unicode): → has the code U+2192
The way, how unicode characters can be typed directly depends on the operating system and editors, but CTRLSHIFTU2192 is a good guess (at least it works for Firefox)
A former version used
ucs
and\unichar
-- thanks to some notes by egreg, I dropped this and revised the example