[Tex/LaTex] Fit large image on one page with section title

graphicsscaling

I have a large image that needs to be scaled and put onto one page, which has a section title as well. The image should fill the maximum space avaiable.

I tried passing different arguments to the \includegraphics command, but it doesn't seem to work, because it doesn't take the section header into account.

I've tried different variations of

\includegraphics[width=\textwidth,height=\textheight,keepaspectratio]{myfig.png}
\includegraphics[width=\linewidth,height=\textheight,keepaspectratio]{myfig.png}
\includegraphics[page=1,width=\textwidth,height=\textheight,keepaspectratio]{myfig.png}

Best Answer

If you can be sure that the section header will always be at the top of the page, you could try executing the commands

\renewcommand\bottomfraction{0.9} % default value: 0.3
\renewcommand\textfraction{0.1}   % default value: 0.2

in the preamble and issuing a command such as

\includegraphics[height=0.8\textheight]{myfig.png}
% If the graphics file is not embedded in a LaTeX "float" environment such 
% as "table" or "figure", you may be able to set "height=0.9\textheight"

after the respective \section header. Depending on how much space the section header takes up, you may have to fiddle a bit with the height you assign to the graphics file, i.e., you may have to try 0.7\textheight or 0.75\textheight.

Addendum: The form of the \includegraphics command above assumes, implicitly, that the limiting element for the image size is its height, i.e., that even if the height is maximized the width will not exceed the \textwidth parameter. If this assumption is incorrect, i.e., if there's a chance that the image's width will exceed \textwidth when the image's height is maximized, you should use the following version of the command instead:

\includegraphics[height=0.8\textheight,width=\textwidth,keepaspectratio]{myfig.png}