I have a macro (here \mymacro
) that receives a command as one of the inputs (specifically a command of type \includegraphics{..}
).
The macro reads as
\newcommand{\mymacro}[4]{%
something{#1}
...
}%
and is called as
\mymacro{\includegraphics{..}}{..}{..}{..}
I am now in the necessity of parse the the content of the first argument as a string to extract content (i.e. parse the token \includegraphics{..}
itself to extract file name and modifiers). I will use xstring
parsing commands for the purpose.
In other words, I'd like to turn \mymacro
into something like
\newcommand{\mymacro}[4]{%
something{#1}
\stringparsingcommands{ \as__a__string{#1} }
...
}%
My question is:
how to build such \as__a__string
command? It needs to prevent #1
to be expanded as token and convert it into string.
I've been trying with \verbtocs
from the package \xstring
, yet with no success.
Any help is greatly appreciated.
tikzexternalize
execution\mymacro
. E.g., will it always be of the form\includegraphics{<some string>}
, i.e., will it always start with\includegraphics
and end with some material (a "string"?) that's encased in matching curly braces? If this is not the actual structure of the first argument, do please provide more in-depth information as to what should be expected.\includegraphics
call are irrelevant, I believe. I think the point is: from a call\mymacro{\command{string}}
can one extract and e.g. display in the manuscript the string\command{string}
as is (i.e. not expanded)?\includegraphics
(or rather keyval) is already going to parse the argument and is already going to and report the filename and various options, you can use the result of that parse.