This is a follow-up question to Best figure size adjustment when dealing with different image sizes. I want to resize a figure in a way, that the figure including the caption fits the page. Resizing just the figure has been explained in the previously mentioned question. The solution looked as follows:
\documentclass[a4paper,10pt]{scrartcl} \usepackage{graphicx} \begin{document} \begin{figure} \centering \includegraphics[width=\textwidth,height=\textheight]{AnyGraphic} \caption{Some random caption. This should be long enough to create at least one line break, as the overall size of the float naturally depends on the size of the caption} \end{figure} \end{document} Without the caption, everything is fine. But including a caption will result in a Float too large for page warning.
Thus the question: How can I fit a float including the caption to a page?
Note: I want to do this for many floats with captions of different lengths. I would thus prefer a solution that works for captions of arbitrary lengths.