答案1
哎呀,我算出来了;原来你需要_{#3}
和^{#4}
。
\let\oldlog\log
\RenewDocumentCommand{\log}{s m e{_^}}{%
\ensuremath{%
\mathrm{log}%
\IfValueT{#3}{_{#3}}%
\IfValueT{#4}{^{#4}}%
\IfBooleanTF{#1}{\!\left(#2\right)}{#2}%
}%
}