My objective is to create a new environment that encapsulates LTXexample environment.
Here is my minimal code:
Code: Select all
\documentclass{article}
\usepackage{showexpl}
\usepackage{lipsum}
\lstset{%
captionpos=b,
explpreset={pos=b}}
\newenvironment{ExampleWithAboveCaption}[1]
{%
\newcommand{\tempargs}{#1}%
\newsavebox{\ewac}%
\begin{lrbox}{\ewac}%
}%
{%
\end{lrbox}%
\begin{LTXexample}[aboveskip=3\fboxsep,caption={\tempargs}]%
\usebox{\ewac}%
\end{LTXexample}%
}%
\begin{document}
\begin{ExampleWithAboveCaption}{This is an example.}
\lipsum[1]
\end{ExampleWithAboveCaption}
\end{document}
Unfortunately it cannot be compiled successfully.
Any suggestion is appreciated.
Thank you in advance.