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 was thinking about doing something crazy, namely, I want to define a "newcommand" by

\renewcommand{\alpha}{\ensuremath{\alpha}}

so that later in text mode I can just do \alpha instead of $\alpha$ (The actual macro will have \xspace in it, but let's ignore that.).

The question is, how do I let the system know, when it replace \alpha by \ensuremath{\alpha} to use the "built-in" macro \alpha, instead of the renewed one, and thus not stuck in an infinite loop?

Or, is there a way to make sure the macro only "expand" once?

share|improve this question
    
Don't moan when you find that the result of \alpha-\beta is different from what you'd expected. There's no reason why math symbold should be used in text without proper markup. –  egreg Feb 20 '13 at 7:36
    
Well, that's what I expected, so I will take care. You see lots of the time people want to write \alpha-male or \epsilon-neighborhood, \delta-ball etc. And there is no easy solution for that. –  hyh Feb 20 '13 at 8:13
    
For alpha-male, you can always write it in full text. For \epsilon-neighborhood, you really should write it with dollars : see for example the difference between $\epsilon$'-neighborhood (expansion of your macro) and $\epsilon'$-neighborhood (what you probably want to write). The point is : if it is always the same math symbol with the same text, you can encapsulate all in a macro. But if it may vary, you should stick with math markup. You can also see tex.stackexchange.com/questions/34830/…. –  T. Verron Feb 20 '13 at 8:21
    
@T.Verron I understand that primes are funny and will take care of that. I will put it in math mode whenever it is not a single letter. –  hyh Feb 20 '13 at 8:27
1  
@hyh Yes, there is an easy solution for that: $\alpha$-male. But, since it's a technical term in a non mathematical field, probably \alphamale with a proper definition would be preferable. –  egreg Feb 20 '13 at 8:46

1 Answer 1

up vote 5 down vote accepted

I'm not sure why you would want to do this, but here's how anyway

\let\oldalpha\alpha
\renewcommand{\alpha}{\ensuremath{\oldalpha}}

Your queried approach would result in an infinite loop. The \let essentially makes an alias for the former meaning of \alpha which will allow you to redefine it later.

share|improve this answer

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.