I'm completely puzzled by this: I'm trying to create a simple command that will modify a savebox from an enumerate, and I've worked it down to a minimal example of some weirdness:
...
% Create our command
\newcommand{\hello}{
\savebox{\tmp}{Works!}
}
% Setup the box
\newsavebox{\tmp}
\savebox{\tmp}{Doesn't work!}
\hello
\usebox{\tmp}
% Will put: Works!
If I run the command from inside an enumerate, it does not work:
% Create our command
\newcommand{\hello}{
\savebox{\tmp}{Works!}
}
% Setup the box
\newsavebox{\tmp}
\savebox{\tmp}{Doesn't work!}
\begin{enumerate}
\item
Something \hello
\end{enumerate}
\usebox{\tmp}
% Will put: Doesn't work!
I have absolutely no clue why it does this. No warnings or errors are given, and it does this on both pdfLatex and XeLaTex (the only two I had available to test). Any clues would be much appreciated!

enumeratecreates a local group that isolates the effect of\helloto within theenumerategroup. Therefore, duplicate?? https://tex.stackexchange.com/questions/283373/create-a-savebox-in-a-group-and-have-it-available-outside-of-group – Steven B. Segletes May 13 '19 at 16:52