Typically a TeX command have arguments coming after it. But the command \over, which is used to produce fractions, can access the token before it. How exactly is it implemented and can I define a custom command like that?
|
It's a TeX primitive so no you can't define commands like it. It's also a pain in the neck and the cause of many of the problems in math mode, as it means that you can not be sure when you first encounter any math mode token what style things will end up in, hence the need for |
|||
|
|
|
It occurs to me that there is one other TeX primitive that can do this: As David Carlisle said, though, its syntax is a poor design decision. For user-visible commands you have the luxury of requiring the author to write the operation before its operands. For internal commands, |
|||
|
|

\over. Perhaps one could hook into this tokslist? – L Spice Jan 30 '12 at 21:31\overbut got nothing. I too guessed it was built-in but still hoped there was a way to access the token list (although David’s answer seems to imply there’s no way to do that…). – JC Chu Jan 30 '12 at 21:45\overit puts this list aside, starts another math list and when this one is over it builds the fraction from the two lists. – egreg Jan 30 '12 at 21:52