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}
etoolbox
oretextools
provides some macros like this. I think it is the latter.\expanded
macro which does exactly what is being asked in the question.\ExpandArgs
in newer versions