这有效:
\documentclass{article}
\newsavebox{\mybox}
\begin{document}
\savebox{\mybox}\bgroup This is a test.\egroup\usebox{\mybox}
\end{document}
但这会失败(Missing } inserted.
在环境的开始和Extra }, or forgotten \endgroup.
结束时):
\documentclass{beamer}
\newsavebox{\mybox}
\begin{document}
\begin{frame}
\savebox{\mybox}\bgroup This is a test.\egroup\usebox{\mybox}
\end{frame}
\end{document}
注意我想要的是\bgroup
and \egroup
,而不是{
and }
,因为我正在尝试创建一个 savebox 环境:
\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}
- 为什么投影仪会失败?
\begin{foo}
我怎样才能让它工作(注意,如果/\end{foo}
可以在环境中,我的生活就会变得容易得多frame
,但目前,无论我移动环境,它仍然会失败,foo
当然已经删除了usebox
)?
答案1
有环境lrbox
:
\documentclass{beamer}
\newsavebox{\mybox}
\newenvironment{foo}{%
\begin{lrbox}{\mybox}%
}{%
\end{lrbox}%
\fbox{\scalebox{.1}{\usebox{\mybox}}}%
}
\begin{document}
\begin{frame}
\begin{lrbox}{\mybox}This is a test.\end{lrbox}%
\usebox{\mybox}
\begin{foo}This is a test.\end{foo}
\end{frame}
\end{document}