# Partially expanding macro argument

I have a library of tikz pictures, eg.

\newcommand*{\mypic}[1]{
\begin{tikzpicture}
%...
\end{tikzpicture}
}


which I would like to print together with their names (including arguments). However,

\renewcommand{\show}[1]{\verb|#1|\quad #1}
\show{\mypic{a}}


produces

Package tikz Error: Sorry, some package has redefined the meaning of the math-mode dollar sign. This is incompatible with tikz and its calc library and might cause unrecoverable errors.

I guess \show is trying to expand its argument inside \verb. I experimented with \expandafter but it didn't help. When I replaced \verb| | with \texttt{}, \show didn't print the macro name at all.

• \verb cannot appear inside another macro. Aug 18 '20 at 5:03
• Try instead \renewcommand{\show}[1]{\detokenize{#1}\quad #1} Aug 18 '20 at 5:03
• Also \show only takes a single token. If you want to print multiple, try \message{...} or \errmessage{...}. Aug 18 '20 at 5:04

Firstly, it's better to not redefine primitive, for example \show. Just choose another command name. Then, \Verb from fvextra package is more robust than \verb, when used inside another macro.

\documentclass{article}
\usepackage{fvextra}
\usepackage{tikz}

\newcommand*{\mypic}[1]{
\begin{tikzpicture}
\node[draw, circle] {text};
\end{tikzpicture}
}