etoolbox: AtBeginEnvironment is not At Begin Environment
The etoolbox
package redefines \begin
so that
\@beforebegin@<envname>@hook
is executed- a group is started
- the usual bookkeeping is performed (setting
\@currenvir
, for instance) \@begin@<envname>@hook
is executed- the macro
\<envname>
is executed
Thus what you get is
\@beforebegin@table@hook
\begingroup
<bookkeeping>
\@begin@table@hook
\table
The macro \table
is responsible for starting the creation of a float and expands to \@float{table}
.
Thus the tokens AtBeginEnvironment\par
and BeforeBeginEnvironment\par
are seen and the paragraphs are typeset before the float is started.
To the contrary, \end
is redefined to execute the \AtEndEnvironment
tokens before \end<envname>
is executed.
This should explain the output you get.
There is a hook for doing things when the float has already begun and is \@floatboxreset
.
I would be wary of using the hooks for adding text: they're meant for additional setup.