# how to maximise a figure (float) size

Is it possible to maximise the size of the whole float (including the caption)? I would like the float to fit the maximum allowable size (both width and height) on the page (i.e. for binding). I have included an example, which makes the figure too large for the page and cuts off the caption. I also use a package from my university that sets the margin size, etc.

\documentclass{report}
\usepackage{mwe}
\usepackage{rotating}
\begin{document}

\begin{sidewaysfigure}[p]
\includegraphics[height=1\textheight,width=1\textwidth]{example-image-a}
\caption{long figure caption...long figure caption...
long figure caption...
long figure caption...
long figure caption...
long figure caption...
long figure caption...
long figure caption...
long figure caption...
long figure caption...
long figure caption...
long figure caption...
END OF CAPTION}
\label{fig:example}
\end{sidewaysfigure}

\end{document}


A simple solution, but it needs manual adjustment:

\documentclass{report}
\usepackage[showframe, % only for show page layout
margin=25mm]{geometry}
\usepackage{mwe}
\usepackage{rotating}

\begin{document}
\begin{sidewaysfigure}
\includegraphics[width=\textheight,% changed
height=\dimexpr\imageheight-2\baselineskip\relax% changed, number of \baselineskip adjust manulaly :-(
]{example-image-a}
\caption{long figure caption... long figure caption... long figure caption...
long figure caption...  long figure caption...  long figure caption...
long figure caption...  long figure caption...  long figure caption...
long figure caption...  long figure caption...  long figure caption...
END OF CAPTION}
\label{fig:example}
\end{sidewaysfigure}
\end{document}


Note: \textwidth doesn't work as expected. Therefore in preamble is defined new length and set to textwidth-\abovecaptionskip. Space, needed for caption is determined in graphics option by manually set number of caption lines in it calculation.

Addendum: In case of image in the portrait format, the code is simpler. You not need sidewaystable and therefore the height of image can be calculated in includegraphics options field:

\documentclass{report}
\usepackage[showframe, % only for show page layout
margin=25mm]{geometry}
\usepackage{mwe}
\usepackage{rotating}

\begin{document}
\begin{figure}[p]
\includegraphics[height=\dimexpr\textheight-3\baselineskip-\abovecaptionskip\relax,
width=\textwidth%
]{example-image-a}
\caption{long figure caption... long figure caption... long figure caption...
long figure caption...  long figure caption...  long figure caption...
long figure caption...  long figure caption...  long figure caption...
long figure caption...  long figure caption...  long figure caption...
END OF CAPTION}
\label{fig:example}
\end{figure}
\end{document}


• The new figure sizing works , thank you - and adjusts easily enough for additional caption lines. Is there an equivalent adjustment I can make to set the height for portrait figures? – BaiSmi Mar 30 '17 at 22:12
• @BaiSmi, you mean, that image is not in sidewaysfigure environment? If yes, the problem is simpler since you not need new length, i.e. image height and width you can determine directly: \includegraphics[width=\textwidtht, height=\dimexpr\textheight - 2\baselineskip -\abovecaptionskip\relax]{<image>}. Let me know, if this will not work (very unlikely ...) – Zarko Mar 30 '17 at 22:55