I would like to write a macro that works somewhat like showexpl but just reproduces the LaTeX code and the results of the code in a way that I can use inline.
\documentclass{article}
\usepackage{fancyvrb}
\begin{document}
I want a macro that produces something like ``\verb|$\bar\mathbf{x}$| produces $\bar\mathbf{x}$''.
\end{document}
Is this possible?
Best Answer
@Werner made a very similar answer (deleted) to the
\detokenize
version and at his suggestion I'll add some of the additional comments he made there:Note though that
\detokenize
returns the tokens used in an "already-grabbed" argument, and therefore introduces spaces. Also, you won't be able to pass\verb
orverbatim
content as a macro argument (see Why doesn’t verbatim work within …?). There might be other things that will break this as well.An alternatve approach is to first read the argument verbatim and then use
\scantokens
to re-parse it to obtain the normal meaning: