I am currently learning, playing with xparse, and have the following demo command partially working:
\let\oldlog\log
\RenewDocumentCommand{\log}{s m e{_^}}{%
\ensuremath{%
\mathrm{log}%
\IfValueT{#3}{_#3}%
\IfValueT{#4}{^#4}%
\IfBooleanTF{#1}{\!\left(#2\right)}{#2}%
}%
}
My issue is the current result. What I expect is that \log{x}^{yy}_{zzz}
gives:
But instead, I get this:
Why doesn't the embellishment argument, e{_^}
capture the whole content in the braces for ^{yy}
and _{zzz}
?
\log_{zzz}^{yy}(x)
?\left
and\right
don’t even give the delimiters\mathopen
and\mathclose
status. On top of that,\left...\right
change the positioning of indices:\left(...\right)^2
vs.(...)^2
. The interval ]–1,0] can be typed\mathopen]-1,0]
, or, preferably, via some command (e.g. via\DeclarePairedDelimiter
, theinterval
package, or some custom solution; nobody will be surprised to learn that mine is based onsemantex
).