2

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?

1 Answer 1

1

Edit after OPs edit:

This should work in this case:

\documentclass{beamer}

\newcommand{\Lspacer}{\columns[t]\column{.02\textwidth}\column{0.96\textwidth}}
\newcommand{\Rspacer}{\column{.02\textwidth}\endcolumns}

\let\olddocument\document
\let\oldenddocument\enddocument

\renewenvironment{document}%
  {\olddocument\begin{frame}[t]\vfill\par%
    \Lspacer%
    }
  {\Rspacer%
    \vfill\end{frame}\oldenddocument
    }

\begin{document}

Cogito ergo sum.

\end{document}

Old answer:

You could try this way in this case:

\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}

Your problem is possibly that there are more commands using the \AtEndDocument inside beamer class and thus they the order of the frame environment \begin and \end commands is not the expected.

5
  • Thanks @koleygr, it works as it is. However, when I want to add a further environment it crashes again. Please, kindly see my update.
    – lfba
    Commented Sep 25, 2019 at 23:38
  • 1
    @Ifba I have edited ... but not really sure about what you want to do with your commands there on the post...
    – koleygr
    Commented Sep 26, 2019 at 5:56
  • 1
    Fair question, @koleygr. I'm making a template for a beamerposter and I don't want to explicitly write the beginning of frame and columns environment, nor of the spacer first and last columns. I gave a very minimal example (perhaps too minimal) that omits the beamerposter package, but I already tested your answer and it works well with it. Thanks again for the answer, and for your patience.
    – lfba
    Commented Sep 26, 2019 at 22:05
  • 1
    @lfba happy TeXing ... No patience at all, just asked in order to help more if I would ffind out that more things would be useful for you there and because the way you edited I could not be sure if you want to have the "\spacers" across the title or the whole frame.
    – koleygr
    Commented Sep 27, 2019 at 9:22
  • Thanks @koleygr. It's just that I often don't give the proper context to all my questions and, hence, my questions are often not easy to answer. But I'm doing my best to learn. Thanks again.
    – lfba
    Commented Sep 27, 2019 at 19:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .