This works:
\documentclass{article}
\newsavebox{\mybox}
\begin{document}
\savebox{\mybox}\bgroup This is a test.\egroup\usebox{\mybox}
\end{document}
But this fails (Missing } inserted. at the beginning of the environment and Extra }, or forgotten \endgroup. at the end):
\documentclass{beamer}
\newsavebox{\mybox}
\begin{document}
\begin{frame}
\savebox{\mybox}\bgroup This is a test.\egroup\usebox{\mybox}
\end{frame}
\end{document}
Note I want the \bgroup and \egroup, and not { and }, because I'm trying to create a savebox environment:
\documentclass{article}
\usepackage{graphicx}
\newsavebox{\mybox}
\newenvironment{foo}{%
\savebox{\mybox}\bgroup%
}{%
\egroup\fbox{\scalebox{0.1}{\usebox{\mybox}}}%
}
\begin{document}
\begin{foo}
This is a test.
\end{foo}
\end{document}
- Why does it fail with beamer?
- How can I make it work (note life's a whole lot easier for me if the
\begin{foo}/\end{foo}can be within aframeenvironment, but currently it still fails wherever I move thefooenvironment, having removed theuseboxof course)?
\mbox,\makebox,\fbox,\framebox,\sboxand\saveboxaccepts the contents enclosed in\bgroupand\egroup. They are ultimately based on\hbox, but they gather their (mandatory) argument as normal macros. – egreg Sep 08 '12 at 17:48\input{\jobname}, to get a scaled version of some/all slides on a (few) slide(s)). See my question (we have agreed that the best was to copy the pdf and\includegraphicsit, but I'm trying to do this without copying the pdf, just as a proof of concept since it's much more likely to break). – Suzanne Soy Sep 08 '12 at 17:49\documentclass{article}then? Just curious. – Suzanne Soy Sep 08 '12 at 17:50\documentclass\bgroup article\egroupraises an error. – egreg Sep 08 '12 at 17:53\documentclass{article}, the\newenvironment{foo}{\savebox{\mybox}\bgroup}{\egroup}works, but if I use\documentclass{beamer}it fails when used (see my two MWE). If the problem is that\saveboxdoesn't accept content enclosed in\bgroupandegrouplike you said, shouldn't it fail also in an article? – Suzanne Soy Sep 08 '12 at 17:59colorpackage, the accident 'working' (i.e. lack of error) is ended: you are seeing grouping in action! – Joseph Wright Sep 08 '12 at 18:07\mbox, but\mbox\bgroup a\egroupbecomes\leavevmode\hbox{\bgroup}a\egroup, so it's only a coincidence that it makes a box. – egreg Sep 08 '12 at 19:11