I have a custom environment called 'quiz' which puts its input into a savebox and then uses it later depending on a package option. The code works fine, unless I use an align* environment in which case I get 'Missing \endgroup inserted' errors.
Here's a minimum (non)-working example.
\documentclass{article}
% Load required packages
\usepackage{amsmath}
\usepackage{ifthen}
% Define new 'quiz' environment
\newsavebox{\quizbox}
\newlength{\quizheight}
\newboolean{showanswer}
\setboolean{showanswer}{true}
\newenvironment{quiz}{%
\begin{lrbox}{\quizbox}
}{%
\end{lrbox}
\ifthenelse{\boolean{showanswer}}{%
\usebox{\quizbox}
}{%
\settoheight{\quizheight}{\usebox{\quizbox}}
\fbox{\begin{minipage}[\quizheight]{\linewidth}%
Answer:\hspace{\linewidth}\\[1em]
\end{minipage}}
}
}
\begin{document}
\begin{quiz}
\begin{align*}
R_o = \int_{t=0}^{t_{max}} R(t)
\end{align*}
Test
\end{quiz}
\end{document}
Any thoughts?
align
in a\mbox
(and the same holds forlrbox
) unless you embed it in aminipage
.