TransWikia.com

Extra vertical space between two paragraphs added by figure

TeX - LaTeX Asked by EuklidAlexandria on May 12, 2021

Compiling the following code

documentclass{article}

usepackage{lipsum}

begin{document}
lipsum[1] aaa aaa aaa aaa aaa aaa aaa aaa aaa  aaa aaa aaa aaa aaa aaa aaa
aaaa

lipsum[1]
end{document}

returns two paragraphs as expected.

No Vertical Space

But if a figure is placed after the first paragraph,

documentclass{article}

usepackage{lipsum}

begin{document}
lipsum[1] aaa aaa aaa aaa aaa aaa aaa aaa aaa  aaa aaa aaa aaa aaa aaa aaa
aaaa
begin{figure}
  caption{A}
end{figure}

lipsum[1]
end{document}

LaTeX inserts a vertical space between the two paragraphs.

Vertical Space

If a %-character is added at the end of the first paragraph or a blank line is added before the figure, the vertical space disappears and the ouptut matches the first one. This only seems to happen if the first paragraph ends in a full line.

Why does this happen and should therefore every float be preceded with a blank line?

One Answer

It is not really related to figure you see the same from here

documentclass{article}

usepackage{lipsum}

begin{document}
lipsum[1] aaa aaa aaa aaa aaa aaa aaa aaa aaa  aaa aaa aaa aaa aaa aaa aaa
aaaa mbox{}

lipsum[1]
end{document}

It is not actually vertical space, it is an extra all white line of the first paragraph (you can most easily see the difference if a page break occurs as this is a paragraph line it is not dropped at the top of a page, as vertical space would be.

The primitive end-of-paragraph process does one unskip to remove a space at the end of a paragraph which usually comes from the end of line, but you have space-emptybox-space so you end up with space-emptybox at the end, then you were unlucky and got a linebreak at the space, so leaving the box on its own.

Actually with figure you get a vadjust node not a box, but it has the same effect.

Correct answer by David Carlisle on May 12, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP