I would like to make a command to help me writing lines like:
The \LaTeX~code is: \verb@e^{i\pi} - 1 = 0@, and the result is: $e^{i\pi} - 1 = 0$.
I thought of using a newcommand as:
\newcommand{\eqn}[1]{The \LaTeX~code is: \verb@#1@, and the result is: $#1$.}
to use as:
\eqn{e^{i\pi} - 1 = 0}
which doesn't work.
Trying to pull out the verbatim out as:
\newcommand{\eqn1}[1]{The \LaTeX~code is: #1, and the result is: $#1$.}
to use as:
\eqn1{\verb@e^{i\pi} - 1 = 0@}
also doesn't work.
My question is, is there a way to achieve this in latex?
Thank you. PS: unfortunately the thread bellow seems to indicate that it's not possible :( Wrapping code (listings, verbatim, or other method) inside a newcommand


\eqn1generates aMissing \begin{document}error); and youreqn1command takes math and pastes it into the document inside textmode, so you'll get a bunch of errors from that (e.g.^is not allowed in textmode). – Arun Debray Dec 18 '15 at 05:17\verbcommand inside of\textbfblock? – Werner Dec 18 '15 at 05:47