# New command to display a symbol and its command

I'd like to print a symbol and the command to get the symbol. For example,\bomb\ (\verb|\bomb|). To make a command to save some keystrokes, I came up with this command \newcommand{\symb}[1]{#1\ (\verb|#1|)}. However, I get some compilation error \verb ended by end of line. with wrong results.

\documentclass{article}

\usepackage{fourier}
\usepackage{marvosym}
\newcommand{\symb}[1]{#1\ (\verb|#1|)}

\begin{document}

Fourier
\begin{itemize}
\item \symb{\danger}
\item \bomb\ (\verb|\bomb|)
\item \grimace\ (\verb|\grimace|)
\end{itemize}

\end{document}


What's wrong and what might be the solution?

• You can't use \verb inside of a macro, as generally verbatim content is not possible, at least not this way. – user31729 Jan 20 '18 at 19:37

It is too late to use \verb after the argument has been tokenised but you can do:

\documentclass{article}

\usepackage{fourier}
\usepackage{marvosym}
\newcommand{\symb}[1]{#1\ (\texttt{\string#1})}

\begin{document}

Fourier
\begin{itemize}
\item \symb{\danger}
\item \bomb\ (\verb|\bomb|)
\item \grimace\ (\verb|\grimace|)
\end{itemize}

\end{document}