I have a figure with a 3 line caption. I would like to insert the figure as tall as possible. If I use
\includegraphics[height=\textheight]{file}
The figure is as high as the textblock and the caption is at the footnote position.
Is it possible to set the height the figure, so the caption is aligned with the bottom of the textblock?
Best Answer
That is possible but it depends on many factors so that there is no single formula available that you can apply. It depends on
\abovecaptionskip
above the caption and\belowcaptionskip
below it\baselineskip
\parskip
But assuming the above is the situation then some calculations should get you to the right value:
and then use this value when including the graphics. For flexibility I placed it into a command so that you can vary the number of caption lines.
Note: If you want to have the base of the caption text align with the textblock you should either set
\belowcaptionskip
to zero (in which case we do not really need to substract it above) or explicitly back up after the caption by that amount in case you want to use it in other circumstances.In addition you have to add
\vspace{-\prevdepth}
below the caption because LaTeX turns the float into a box with the bottom line never being the baseline of the last line (i.e., the caption line in this case) so without this correction any character protruding below the baseline will shift the whole material upwards. This can't be included into the calculations because it depends on the material in the last caption line. It could be only added to the definition of the caption, e.g.,\@makecaption
in standard LaTeX.Here is an example, based on the definition from
book.cls
: