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)? – egreg Sep 07 '21 at 16:18\oldlogor\operatorname{log}instead of\mathrm{log}. Also avoid using\left...\rightin general and stick to manual scaling. And if you must use automatic scaling, use the variants from the packagemleftrightwhere some spacing issues are being fixed. – Gaussler Sep 07 '21 at 16:47\operatorname, thanks for that! I read the amsmath package and it said\mathrmis a better alternative to many others, so that is nice to know. As for\left ... \right, I have never ever had any issues with it. Can you provide some extra material as to why I should have that opinion? Thanks :) – TimeTravelPenguin Sep 07 '21 at 16:51\left...\rightis that they have a tendency to make the delimiters way too big. Look at\[ \left( \sum_{n=0}^{\infty} \frac{1}{n^2} \right) \]to see what I mean. In this case,\Bigl( ... \Bigr)or\biggl(...\biggr)yield better results. Apart from that, there are certain spacing issues, but they can be fixed. – Gaussler Sep 07 '21 at 16:57\leftand\rightis to prefer them over manual scaling unless otherwise necessary. They are usually correct and there are some instances where they're necessary (e.g., if you want to write the open interval ]-1,0] which will be typeset incorrectly without using\left]and\right]. Not to mention cases where\Biggisn't bigggg enough or incorrect sizing without amsmath in anything that's not ten point. – Don Hosek Sep 07 '21 at 17:59\leftand\rightdon’t even give the delimiters\mathopenand\mathclosestatus. On top of that,\left...\rightchange the positioning of indices:\left(...\right)^2vs.(...)^2. The interval ]–1,0] can be typed\mathopen]-1,0], or, preferably, via some command (e.g. via\DeclarePairedDelimiter, theintervalpackage, or some custom solution; nobody will be surprised to learn that mine is based onsemantex). – Gaussler Sep 07 '21 at 18:47\mathopenand\mathclosecomes from. That same unknowledgeable author gives as his primary suggestion for the open interval\left]…\rightwith\mathopenand\mathcloseas a secondary suggestion. – Don Hosek Sep 10 '21 at 05:08\left...\rightare documented everywhere on this site. I agree that my previous formulation about not making them behave like\mathopenand\mathclosewas misleading, but it doesn’t change the facts. I know that the biggg commands are defined in terms of\left...\right; that does not change the fact that\left...\rightlead to both bad spacing and too big delimiters. I have no doubt that Knuth intended them to be used the way you suggest, but nowadays, the common consensus is that he made a wrong design choice in this particular case. – Gaussler Sep 10 '21 at 11:53\leftand\right, just ones that need to be resized. (btw you misspelled wrong in your reply, it doesn't start with m-i-s-) – Don Hosek Sep 10 '21 at 13:48\mathinneratom that is added by\left...\right. – Gaussler Sep 10 '21 at 13:56