![](https://secure.gravatar.com/avatar/c5ae4f9aa0d3a9bd5376e92b322c3e50.jpg?s=120&d=mm&r=g)
24 Feb
2007
24 Feb
'07
9:55 a.m.
Hi, Can I define a math macro, say \EXP that does the following: 1) \EXP{something} gives me, say E(something) 2) \EXP_a^b{something} gives my E_a^b(something) That is, I want to write a macro that will only be used in the math mode, that does something with its argument. But, I also want it to handle _ and ^ if they are present. The only method that I can think of is to check _ or ^ with \ifnextcharacter and go through all 5 cases (nothing, only _, only ^, _ followed by ^, ^ followed by _) but this seems very inefficient. Is there a better way? Aditya