Is it possible to write a new command/macro in infix syntax instead of prefix syntax; especially I'd like to have this for $\frac{a}{b}$.

I use LuaLaTeX and with \newunicodechar{‾}{\overline} I can write ‾{blah} and this is expanded to \overline{blah}. Analogously I'd like to have $\frac{a}{b}$ to be something like {a}➗{b} or a÷b which would be much more readable.

  • 1
    It is not possible to get the last argument before a macro or active character and use it the same way as with normal arguments.
    – Martin Scharrer
    Dec 18 '11 at 14:55
  • In standard TeX, you can use \lastbox (not in math mode, however), but seemingly this doesn't work with single characters, only with "explicit" boxes. I am not sure, however, whether similar things couldn't be possible in LuaTeX-it's quite possible that you could use some lua trickery to retrieve a few last tokens (digits, for instance). Still, it is highly non-standard and would imho qualify for Appendix D of "The LuaTeXbook" (if it ever gets written) ;).
    – mbork
    Dec 18 '11 at 17:23

TeX already has primitive \over; try ${a \over b}$.

  • Thanks for the quick answer - are there any other infix TeX-primitives ? Dec 18 '11 at 15:17
  • @epsilonhalbe: Very few in comparison to the prefix (or macro) notation you mention. Macro usage can be just as readable, since you can now describe the function (or macro) to your heart's content: \frac if short for \fraction. You could define \newcommand{\fraction}[2]{\frac{#1}{#2}} which would allow you the same usage: \fraction{a}{b}. To the contrary (although not technically an infix operator), using $a \mid b$ doesn't really tell me anything about \mid, whereas \newcommand{\given}[2]{#1 \mid #2} and then using \given{a}{b} perhaps does, when you have naming freedom.
    – Werner
    Dec 18 '11 at 15:38
  • the infix names I only would use with unicode-symbols $a \mid b$ reads $a ∣ b$ in my setting which is quite expressive/readable to me. Dec 18 '11 at 16:35
  • 1
    @epsilonhalbe: there's also at least \atop, \above<rule height>, \atopwithdelims<delim1><delim2>, \abovewithdelims<delim1><delim2><rule height>, \overwithdelims<delim1><delim2>
    – morbusg
    Dec 18 '11 at 17:16
  • @morbusg I believe that those fraction-building primitives are the only infix ones, at least in TeX. I doubt that later engines added any. Dec 19 '11 at 5:48

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.