# Beamer error driving me nuts

OK, I've been staring at this for an hour. I know there's an error in this frame, as the document compiles fine if I put \end{document} in the frame before this. But this frame gives an error about extra } or missing endgroup.

Where is it?????

\begin{frame}[fragile]
\frametitle{PROC TEMPLATE for a fancy graph (part 1)}
\begin{alltt}
proc template;
define statgraph scatdens2;
begingraph;   *BEGIN DEFINING THE GRAPH;
entrytitle "Scatter plot with density plots";
*CREATE A TITLE;
layout lattice/columns = 2 rows = 2
columnweights = (.8 .2) rowweights = (.8 .2)
columndatarange = union rowdatarange = union;
*LAYOUT LATTICE...SETS UP A GRID OF GRAPHS;
*COLUMNWEIGHTS AND ROWWEIGHTS SETS
THE RELATIVE SIZE OF THE INDIVIDUAL COLUMNS AND ROWS;
\end{alltt}
\end{frame}

-
 Don't put greetings and a signature, as the latter is automatically inserted. For the code, indent each line by four spaces. – egreg May 9 '11 at 21:11 Try removing the space before \end{frame} (assuming that this is real and not an artefact from posting here) – Joseph Wright♦ May 9 '11 at 21:11

Believe it or not, the error was caused by the space before \end{frame}.
Oh, I believe you. frame is a pseudo-environment, i.e. a macro in disguise which collects everything till \end{frame}. With the fragile option it turns on verbatim mode in addition and then looks for the <new line>\end{frame} verbatim. With the space it doesn't find it and therefore takes everything until the end of the document where an error is raised, except of course if there is such a line later in the document. – Martin Scharrer May 9 '11 at 21:25