TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
Thanks for the link but it does not help me... – projetmbc Oct 7 '11 at 20:54
up vote 5 down vote accepted

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:



share|improve this answer
Thanks for this. – projetmbc Oct 8 '11 at 13:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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