In most cases, by the time output gets to your screen, arguments are fully expanded and my question is moot. But sometimes (verbatim being a common example), one wishes to operate on arguments with different levels of expandedness. My question concerns how to preserve a level of expandedness, or conversely, how to do a partial expansion.
Here's an MWE which demonstrates how the level of expandedness of the argument affects the result:
\documentclass{article}
\usepackage[T1]{fontenc}
\newcommand\display[1]{\expandafter\string#1}
\begin{document}
\display{\large word}\par
\def\x{\large word}
\display{\x}
\end{document}
In the first case, I pass actual text to my macro \display
and get the top line. But if I stuff the same text into \x
and pass it to the macro \display
, it produces a different output, because the the two different invocations supplies the macro with an argument at different levels of expansion.
To the MWE, how does one reconcile the output in either direction (i.e., if the first output was what I actually sought from the second instance and, alternately, if the second output was what I actually sought from the first instance)?
Related to this MWE would be to know if there is something like a \verbatim{\x}
which prints out the verbatim of the first level expansion of \x
, for the example of the MWE, producing \large word
(space included).
More generally, what are the LaTeX techniques for controlling the expansion of an argument, when what your macro gets may be far removed from the original "plain" text.
\detokenize\expandafter{\x}
and so on.