1

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}
1

A simple solution, but it needs manual adjustment:

enter image description here

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

\newlength{\imageheight}% added
\setlength\imageheight{\dimexpr\textwidth-\abovecaptionskip}% added
\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}

enter image description here

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.