# Why I can't use \footnote inside \vbox or \hbox in horizontal mode?

The definition of \footnote is as follows in plain TeX

% all from the Appendix B of The TeXbook
\newinsert\footins
\def\footnote#1{\let\@sf=\empty % parameter #2 (the text) is read later
\ifhmode\edef\@sf{\spacefactor=\the\spacefactor}\/\fi
#1\@sf\vfootnote{#1}}

\def\vfootnote#1{\insert\footins\bgroup ... \futurelet\next\fo@t}


All the inserted footnotes will be in \box\footins, but we are in a \vbox

\vbox{footnote\footnote*{you are reading a footnote}}


the footnote text will not be at the bottom of the current page.

% now we are in vertical mode when encountering the \hbox
\hbox{insert footnote.\footnote*{this is ok.}}


this is ok

another

% after have entered the horizontal mode
the first paragraph \hbox{an hbox.\footnote*{a footnote}}


this also upset me.

Now the question is that why we can't use footnotes macro when we are in an vbox or an hbox in the horizontal mode, even boxes inside boxes? Is the reason that when we enter a box, we will enter a group at the same time?

-
It is not the grouping it is the box level. \footnote puts an insert node into the current list. When the page breaker splits up the main vertical list to make a page, it hands the part of the main vertical list to be used in box255 to the output routine and it hands all the footnote texts related to inserts in that list to the output routine in box footins. Insert nodes that are not on the main vertical list have no effect.
Wonderful! I have read the \output={\plainoutput}, but not aware of this. –  Timothy Li Apr 1 '13 at 12:11
@TimLi yes you can save it as part of the contents of any box register and then if you unbox the contents the node will be added to the current list so may end up in \box\footins in the output routine. –  David Carlisle Apr 1 '13 at 13:37