Page LayoutExtra Spacing below Figures placed at Top of Page

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
jaykemper
Posts: 22
Joined: Wed Apr 15, 2009 12:11 am

Extra Spacing below Figures placed at Top of Page

Post by jaykemper »

I noticed that when a figure doesn't have enough space below it, it pushes the figure to the next page and fills in text that was entered after it. I completely under stand the reasoning for that, however, there is more space below the figure caption of the pushed back figure than there is if it were where it had been placed in code.

MWE:

Code: Select all

\documentclass{article}
\usepackage{graphicx}
\usepackage{lipsum}

\begin{document}
  \lipsum[2]

  \begin{figure}[!ht]
    \centering
    \fbox{\includegraphics[height=2in]{authors-quill}}
    \caption{Compare the space below here...}
  \end{figure}

  \lipsum[1]

  Figure code is between these two paragraphs.

  \begin{figure}[!ht]
    \centering
    \fbox{\includegraphics[height=2in]{authors-quill}}
    \caption{to the space below here.}
  \end{figure}

  \lipsum[5-6]
\end{document}
Is there a way to make those the same distance? What lengths are being used here?
Attachments
text.pdf
(22.93 KiB) Downloaded 381 times

Recommended reading 2024:

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

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

User avatar
tom
Posts: 73
Joined: Thu Apr 18, 2013 4:02 am

Extra Spacing below Figures placed at Top of Page

Post by tom »

You see different vertical spaces because the first figure is situated between two paragraphs, whereas the second is placed within a paragraph. This means that two different lengths are used, \intextsep (default 12pt) and \textfloatsep (default 20pt). I have to admit, I find the names somewhat misleading. If you prefer equal spacing, add these two lines to your preamble:

Code: Select all

\setlength{\intextsep}{12pt}
\setlength{\textfloatsep}{12pt}
Take a look at the layouts package manual (chapter 6) for more details.

Btw. there is nothing in the attached PDF.
jaykemper
Posts: 22
Joined: Wed Apr 15, 2009 12:11 am

Re: Extra Spacing below Figures placed at Top of Page

Post by jaykemper »

Great, I knew there were some lengths being used there, I just had no idea what they were.

For reference, I attached the PDF output.
Attachments
test.pdf
(28.17 KiB) Downloaded 290 times
Post Reply