I have found that when saving and later using boxes the box with index 10 behaves differently to all other.
Here is simple demo that shows different behaviour. In preamble I define this commands:
\usepackage{forloop}
\newcounter{BoxCount}
\newcommand{\numberedBox}[1]{%
\stepcounter{BoxCount}%
\savebox{\theBoxCount}{\vbox{\noindent\theBoxCount\\~ #1}}%
}%
\newcommand{\writeBoxes}{
\stepcounter{BoxCount}%
\newcounter{I}%
\setcounter{I}{1}%
\forloop{I}{1}{\value{I} < \value{BoxCount}}{%
\usebox{\theI}\par
}%
The \numbredBox basically stores given text in indexed box while adding number of the box to the text. The \writeBoxes prints all stored boxes in order they were stored.
In document body I have this code:
\numberedBox{word}
\numberedBox{word}
\numberedBox{word}
\numberedBox{word}
\numberedBox{word}
\numberedBox{word}
\numberedBox{word}
\numberedBox{word}
\numberedBox{word}
\numberedBox{word}
\numberedBox{word}
\numberedBox{word}
\numberedBox{word}
\writeBoxes
This is printed output of this document:
All the boxes are printed as expected except for 10th box which somehow interfere with box 11. I have played with similar code a little and found out that 10th saved almost always box behaves strange. In some cases I even got ! Incompatible list can't be unboxed error but only for 10th saved box (content of all the boxes was equal).
Why is this happening? How can I avoid it?
EDIT
Here is complete source of this example that Hebert asked for. Just compile with pdfLaTeX and you will get output shown above.
\documentclass[a5paper]{book}
\usepackage{forloop}
\newcounter{BoxCount}
\newcommand{\numberedBox}[1]{%
\stepcounter{BoxCount}%
\savebox{\theBoxCount}{\vbox{\noindent\theBoxCount\\~ #1}}%
}%
\newcommand{\writeBoxes}{
\stepcounter{BoxCount}%
\newcounter{I}%
\setcounter{I}{1}%
\forloop{I}{1}{\value{I} < \value{BoxCount}}{%
\usebox{\theI}\par
}%
}
\begin{document}
\numberedBox{word}
\numberedBox{word}
\numberedBox{word}
\numberedBox{word}
\numberedBox{word}
\numberedBox{word}
\numberedBox{word}
\numberedBox{word}
\numberedBox{word}
\numberedBox{word}
\numberedBox{word}
\numberedBox{word}
\writeBoxes
\end{document}


\newsavebox. Also, if add a\tracingassigns=1, or just\showbox11, you will see that\box11is not void when you define it, so it is being used by something else. – Andrew Swann Jan 15 at 12:38