I would like to write some LaTeX code, and without repeating myself, I would like that to be used for displaying that particular piece of code as-is and its typeset version, next to each other.
The solution in my head involves creating a command which shall take one required argument, which will be my LaTeX code; and this command shall use its argument to display it both inside some verbatim
-like environment where it shall remain as-is, and outside where it shall be typeset.
However, something as in below does not work:
\newcommand{\codewithoutput}[1]
{
\begin{verbatim}
#1
\end{verbatim}
#1
}
And this is it, this is the best I can. I am completely stuck at here for the past 2 hours.
Since I am trying to display a LaTeX code here, using \texttt[1]
or anything like that will not help, I think.
tcolorbox
for example!