I have the following MWE which takes an argument and prints it verbatim. I have obtained the code from this answer.
\documentclass{article}
\makeatletter
\newcommand{\myverb}{%
\begingroup
% deactivate special characters
\let\do\@makeother
\dospecials
% change '{' and '}' back to normal
\catcode`\{=1
\catcode`\}=2
\@myverb%
}
\def\@myverb#1{%
\endgroup%
\texttt{#1}%
}
\makeatother
\begin{document}
\myverb{$\alpha$}
\end{document}
yields $\alpha$ on the page.
I want to define a macro \showcase which will print the code that was used for the text, and the evaluation of that code, namely
\newcommand\showcase[1]{\myverb{#1} #1}
\showcase{$\alpha$}
I expected this to print
$\alpha$ <actual-letter-alpha>
but instead it prints
<actual-letter-alpha> <actual-letter-alpha>
because the argument is expanded before it is taken by \myverb (I think).
What should I do to make the macro behave the way I want?
Note: I want to use this macro either inside a table or minipages, so that I can showcase the macros I have defined. So I need to be able to play with it, like put the column delimiter & between, or separate them into two minipage environments.
\newcommand\showcase[1]{\texttt{\meaning#1} #1}}– David Carlisle Jul 25 '14 at 14:53\verbin a macro argument) so your definition is just\texttt{#1}` – David Carlisle Jul 25 '14 at 14:54\myverb. – osolmaz Jul 25 '14 at 15:19\meaning, then you don't have a problem with{}If you don't like eh prefix\meaningadds you can remove it (see for example the definition of verb intabularx) – David Carlisle Jul 25 '14 at 15:22