1

I want to define a macro \foo that behaves similarly to \over and \atop, such that the code

#1 \foo #2

outputs

foo #1 #2
FR09
  • 147
  • 1
    Welcome to TeX.SE. Can you provide a use case for wanting to use \over-like notation in a command? The commands \over and \atop, which are TeX primitives, are actually quite problematic from a design-theoretical perspective. There is a very good reason for why LaTeX provides \frac and discourages the use of \over. See also @Aditya's and @barbarabeeton's follow-up comments on this answer to the query What is the difference between \over and \frac? – Mico Dec 31 '20 at 09:04
  • The answer by @AméricoTavares provides additional information about the nature of the problems caused by the infix syntax of the TeX primitives \over, \atop, \above, etc. – Mico Dec 31 '20 at 09:20
  • The commands \over, \atop, \above, etc are implemented as TeX primitives, not as macros. As such, it's going to be rather tough to come up with new commands that adopt infix notation. Are you open to using a LuaLaTeX-based solution that acts like a preprocessor? – Mico Dec 31 '20 at 09:39
  • @Mico I would like to redefine \to into a command that generates a xymatrix and takes the word before \to as the domain of a function and the word after it as the codomain. Right now I have something like this. \renewcommand{\to}[3][]{\xymatrix@1{#2 \ar@{->}[r]^{#1} & #3}}. – FR09 Dec 31 '20 at 10:03
  • 3
    the infix \over (possibly the worst aspect of the tex design), is not implementable using TeX macros. If you have any prefix you could have some syntax such as \zzz ... \to ... where \zzz grabs the expression and splits on \to, but you can not "go back". – David Carlisle Dec 31 '20 at 10:20
  • @FR09 - I'm afraid I'm not familiar with \xymatrix and its syntax. Would you mind editing the body of your posting to spell out exactly how you expect the input to be formatted? Thanks. – Mico Dec 31 '20 at 11:19
  • 2
    @FR09 in $a+ { b + xyz \over 2}$ the numerator is b+xyz but your request for your \to to take "the previous word" would suggest that in $a+ { b + xyz \to 2}$ you want #1 to be xyz or z not b+xyz. without Lua none of these is implementable but which do you have in mind? – David Carlisle Dec 31 '20 at 14:37
  • Since this feature seems to take a lot more effort than I imagined, I don't consider it necessary. Thank you for your help! – FR09 Jan 01 '21 at 03:37

0 Answers0