[Tex/LaTex] Float too large also when less than textwidth

floatsmemoir

I have an image of size 112×196mm and LaTeX complains saying it is too large:

<figs/3d_ferro.pdf, id=1306, 318.18875pt x 559.08875pt> <use figs/3d_ferro.pdf>
LaTeX Warning: Float too large for page by 72.20679pt on input line 400.

I'm using memoir class with a4paper,twoside options and the output of

\the\textwidth
\the\textheight
\the\linewidth

is

398.33858pt

574.74557pt

398.33858pt

I don't understand why there is this warning since both the width and the height of my image are less than the page size.

Best Answer

The following calculates \textheight minus the size of the caption. I'm not sure why the 2pt fudge factor is needed (round off error?).

\documentclass{memoir}
\usepackage{mwe}
\begin{document}
\begin{figure}[p]
\sbox0{\parbox{\textwidth}{\null\caption{\blindtext}\null}}%
\includegraphics[width=\textwidth,height={\dimexpr\textheight-\ht0-\dp0-2pt}]{example-image}\par
\box0
\end{figure}
\end{document}