# How can I get rid of the LaTeX warning: Float too large for page?

In my document, I have figures that have a rather long caption. The code I use to include them looks like this:

\begin{figure}
\begin{center}
\includegraphics[width=\textwidth]{../fig.pdf}
\caption[Short caption]{Fairly long text...}
\end{center}
\end{figure}


For some of the figures, I keep getting warnings like this one:

LaTeX Warning: Float too large for page by 2.38557pt on input line 339.


I can't see anything wrong with the figures in the output document, but it makes the compilation output harder to read because it is full of such warnings.

What am I doing wrong, and how can I get rid of these warnings?

• I was struggling a lot with different solutions including playing with \vspace{-Xmm}. Until I came up with this solution that perfectly works for huge images/tables: stackoverflow.com/a/44439837/2961878 – Alisa Jun 8 '17 at 15:31

The warnings tell you that the float (figure and caption) are too long for staying in a page. You will get rid of many of those warnings if you avoid the center environment:

\begin{figure}
\centering
\includegraphics[width=\textwidth]{../fig.pdf}
\caption[Short caption]{Fairly long text...}
\end{figure}


(it should be avoided anyway, see Should I use center or centering for figures and tables?).

For pretty high figures you might also want to shorten their width, say 0.95\textwidth or less. LaTeX won't apply such a transformation for you: the warning simply tells that a float needs attention, but how to solve the problem depends on factors that only a human can evaluate properly.

• How could one suppress this warning but not change the page layout or the size of the figure? – lblb Apr 23 '18 at 14:38
• @lblb Why would you suppress the warning? – egreg Apr 23 '18 at 16:51
• @egreg: I get this warning myself and I just want to leave the offending figure exactly as it is. It's likely both too wide and too long for the page. To be clear I only want to suppress the one warning for the one figure, not all warnings of this kind. – lblb Apr 23 '18 at 20:29
• @lblb This mostly depend on the actual code and why you don't care about the excess height. – egreg Apr 23 '18 at 20:31
• @egreg: I found a solution for my case: tex.stackexchange.com/questions/404301/… \enlargethispage didn't work for the float page. – lblb Apr 23 '18 at 20:38

If the overfullness is not actually a problem: it worked for me to add \vspace{-Xpt} before the \end{figure}.

In my case the complaint was about an utterly inconsequential 0.04999pt and so I did not want to split the figure or do anything else to the input, just get the useless-in-this-case warning to go away.

• Great! I added the same \vspace{-Xpt} before the end of the table and it worked. I had a long table though, and I needed to use top and bottom margins. – Alisa May 19 '17 at 18:29
• This worked like a a charm! – Panos Kal. May 15 at 9:59

In case one has figures boxed (e.g. with the floatrow package) the \vspace solution disrupts the boxing (i.e. the box will cut the figure at \textheight). The problem can be fixed by extending the text area of the floatpage.

\makeatletter
\newenvironment{largefigure}[1][0pt]{
\clearpage % finish last page and flush previous floats
% save current textheight
\newlength{\@prevtextheight}\setlength{\@prevtextheight}{\textheight}
% extend textheight and recompute internal float parameters
\setlength{\textheight}{\textheight + #1}
\global\@colht\textheight % reset \@colht
\global\@colroom\textheight % reset \@colroom
\@floatplacement
% force float to appear at top of page
\setlength{\@fptop}{0pt}
\begin{figure}[!p]
}{
\end{figure}
\clearpage % flush the float
% restore textheight and all
\setlength{\textheight}{\@prevtextheight}
\global\@colht\textheight
\global\@colroom\textheight
\@floatplacement
\setlength{\@fptop}{0pt plus 1fill}
}
\makeatother


The solution to your problem then becomes:

\begin{largefigure}[3pt] % extend text area by 3pt
\cenetring
\includegraphics[width=\textwidth]{../fig.pdf}
\caption[Short caption]{Fairly long text...}
\end{largefigure}


In contrast to actually changing the dimensions of an offending image or float, which is too tall and/or too wide for the text area, I personally often work with carefully scaled graphics that only overshoot the margins by a few millimeters. I would employ these two techniques to silence these warnings gracefully:

\documentclass{article}

\usepackage{graphicx}
\usepackage[showframe]{geometry}

\begin{document}

% image too wide
\begin{figure}
\makebox[\textwidth][c]{% fix, centers image in textblock
\includegraphics[width=1.1\textwidth]{example-image}
}
\end{figure}

% image too tall
\begin{figure}
\includegraphics[height=1.1\textheight]{example-image-golden-upright}
\vspace{-60pt} % fix
\end{figure}

\end{document}


The first one handles bad box warnings and places the image inside a \makebox, which will here center the image on the text area no matter how wide it is. The second example deals with too high images: \enlargethispage doesn't work with float environments (see \enlargethispage command inside a float), so we need to insert a negive height at the end of the figure environment contents to fool LaTeX successfully.