I have to write a small demonstration of some features of my package. I was thinking about doing something like:
\documentclass{article}
\usepackage{listings}
\newcommand{\demo}[1]{%
\fbox{
\begin{minipage}{.5\linewidth}
#1
\end{minipage}}%
\fbox{%
\begin{minipage}{.5\linewidth}
\begin{lstlisting}
#1
\end{lstlisting}
\end{minipage}}
}
\begin{document}
\demo{\section{section}}
\end{document}
But this isn't working, because of listings can't be used inside commands. Any nice solution? (Would like to have a left right comparison between source and result)
And is there some way to enclose this so that nothing outside is affected?

