I'm trying to set the font size smaller in the legends for all of my figures and tables. The way I was trying to do this was using \AtBeginEnvironment but that doesn't seem to do anything at all. This is a minimal example of what is failing:
\documentclass[a4paper, 12pt]{report}
\usepackage{etoolbox}
\usepackage{relsize}
\AtBeginEnvironment{figure}{\smaller}
\begin{document}
\begin{figure}
\caption{whatever}
Text
\end{figure}
Outside text
\end{document}
Now that should, I think, make 'Text' appear smaller than 'Outside text' exactly as it would if you put the \smaller
inside the figure environment. But it doesn't. I tried using the floatrow package instead but it messes up the ordering of the figure caption and the legend text and \captionsetup
will only alter the caption itself not the legend text.
Any help? Why does \AtBeginEnvironment
not work?
Best Answer
One of the last things the
figure
enviroment does is issuing the internal command\@floatboxreset
whose definition isand this is why the
\smaller
declaration has no effect, because the tokens in\AtBeginEnvironment
are found earlier.You should instead change the meaning of
\@floatboxreset
The change will not leak outside the environment.
In case you're using
setspace
, something more should be done, as the package patches\@xfloat
to issue again\normalsize
, which is an error, in my opinion, as\selectfont
would suffice.