I would like to define a command using verbatim like in the commented line in the following code.


%   \newcommand{\example}[1]{\verb!#1! : #1}


\noindent \verb!$\textbf{A}^\intercal$! : $\textbf{A}^\intercal$


How can I acheive this? Is it possible to give the argument without the dollars?


The question that @Marco refers to Verbatim text can't be shown correctly in pdf and the referenced Why doesn’t verbatim work within attempt to explain the difficulties with verbatim commands within macros.

But based on your code in the MWE \newcommand{\example}[1]{\verb!#1! : #1} it appears that you want to be able to show the LaTeX code and its output:

enter image description here

One way to do that would be to use the LTXexample environment from the showexpl package:



| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.