6

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 
\usepackage{setspace}
\setstretch{1.5}
\setlength{\parskip}{\baselineskip}
\usepackage{etoolbox}
\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.

\documentclass[twocolumn]{book}

% page layout settings with geometry 
\usepackage[papersize={240mm,300mm}
            ,hmargin={25mm}
            ,top={20mm}
            ,columnsep={10mm}
            ,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
\usepackage{caption}

% adjust all spacings to \baselineskip to align text paragraphs and floats 
\usepackage{setspace}
\setstretch{1.5}
\setlength{\parskip}{\baselineskip}
\usepackage{etoolbox}
\BeforeBeginEnvironment{figure}{\kern \baselineskip}

\begin{document}

\lipsum[4]    

\begin{figure}[tb]
  \centering
  \includegraphics[width=0.8\columnwidth]{castle}
  \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.}
\end{figure}

\lipsum

\end{document}
  • 3
    Welcome to TeX.SE, and thanks for providing a fully compilable MWE. – Peter Grill Apr 2 '13 at 18:55
  • What exactly is the problem? Obviously the text and floats are in different positions of you alter the dimensions of the text body, as it is optimized within the body. Are the lines supposed to illustrate the problem, as in the text is not on one line in the wrong example? – Mythio Apr 2 '13 at 19:16
  • Also note that, when using your example, if you increase the setstretch, i.e. use \setstretch{1.9}, the text is aligned fine again. The setstretch command has to match the new dimensions of the textbody...which i think is most easily done with trial and error. – Mythio Apr 2 '13 at 19:20
  • @Mythio: yes the problem is that the text alignment between the two columns is lost when I alter the text body. And I had not noticed that I can 'fix' it by altering the \setstretch{}, but for this example I also have to maintain a particular line spacing, so this also doesn't fully solve my problem. Also, what's the relation between the \setstretch and the float placement? – PGA99 Apr 2 '13 at 19:34
2

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.

  • Re your last sentence, specifically the grid and gridset packages might be helpful to the OP (though both have their quirks). – Aaron Apr 3 '13 at 2:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.