# Fit large image on one page with section title

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}
``````
-
Try something like `...height=.9\textheight,..` This shooting bildfolded as I don't know your picture dimensions. –  Harish Kumar Jun 13 '12 at 1:07
–  Martin Scharrer Jun 13 '12 at 8:53

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}
``````
-
`\bottomfraction` and `\textfraction` are for floats and not required here. The image seems not to be in a float and if it is then `[b!]` should do it, because it disables the fraction limits. –  Martin Scharrer Jun 13 '12 at 8:49
@Martinscharrer: I thought there was a possibility that the OP was using a float construct, so that's why I provided the extra code (about the page fractions). Of course, if no floats are involved, the case becomes much simpler. –  Mico Jun 13 '12 at 12:18
@Mico, \texttwidth should be \textwidth –  mangledorf Apr 13 '13 at 10:32
@mangledorf - Good eye! I've fixed the typo. –  Mico Apr 13 '13 at 17:10

You can use `\dimexpr` to subtract the space required for the section header. I guess 2 or 3 times the normal baseline skip should do it:

``````\includegraphics[width=\textwidth,height=\dimexpr\textheight-3\baselineskip\relax,keepaspectratio]{myfig.png}
``````

If you use an older LaTeX version which doesn't support e-TeX, or you don't like `\dimexpr`, then load the `calc` package and use `height=\textheight-3\baselineskip` directly.

-