[Tex/LaTex] Figure and text vertical alignment in two column document

floatstwo-columnvertical alignment

I am trying to set a layout for a twocolumn book with a particular page layout (specified with the geometry package) and with the text in both columns aligned to each other. For this I've already adjusted the lengths of the spaces between paragraphs and before and after floats:

%%% adjust all spacings to \baselineskip to align text paragraphs and floats 
\BeforeBeginEnvironment{figure}{\kern \baselineskip}

and it works out fine for the standard page layout*:

enter image description here

However, once I alter the page layout, specifically the body text, with the geometry package it stops working.

enter image description here

Can somebody explain me why this happens and how I can fix it?

Here's the MWE.


% page layout settings with geometry 
            ,body={190mm, 220mm} % <- when textbody is changed, fig/float placement changes!
            ]{geometry} %,

\usepackage{lipsum}         % generates filler dummy text          
\usepackage[demo]{graphicx} % demo option replace images with black rectangles for testing purposes

% adjust all spacings to \baselineskip to align text paragraphs and floats 
\BeforeBeginEnvironment{figure}{\kern \baselineskip}



  \caption{This is a caption This is a caption This is a caption This is a cThis is a captionThis is a captionThis is a captionThis is a captionaption This is a caption.}



Best Answer

Looking at your example there is nothing to force alignment of lines of text to your grid, so while in one case the lines may have appeared closely aligned that was just luck.

If you want to align text to a grid then all vertical material placed must be a multiple of \baselineskip. You have set the lengths but the figure appears to be an arbitrary height, the image has whatever height it has when its width is scaled, and the caption appears to be set to a different font size, so the figure will not be a multiple of the main body \baselineskip. So text after the figure will be off the grid, and alignent with the following column will be lost.

One way to force the size of the figure would be to use a minipage with its optional height argument set to a multiple of \baselineskip, and put the \includegraphics and \caption inside that.

There are packages that aim to help with grid layout that probably automate some of the measuring needed.

Related Question