Graphics, Figures & TablesIncluding caption height in determining size of image

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
rspringuel
Posts: 19
Joined: Wed Apr 28, 2010 7:16 pm

Including caption height in determining size of image

Post by rspringuel »

I have some photos that I'm including in a book I'm writing which I want to display as full page images (on custom sized pages). I'd like the following parameters to be applied to the way the image displays:
  1. If the photo is landscape oriented, then it, and its caption, should be rotated 90 degrees to take full advantage of the page (currently I accomplish this using the {sidewaysfigure} environment from the rotating package for such images).
  2. The header (and footer, but that's normally empty anyway) should be suppressed on pages containing a full page image (currently I accomplish this using the \iffloatpage command from the fancyhdr package in my header definitions).
  3. No captions should be numbered (currently I accomplish this by using the \caption* command from the caption package).
  4. The image and its caption should be sized to take up all available space on the page, include that normally allotted to the header and the footer but not the margins.
It's just this last parameter which is giving me problems at the moment (I've included the others to prevent any proposed fixes to the last from breaking the others). My thought was to define a new length (\fullfigheight) which was \textheight+\headheight+\headsep+\footskip and use this as the height of the image. This resulted in two problems:
  1. The top of the figure is placed at the top of the text field, not the top of the header field (surrounding the \includegraphics command with a \centerline command seems to solve this)
  2. The figure, especially when the caption is included, is too wide for the page
I've tried simply adding "height=\textwidth,keepaspectratio" to the optional arguments for the \includegraphics command, but that doesn't help because that doesn't take into account the room taken up by the caption. As a result the figure "bleeds" into the margins.

What I'd like to do is have the image be scaled so that it uses the full print height (text + header + footer) where possible, but scales the image down when necessary (and only as much as is necessary) to make both the image and the caption fit within the horizontal margins. Ideally, this should happen automatically and should play well with changes to the custom page layout parameters (as these might change).

I've attached a MWE (and a sample image) that shows the results of what I've tried.
Attachments
Sample image with the same aspect ratio as the photo I'm trying to include.
Sample image with the same aspect ratio as the photo I'm trying to include.
Image.jpg (109.23 KiB) Viewed 3895 times
Scratch.tex
MWE
(1.72 KiB) Downloaded 354 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Post Reply