I'm trying to use the filecontents package in combination with listings as suggested in How to define macro that only makes argument substitution? in order to produce a side-by-side view of LaTeX code and the corresponding output.
Here's what I have:
\documentclass{article}
\usepackage{listings,filecontents}
\begin{document}
\newenvironment{testenv}{%
\csname filecontents*\endcsname{\jobname.tmp}}{%
\csname endfilecontents*\endcsname
\noindent
\begin{minipage}{0.5\textwidth}%
\input{\jobname.tmp}%
\end{minipage}%
\begin{minipage}{0.5\textwidth}%
\lstinputlisting[basicstyle=\ttfamily]{\jobname.tmp}%
\end{minipage}%
}%
\begin{testenv}
Some lines?
of text !!!
here.
\end{testenv}
\end{document}
Expected output:
Actual result:
ERROR: Missing number, treated as zero.
--- TeX said ---
<to be read again>
\openin
l.1 Some lines?



filecontents*environment is treated as verbatim text, and then normal rules don't apply. – Ernest A Jul 21 '16 at 16:10verbatimcontent is indeed a problem here! – Jul 21 '16 at 16:14