This is what I want to achieve:

{ 2 \pow -(n+4) } --> {2^{-(n+4)}}

This is what I know how to do:


This is what I don't like about it:

\pow{2}{-(n+4)} is ugly to me.

Now, I know that plain TeX can do things like this due to:

\over, \choose, \above



"shows that such commands are internals."

I have dug into the TeX book (chapter 20), but do not see examples of how arguments can be to the left, i.e. I want something like:

\def #1\pow #2 {{#1}^{#2}}

Then, I tried things like:

\def \pow #1 \} {^{#1}\}}

However, neither of these work. Is it possible to define pow s.t.

{ 2 \pow -(n+4) } --> {2^{-(n+4)}}
  • 4
    \over is a primitive, and therefore does not implement the syntax in macros. Alexey's solution may work for you, but in TeX arguments have to come after the macro processing them (so in your case more complex 'before' parts may go wrong). – Joseph Wright Aug 18 '11 at 10:18
\newtoks \powtoks
\def \pow {\afterassignment\powhelp \powtoks=\bgroup }
\def \powhelp{^{\the\powtoks} \egroup }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.