Basically I want to define a macro whose parameter should be treated as a "script", meaning that I want to print it in a verbatim way including line breaks and special characters. Furthermore, I want to use this parameter in a second way, namely as an input to create a qrcode (using the qrcode package). A very minimal example is the following:
\documentclass{article}
\usepackage{qrcode}
\newcommand{\script}[1]{
#1\qrcode{#1}
}
\begin{document}
\script{test}
\end{document}
When I do it like this, the parameter is obviously not interpreted as verbatim. Since I need the parameter at two different places (both interpreted in verbatim mode), I cannot use an environment either -- such as a listings environment -- since the body text cannot (directly) be used as parameter.
I played around with the environ package (see my earlier question: Is it possible to "scan" the text within an environment?) to capture the body text of an environment, but, again, didn't succeed to make it verbatim.
I also tried to work with \obeylines and \StrSubstitute, but it gets quite ugly really soon, and it didn't actually work well.
It looks rather easy, but I'm struggling with this for a long time now. Any suggestions?


#1\qrcode{#1}the first#1should be verbatim but the second one not? Or should both occurences be verbatim? – cgnieder Jul 25 '15 at 15:49\script{\#}and\qrcode{\#}will give different QR codes… (just to be sure) – cgnieder Jul 25 '15 at 15:55\script{\#}should produce a qrcode of the two characters \ and #, while\qrcode{\#}would produce a qrcode of # (as far as I know). – lukas.coenig Jul 25 '15 at 16:06newverbspackage (limitation: requires|...|style argument, not work with{...}) – user202729 Dec 25 '21 at 09:40