I tried the following MWE:
\documentclass{article}
\usepackage{etoolbox}
\AtBeginEnvironment{table}{AtBeginEnvironment\par}
\AtEndEnvironment{table}{AtEndEnvironment\par}
\BeforeBeginEnvironment{table}{BeforeBeginEnvironment\par}
\AfterEndEnvironment{table}{AfterEndEnvironment\par}
\begin{document}
Text before\par
\begin{table} [t]%
Table text\par
\end{table}
Text after\par
\end{document}
and got the following result:
Table text
AtEndEnvironment
Text before
BeforeBeginEnvironment
AtBeginEnvironment
AfterEndEnvironment
Text after
I was expecting AtBeginEnvironment to travel to the top of the page together with the float. Here is what the manual has to say on the matter:
\AtBeginEnvironment{<environment>}{<code>}
Appends arbitrary <code> to a hook executed by the \begin command
at the beginning of a given <environment>, immediately before
\<environment>, inside the group opened by \begin.
I do not know what happens inside an environment definition; I guess it declares some special commands called \<environment> (e.g. \table) and \end<environment> (e.g. \endtable).
But in this case, shouldn't it be immediately after \<environment>, in order to be a complement to \AtEndEnvironment just as \BeforeBeginEnvironment is a complement to \AfterEndEnvironment?
Anyway, how can I add code to the beginning of an environment? I'm trying to set a certain font style for all tables, and \AtBeginEnvironment{table}{\small} does not work. Also I guess this behavior makes this answer incorrect, because \addvspace would stay at the point of declaration of the figure instead of moving together with it.