Often I find myself in the need of expanding some macro, whose contents should be given as an argument to another command. The usual solution is to invoke some \expandafter concoctions to somehow control the expansion, but I wonder if (at least for some common cases) there is an easier way.
As an example, imagine that I want to write something like the following
\somecommand{Some Argument}{\secondarg}
But I want to expand \secondarg before actually attempting to process \somecommand.
For this kind of scenarions, would it be possible to define a command so that
\expandafterallthat{\somecommand{Some Argument}}{\secondarg}
expands to something like
\somecommand{SomeArgument}{Contents of secondarg macro}
etoolboxoretextoolsprovides some macros like this. I think it is the latter. – Martin Scharrer Jul 04 '11 at 14:05\expandedmacro which does exactly what is being asked in the question. – Aditya Mar 20 '22 at 04:02\ExpandArgsin newer versions – user202729 Jun 13 '22 at 12:47