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 follws:
\documentclass[a4paper,10pt]{scrartcl}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\centering
\includegraphics[width=\textwidth,height=\textheight]{AnyGraphic}
\caption{Some random caption. This sholud be long enough to create at least one linebreak, 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 lenghts. I would thus prefer a solution that works for captions of arbitrary lengths