I am working on the sheets of a course on LaTeX and would like to have several sheets in which you see on the left an example of a source document and on the right its output. I have this working now with listings and minipage, but I also want a frame around the page of a fixed width and height.
what I have now is:
\documentclass{beamer}
\usepackage{listings}
\begin{document}
\begin{frame}[fragile]{The \LaTeX\ language}
% Source code:
\begin{columns}[T]
\column{0.45\textwidth}
\begin{center}
\LaTeX\ code:
%\begin{lrbox}\mylistingbox
\begin{minipage}[t][0.7\textheight]{\textwidth}
\begin{lstlisting}
An equation:
\[
1 + 1 = 2
\]
\end{lstlisting}
\end{minipage}
%\end{lrbox}
%\fbox{\usebox\mylistingbox}
\end{center}
% Output
\column{0.45\textwidth}
\begin{center}
Output:
\fbox{
\begin{minipage}[t][0.7\textheight]{1\textwidth}
An equation:
\[
1 + 1 = 2
\]
\end{minipage}}
\end{center}
\end{columns}
\end{frame}
\end{document}
This works, but only puts a frame around the right side (the output). If I try the same with \fbox{}
on the left side it does not work.
How can I put a frame around the minipage with the listiting?
Best Answer
While this does not address you specific question, I would highly recommend that you consider using the
showexpl
pacakge which makes use of thelistings
package. This eliminates the duplication of the LaTeX code, so it is not as error prone.To control the font use
basicstyle=...
to set it for the listings. The output font will be as per the rest of the document. If you want to adjust it just for the output ofLTXexample
you can usepreset=...
to specify commands to be executed before the sample code is typeset.