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 am trying to enrich $\to^*$ with a $w$ above it, and the cleanest look I could get was with the {\smash {\overset w \rightarrow}}^* command. However, I believe this to be a pretty ugly solution, and \smash also smashes the space between two variables and the arrow itself (in for example $g {\smash {\overset w \rightarrow}}^* g'$. Is there a better solution that does not result in the w to be high above the arrow, or the * high above the arrow?

PS: How do you use mathmode or how can you display TeX commands? On other SE sites you can use $ $.

share|improve this question
2  
Regarding your P.S.: You can't, as it's usually the code itself that is interesting. See for example Why doesn't maths render as maths? on meta. You have to upload an image manually. –  Torbjørn T. Apr 15 '12 at 17:00
    
How about $g \mathrel{{\stackrel{\hskip-0.7ex w}{\to}}}{\hskip-1ex}^* g'$? Also, I really think that it is not LaTeX but it's the notation that makes it uncomfortable. –  percusse Apr 15 '12 at 17:24
    
possible duplicate of Arrow with an asterisk superscript and text above? –  Caramdir Apr 15 '12 at 23:44
1  
I wonder if we should dupe the older question to this one: the solution here looks cleaner to me. –  Joseph Wright Apr 16 '12 at 6:10
    
@JosephWright: It certainly is. As egreg points out, the solution in the other question also gives wrong line height. On the other hand, the other question has a better formulated question text. –  Caramdir Apr 16 '12 at 23:29

1 Answer 1

up vote 7 down vote accepted

You have to put a "phantom" arrow; here \tostar is defined to have an optional argument, the letter that goes over the arrow (default w):

\documentclass{article}
\usepackage{amsmath}
\newcommand\tostar[1][w]{%
  \xrightarrow{#1}\mathrel{\vphantom{\to}^*}
}

\begin{document}
$a \tostar b$
\end{document}

We use the fact that TeX doesn't insert spaces between two relation symbols.

enter image description here

share|improve this answer
    
Perfect! This isn't the first time I've seen "phantom". Does it have some meaning? –  codd Apr 15 '12 at 18:59
    
The \vphantom{\to} only occupies the vertical space of \to so we can append the asterisk to the right height. –  egreg Apr 15 '12 at 19:23

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.