I am making a beamer
-document that is basically a one-page frame. Since don't want to explicitly call the frame inside the environment, I how \begin{frame}[t]
at the beginning of the document and \end{frame}
at the end (plus two \vfill
commands). This is the code:
\documentclass{beamer}
\AtBeginDocument{\begin{frame}[t]\vfill}
\AtEndDocument{\vfill\end{frame}}
\begin{document}
Cogito ergo sum.
\end{document}
Which returns the following error message:
File ended while scanning use of \beamer@collect@@body.
And here is the log file.
This, I suppose, means that I cannot hook environments to the document
environment in this way. What would be the right way to do it? Is there a general way to do so for any environment? (That is, not only for frame
.)
Thanks in advance for the help.
UPDATE:
Thanks to @koleygr I could use the following code:
\documentclass{beamer}
\let\olddocument\document
\let\oldenddocument\enddocument
\renewenvironment{document}{\olddocument\begin{frame}[t]\vfill}
{\vfill\end{frame}\oldenddocument}
\begin{document}
Cogito ergo sum.
\end{document}
However, it doesn't work very well when I add another environment as follows:
\newcommand{\spacer}{\begin{column}{.02\textwidth}\end{column}}
\let\olddocument\document
\let\oldenddocument\enddocument
\renewenvironment{document}%
{\olddocument\begin{frame}[t]\vfill%
\begin{columns}[t]\spacer}
{\spacer\end{columns}%
\vfill\end{frame}\oldenddocument}
\begin{document}
Cogito ergo sum.
\end{document}
This returns the following error message:
File ended while scanning use of \frame.
And here is the log file.
How should I deal with this? Should I define some commands \oldolddocument
and \oldoldenddocument
for storing the recently redefined document
environment or is there a more straightforward solution?