Showexpl package defines LTXexample environment which allows to define a latex code and shows its result side by side. The problem is that it uses the same documentclass where the latex code is defined and I would like to define which class to use for examples. Do you know if it's possible?
Here you have an examples. It's a beamer presentation with some LTXexamples.
\documentclass{beamer}
\usepackage{showexpl}
\lstloadlanguages{[LaTeX]Tex}
\lstset{%
basicstyle=\ttfamily\small,
commentstyle=\itshape\ttfamily\small,
showspaces=false,
showstringspaces=false,
breaklines=true,
breakautoindent=true,
captionpos=t
}
\begin{document}
\frame[containsverbatim]{
\frametitle{First slide}
\begin{LTXexample}
\begin{itemize}
\item a
\item b
\item c
\end{itemize}
\end{LTXexample}
\begin{LTXexample}
\begin{equation}
a^2+b^2=\sqrt{\frac{c^2}{1}}
\end{equation}
\end{LTXexample}
}
\frame[containsverbatim]{
\frametitle{Second slide}
\begin{LTXexample}
\documentclass{article}
\begin{document}
\section{Section 1}
Text for section 1
\end{document}
\end{LTXexample}
}
\end{document}
Second slide doesn't show 'section title' beacuse beamer has its own section behaviour, so it seems that \documentclass{article} inside the example doesn't have any effect. The resulting font is sansserif because beamer uses it.
I know I can use several external documents and insert code and results, but with LTXexample or a similar environment would be easier. Do you know a better solution?