At some point, it occurred to me that another level of abstraction may be possible on top of LaTeX. For example, why should I type
\left( \frac{\frac{a}{b + c} \frac{w + \lambda}{z}}{x\left[ \frac{c_n}{d}\right]} \right)\left \{\frac{x_0}{y_0} : x_0 > 0 \right \}
when I could say the same thing, more compactly, with
({{a}/{b + c} {w + \lambda}/{z}}/{x[{c_n}/{d}]} ){{x_0}/{y_0} : x_0 > 0}
or even
({a/{b + c} {w + \lambda}/z}/{x[c_n/d]} ){x_0/y_0 : x_0 > 0}
Sure, conversion from the latter to the former may not be general enough for all use cases, but it should be okay for many of them. It's also somewhat easier to read/debug, what with the fewer words running around.
I think I am going to try to implement such a command, \textmath{...} in LuaTeX (the {} should not be a problem since the parentheses are supposed to be balanced) that does precisely this conversion. But before I attempt this, my question is: is there already a package that does something similar?
After all, I'd hate to reinvent the wheel, and I suspect this question may be also on some other peoples' minds.
Thank you!
Note: this question isn't about the macros that many TeX editors have, convenient as they may be. While they may allow you to perform the topmost expansion automatically, that does not help readability in the long-run :(
This module was meant to implement features present in calculator math, so it only supports a single style of parenthesis and does not support subscripts or superscripts, although it should be easy to add them.
\frac{\Li n}{n/\log n}(\Liis defined suitably) which should not be rendered as\frac{\Li n}{\frac{n}{\log n}}. Also adding\leftand\righteverywhere is not a good idea. – egreg Sep 29 '11 at 23:20\Li. But thinking about it, you're probably right in that I'd need to allow the user to distinguish between frac and nonfracs. Is there a particular reason\leftand\right's are bad, since they would be invisible to the user when luatex.print(...)s them? – scallops Sep 29 '11 at 23:27\leftand\right: they influence the spacing and also the placement of exponents, often in nonoptimal way. – egreg Sep 29 '11 at 23:37\left...\rightpart, but treats fractions in a special way. – Philippe Goutet Sep 30 '11 at 04:28mathtoolsalso implements a similar solution. But what you say about the placement of exponents? – Mateus Araújo Sep 30 '11 at 05:34$(a+b)^2$and$\left(a+b\right)^2$; moreover in the second formula the spaces around the+are frozen, because\left-\rightmakes a subformula. – egreg Sep 30 '11 at 08:13