(I know there are already other questions about centering tables such as this. This question is specific to etoolbox.)
How do I center all tables using etoolbox? I can do
\documentclass[11pt]{article}
\makeatletter
\g@addto@macro{\table}{\centering}
\makeatother
\begin{document}
\begin{table}
\begin{tabular}{lr}
cat & 123 \\
\end{tabular}
\end{table}
\end{document}
and this works. But why not the following with etoolbox?
\documentclass[11pt]{article}
\usepackage{etoolbox}
\AtBeginEnvironment{table}{\centering}
\begin{document}
\begin{table}
\begin{tabular}{lr}
cat & 123 \\
\end{tabular}
\end{table}
\end{document}
\AtEndEnvironmentworks? At first glance, this seems very hackish. But, if it works is works. – Keith Prussing Jun 20 '19 at 03:23\AtEndEnvironment{table} {\centering\addvspace{\myGlue}} % not centered– Merchako Apr 29 '20 at 17:08