I'm typesetting a scientific book with a lot of sections, tables, figures and equations. The book is in two columns. My client asked me to ensure baselines of the text in both columns are aligned vertically no matter the floats, equations or section headings. I searched around a bit and it seems more complicated than I have anticipated. The questions I found are either pretty old and don't present a solution, or too specific for my cause.

My question thus is: Is it possible to set a two column document with LuaLaTeX in such a way that the baselines in both the columns will be on the same vertical place no matter what other elements are in the columns?

The document is very long so the more automated (global) this could be, the better. So far the only thing I was able to think of was manually setting vertical spaces around the headings and floats which is obviously not possible with source code of some 1.7M characters.

I'm adding an MWE with all the settings and packages I have in the actual document (even though they're mostly irrelevant for this MWE).

\usepackage[paperheight=280mm,paperwidth=205mm,top=26mm,bottom=26mm,margin=20mm]{geometry} % remove heightrounded from the parameters
\usepackage{nameref} % Defines a \nameref command, that makes reference to an object by its name (e.g., the title of a section or chapter)
\usepackage{multirow} % Make an entry that will span multiple rows of a table.
\usepackage{array} % An extended implementation of the array and tabular environments which extends the options for column formats (e.g. padding)
\usepackage{gensymb} % Provides generic commands \degree, \celsius, \perthousand, \micro and \ohm which work both in text and maths mode
\usepackage{amsmath} % so we can use multiline equations with equation* or align* environments (uses multline env.)
\usepackage{fancyhdr} % Allows us to set nice headers
\usepackage{tabularx} % Autofit columns to text width
\usepackage[newcommands]{ragged2e} % hyphenation inside table cells - https://tex.stackexchange.com/questions/16842/auto-fit-table-column-widths-based-on-content/16867
\usepackage{lscape} % landscape certain pages
\usepackage{url} % print URLs nicely
\usepackage{wrapfig} % text flow around images
\usepackage{placeins} % force a float to be in the exact place where we say when it's wrapped surrounded by \FloatBarrier
\usepackage{siunitx} % typeset units properly -- we won't use this because the typesetting is problematic for the sed script to replace: \SI{1.55}{\micro\metre}
\usepackage{caption} % figure/tables tweaking
\usepackage{upgreek} % typeset greek letters straight (not italics) outside of math env (we need to do some hardcore regexing to replace this only outside of math env)
\usepackage{xfrac} % this enables us to use the small diagonal fractions with \sfrac{num}{denum} (in math mode)
\usepackage{dblfloatfix} % redefines latex core to enable images in twocolumn layout "be placed in the right order and introduces position [tbp]"
\usepackage{cuted} % this enables us to use env. strip (for quotes at the chapter beginning)
\usepackage{epigraph} % package for the quotes we have at the beginning of each chapter;; not used right now
\usepackage{microtype} % microtypography to adjust the subtle stuff normal mortals don't see (not even me actually)
\usepackage[dvipsnames]{xcolor} % allows to use colors in the document, dvipsnames allows more names of the colors than the basic package setting
\usepackage{makecell} % create cell boxes inside table cells to be able to wrap text inside them
\usepackage{enumitem} % This package provides user control over the layout of enumerate, itemize and description. (e.g. for changing numbering style)
\usepackage{extarrows} % package allowing variable arrows in the document, e.g. \xrightarrow[{}]{} . Details here: http://www.sascha-frank.com/Arrow/latex-arrows.html
\usepackage{sectsty} % allow coloring the chapter/section headings (colors, alignment, ...)
\usepackage{changepage} % set different margins for a part of the document (adjustwidth env.)

% This should ensure we won't have large gaps between paragraph where there's no way to fit some other text into the page. But the price will be inconsistent page-content height


\chapterfont{\color{hbuGreen}\raggedright}  % sets colour of chapters
\sectionfont{\color{hbuGreen}\raggedright}  % sets colour of sections
\subsectionfont{\color{hbuGreen}\raggedright}  % sets colour of subsections

% setup the capion (figure, table) style
    font=footnotesize, % smaller font for all captions
    justification=raggedright, % left align all captions
    singlelinecheck=false, % disable the automatic latex captions centering

    output-decimal-marker = {,},
    group-separator = {\:},
} % tell siunitx to use comma as a decimal separator, not dot

% Here is a macro \shifttext{<len>}{<stuff>} that shifts <stuff> by <len> (negative for left, positive for right)

% Code to change the \paragraph{} definition
    {3.25ex \@plus1ex \@minus.2ex}%
    % {-1em}%

\parskip 0pt

\graphicspath{ {lipsum-imgs/} }


% paragraph and equation indentation


\renewcommand{\arraystretch}{1.2} % set vertical padding for tables
\setlength{\tabcolsep}{2pt} % set horizontal padding for tables



% introduce style for narrower/wider text (use \spacedstyle{+-N} where + is wider, - is narrower)

% two new columns for tabularx, equivalents for X with different alignment - Y: center, Z: right


% \setlist{topsep=3pt,partopsep=3pt,itemsep=1pt}

\makeatletter \renewcommand{\@epirule}{\vspace{-1.5em}\begin{flushright}\rule[.5ex]{0.4\textwidth}{\epigraphrule}
                        \vspace{0.5em}\end{flushright}} \makeatother

% using german quotes as they're the same as Czech: https://tex.stackexchange.com/a/268523/92041

    \chapter{Lorem ipsum} % (fold)
         Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed iaculis condimentum odio at sollicitudin. Donec semper luctus odio, a elementum ex finibus tempus. Pellentesque sagittis, dolor sit amet mollis molestie, tortor lorem posuere lorem, nec interdum leo risus eget urna. Nunc suscipit orci quis sem aliquet tincidunt. Donec ac eros neque. Vestibulum metus magna, vehicula id accumsan in, porttitor nec velit. Etiam a rhoncus metus. Praesent nec sem tortor. Donec egestas mi at odio dapibus, a feugiat libero efficitur. Vestibulum dictum, dui sit amet imperdiet fermentum, risus erat iaculis velit, vel dapibus sem libero a lorem. Pellentesque sed tellus non nisl volutpat placerat eget ut tortor. Aenean et eros est. Vivamus nec finibus quam, et porta ipsum. Nullam posuere convallis est, at congue erat tempus quis. Curabitur dictum eros in elit varius volutpat.

        Ut egestas facilisis ligula, non ultrices dolor sagittis eget. Nunc euismod, quam et efficitur luctus, urna ex convallis est, at vehicula enim sem at nisi. Vivamus ultrices iaculis ipsum, id tincidunt erat maximus sit amet. Nam sollicitudin neque sed lectus vulputate fermentum. Nam et sem pharetra diam venenatis pellentesque nec in lectus. Integer efficitur nunc in faucibus gravida. Sed hendrerit vulputate nulla eu vestibulum. Suspendisse tincidunt, dui eget mollis tristique, metus ipsum aliquet lectus, sit amet mattis orci elit nec mauris. 

                \caption{Suspendisse pulvinar risus quis urna scelerisque iaculis. Nulla consequat erat ligula.}

        \section{Dolor sit amet} % (fold)
             Duis nec vehicula ipsum, iaculis auctor nisi. Curabitur lacinia id eros et scelerisque. Nunc a sapien ac nisl finibus tincidunt ac aliquam erat. Sed ac varius mi. Proin vitae tincidunt tellus. Suspendisse euismod quam ac ante vestibulum, in eleifend ex molestie. Cras vel libero sapien. Nulla sodales, odio ac egestas ultrices, libero urna luctus sem, et laoreet lorem mi vitae tortor.

            Vivamus consequat sem felis, nec sagittis nisl eleifend ac. Nulla facilisi. Suspendisse pulvinar risus quis urna scelerisque iaculis. Nulla consequat erat ligula. Etiam vitae semper nisl. Curabitur euismod, est hendrerit finibus vestibulum, turpis nisl semper nisi, vel vulputate ligula est vitae ante. Integer ultricies accumsan ante. Aliquam auctor volutpat dictum. Aliquam eget iaculis sapien. Etiam rhoncus dignissim ex quis accumsan. 

                E=m\cdot c^2

                \caption{Proin vitae tincidunt tellus. Suspendisse euismod quam ac ante vestibulum, in eleifend ex molestie. Cras vel libero sapien. Nulla sodales, odio ac egestas ultrices, libero urna luctus sem, et laoreet lorem mi vitae tortor.}

             Suspendisse convallis nisl vel viverra gravida. Suspendisse sem mauris, tincidunt at pretium id, venenatis ut ligula. Proin luctus, orci in mollis feugiat, sapien ipsum pharetra sem, at consequat lorem neque at lacus. Nullam euismod enim condimentum odio mattis pulvinar. Quisque nec massa consectetur, iaculis metus laoreet, fermentum erat. Pellentesque sodales porttitor efficitur. Sed sed sollicitudin lacus. Integer tincidunt ipsum id urna imperdiet ornare. Integer leo risus, rhoncus et semper a, imperdiet in magna. Duis sagittis ipsum nec mauris ullamcorper, at porttitor sem molestie. 

             \subsection{Consectetur} % (fold)

                 Proin tempus, lorem id malesuada auctor, lorem arcu suscipit velit, id consectetur tellus tortor nec eros. Interdum et malesuada fames ac ante ipsum primis in faucibus. Donec non euismod urna. Aenean sit amet pellentesque magna. Aliquam consectetur, dui id lacinia tempor, leo diam laoreet orci, sed fringilla lorem diam ac ex.

                 Praesent ullamcorper mi id orci tempus eleifend. Phasellus quis purus ex. Praesent at elit ligula. Aliquam nec tellus a est accumsan tempus id eget sem. Morbi vehicula posuere urna non viverra. Aenean suscipit vulputate lorem sed mollis. Morbi luctus augue ac odio aliquam, a hendrerit ante finibus. Phasellus mauris ipsum, lacinia non congue mattis, egestas vitae augue. Aenean erat nunc, vestibulum quis lectus a, suscipit vestibulum mi. Donec commodo tristique ante, sed mollis elit porta at. In placerat cursus egestas. 

                    \caption{Suspendisse pulvinar risus quis urna scelerisque iaculis. Nulla consequat erat ligula.}

                 Integer sit amet velit pharetra, fermentum dui sit amet, posuere magna. Vivamus ut sem elit. In interdum sit amet mauris eu bibendum. Morbi eu felis interdum, egestas ipsum eget, mattis metus. Suspendisse consequat nulla ultrices elit consequat dictum. Quisque interdum eros a nisi viverra scelerisque. Sed fermentum, arcu ut porta aliquet, lorem eros scelerisque dolor, eu blandit quam lectus ut nisi. 

             % subsection consectetur (end)
        % section sit_dolor_amet (end)

        \section{Vestibulum sodales} % (fold)

             Vestibulum sodales eu risus et lacinia. Maecenas feugiat lorem dignissim, pulvinar augue nec, maximus mi. Praesent ut metus nisl. Sed sem nisl, blandit quis malesuada vel, posuere id risus. Sed quis justo vitae eros gravida cursus vel in felis. Ut est lacus, cursus vel ultrices eu, volutpat in ipsum. Vivamus facilisis ipsum at nulla convallis, ut volutpat ante euismod. Fusce nisl nisi, maximus nec faucibus vel, aliquet in turpis. Ut semper, sapien et porttitor tempus, nisi magna sollicitudin eros, finibus sagittis diam elit quis diam. Proin sed metus nec enim pulvinar pretium a at urna. Donec magna erat, lobortis a elementum eget, congue id felis. Morbi nisl turpis, mollis eget dui eu, fringilla convallis lectus. Fusce at mauris bibendum, posuere risus vel, fermentum sem. Cras efficitur malesuada odio vitae suscipit. Pellentesque fringilla, sem eget molestie malesuada, velit purus faucibus lectus, eu fringilla nibh augue ac augue:
                S=v\cdot t\;,
              integer condimentum nibh odio, non malesuada ex fermentum et. Fusce et tincidunt enim, nec commodo ex. Nulla facilisi. In purus nibh, ultricies eu nibh in, laoreet tempus tortor. Praesent a lorem viverra, faucibus sem at, finibus risus. Donec ornare purus.

        % section vestibulum_sodales (end)
    % chapter lorem_ipsum (end)

enter image description here

As you can see, the baselines get misaligned immediately after the image, section heading, etc. The goal of this question is to keep them aligned at all times (ie. changing the spacing around the floats, headings, etc. I would guess).

  • My LuaLaTeX version is: This is LuaTeX, Version 1.0.4 (TeX Live 2017/Debian) (installed from default Ubuntu repositories)
  • My OS: Ubuntu 18.04 - $ uname -srvpio Linux 4.15.0-76-generic #86-Ubuntu SMP Fri Jan 17 17:24:28 UTC 2020 x86_64 x86_64 GNU/Linux

And here are versions of the packages I include in the file (added \listfiles into the source to get this):

*File List*
    book.cls    2014/09/29 v1.4h Standard LaTeX document class
   fleqn.clo    2016/12/29 v1.2a Standard LaTeX option (flush left equations)
    bk10.clo    2014/09/29 v1.4h Standard LaTeX file (size option)
geometry.sty    2010/09/12 v5.6 Page Geometry
  keyval.sty    2014/10/28 v1.15 key=value parser (DPC)
   ifpdf.sty    2017/03/15 v3.2 Provides the ifpdf switch
  ifvtex.sty    2016/05/16 v1.6 Detect VTeX and its facilities (HO)
 ifxetex.sty    2010/09/12 v0.6 Provides ifxetex conditional
 lmodern.sty    2009/10/30 v1.6 Latin Modern Fonts
   babel.sty    2018/02/14 3.18 The Babel package
   greek.ldf    2016/09/07 v1.9g Greek support for the babel system
  lgrenc.def    2015/12/07 v0.13.1 LGR Greek font encoding definitions
greek-fontenc.def    2015/08/04 v0.13 Common Greek font encoding definitions
 english.ldf    2017/06/06 v3.3r English support from the babel system
   czech.ldf    2008/07/06 v3.1a Czech support from the babel system
csquotes.sty    2018/02/11 v5.2c context-sensitive quotations (JAW)
etoolbox.sty    2018/02/11 v2.5e e-TeX tools for LaTeX (JAW)
csquotes.def    2018/02/11 v5.2c csquotes generic definitions (JAW)
     url.sty    2013/09/16  ver 3.4  Verb mode for urls, etc.
graphicx.sty    2017/06/01 v1.1a Enhanced LaTeX Graphics (DPC,SPQR)
graphics.sty    2017/06/25 v1.2c Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    2016/01/03 v1.10 sin cos tan (DPC)
graphics.cfg    2016/06/04 v1.11 sample graphics configuration
  luatex.def    2018/01/08 v1.0l Graphics/color driver for luatex
setspace.sty    2011/12/19 v6.7a set line spacing
 nameref.sty    2016/05/21 v2.44 Cross-referencing by name of section
refcount.sty    2016/05/16 v3.5 Data extraction from label references (HO)
 ltxcmds.sty    2016/05/16 v1.23 LaTeX kernel commands for general use (HO)
infwarerr.sty    2016/05/16 v1.4 Providing info/warning/error messages (HO)
gettitlestring.sty    2016/05/16 v1.5 Cleanup title references (HO)
kvoptions.sty    2016/05/16 v3.12 Key value format for package options (HO)
kvsetkeys.sty    2016/05/16 v1.17 Key value parser (HO)
etexcmds.sty    2016/05/16 v1.6 Avoid name clashes with e-TeX commands (HO)
ifluatex.sty    2016/05/16 v1.4 Provides the ifluatex switch (HO)
multirow.sty    2016/11/25 v2.2 Span multiple rows of a table
   array.sty    2016/10/06 v2.4d Tabular extension package (FMi)
 gensymb.sty    2003/07/02 v1.0 (WaS)
 amsmath.sty    2017/09/02 v2.17a AMS math features
 amstext.sty    2000/06/29 v2.01 AMS text
  amsgen.sty    1999/11/30 v2.0 generic functions
  amsbsy.sty    1999/11/29 v1.2d Bold Symbols
  amsopn.sty    2016/03/08 v2.02 operator names
fancyhdr.sty    2017/06/30 v3.9a Extensive control of page headers and footers
tabularx.sty    2016/02/03 v2.11 `tabularx' package (DPC)
ragged2e.sty    2009/05/21 v2.1 ragged2e Package (MS)
everysel.sty    2011/10/28 v1.2 EverySelectfont Package (MS)
  lscape.sty    2000/10/22 v3.01 Landscape Pages (DPC)
 wrapfig.sty    2003/01/31  v 3.6
placeins.sty    2005/04/18  v 2.2
 siunitx.sty    2017/11/26 v2.7k A comprehensive (SI) units package
   expl3.sty    2018/02/21 L3 programming layer (loader) 
expl3-code.tex    2018/02/21 L3 programming layer 
l3pdfmode.def    2017/03/18 v L3 Experimental driver: PDF mode
  xparse.sty    2018/02/21 L3 Experimental document command parser
l3keys2e.sty    2018/02/21 LaTeX2e option processing using LaTeX3 keys
translator.sty    2018/01/04 v1.12 Easy translation of strings in LaTeX
 caption.sty    2016/02/21 v3.3-144 Customizing captions (AR)
caption3.sty    2016/05/22 v1.7-166 caption3 kernel (AR)
 upgreek.sty    2003/02/12 v2.0 (WaS)
   xfrac.sty    2018/02/21 L3 Experimental split-level fractions
textcomp.sty    2017/04/05 v2.0i Standard LaTeX package
  ts1enc.def    2001/06/05 v3.0e (jk/car/fm) Standard LaTeX file
xtemplate.sty    2018/02/21 L3 Experimental prototype document functions
dblfloatfix.sty    2012/12/31 v1.0a (JAW)
fixltx2e.sty    2016/12/29 v2.1a fixes to LaTeX (obsolete)
   cuted.sty    2012/10/04 v1.5 Mixing onecolumn and twocolumn modes
epigraph.sty    2009/09/02 v1.5c typesetting epigraphs
microtype.sty    2018/01/14 v2.7a Micro-typographical refinements (RS)
microtype-luatex.def    2018/01/14 v2.7a Definitions specific to luatex (RS)
microtype.cfg    2018/01/14 v2.7a microtype main configuration file (RS)
  xcolor.sty    2016/05/11 v2.12 LaTeX color extensions (UK)
   color.cfg    2016/01/02 v1.6 sample color configuration
dvipsnam.def    2016/06/17 v3.0m Driver-dependent file (DPC,SPQR)
makecell.sty    2009/08/03 V0.1e Managing of Tab Column Heads and Cells
enumitem.sty    2011/09/28 v3.5.2 Customized lists
extarrows.sty    2008/05/15 v1.0b Some extensible arrows
 sectsty.sty    2002/02/25 v2.0.2 Commands to change all sectional heading style
 balance.sty    1999/02/23 4.3 (PWD)
changepage.sty    2009/10/20 v1.0c check page and change page layout
  lgrcmr.fd    2017/07/29 v1.2 Greek European Computer Regular
  ts1cmr.fd    2014/09/29 v2.5h Standard LaTeX font definitions
epstopdf-base.sty    2016/05/15 v2.6 Base part for package epstopdf
  grfext.sty    2016/05/16 v1.2 Manage graphics extensions (HO)
kvdefinekeys.sty    2016/05/16 v1.4 Define keys (HO)
pdftexcmds.sty    2018/01/21 v0.26 Utility functions of pdfTeX for LuaTeX (HO)
epstopdf-sys.cfg    2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live
siunitx-abbreviations.cfg    2017/11/26 v2.7k siunitx: Abbreviated units
mt-LatinModernRoman.cfg    2013/03/13 v1.0 microtype config. file: Latin Modern 
Roman (RS)
  ot1lmr.fd    2009/10/30 v1.6 Font defs for Latin Modern
  omllmm.fd    2009/10/30 v1.6 Font defs for Latin Modern
 omslmsy.fd    2009/10/30 v1.6 Font defs for Latin Modern
 omxlmex.fd    2009/10/30 v1.6 Font defs for Latin Modern
  mt-eur.cfg    2006/07/31 v1.1 microtype config. file: AMS Euler Roman (RS)
  ts1lmr.fd    2009/10/30 v1.6 Font defs for Latin Modern
 ot1lmss.fd    2009/10/30 v1.6 Font defs for Latin Modern
 ot1lmtt.fd    2009/10/30 v1.6 Font defs for Latin Modern

I'll be very glad for some guidance or at least for information about this problem. Even should it be "this can't be done".

  • 2
    Well I wouldn't say that is impossible, but it is probably not easily done. You could check the packages gridset and returntogrid for ideas. The context format can do gridtypesetting but converting your text to context would be quite some work too. Feb 25, 2020 at 22:04
  • Thanks for the tips. Ulrike. I've tried both, the returntogrid one seems more manageable but in the doc I have it doesn't seem to get to the "stable" state no matter how many compiles. I tried just putting \returntogrid after every element breaking the alignment. It evidently attempted to align the text to grid but usually failed. I guess I'll have to tell the client they should have chosen a different typesetting system than LaTeX for this kind of task. From what I read in the docs of both of the packages, LaTeX is really not suitable when one wants to align baselines in 2column layout.
    – edison23
    Mar 1, 2020 at 10:40
  • There are cases where returntogrid is really helpless. Most importantly top floats as shown in your example are a real problem. This will only work, if their size is so that the grid is hold without changes. Mar 1, 2020 at 11:25


You must log in to answer this question.