1

Usually the baseline in LaTeX's output is exactly continuous across pages, so that lines on the following pages appear as printed "on top" of each other when a page is turned.

But that behaviour can be disturbed by elements that have a baselineskip different from the main text. I encounter it rather frequently, for example

  • when an element uses a smaller font size, such as in a quotation or table (at least in some style sheets), or when \\[x pt] is used, e.g. in a table
  • when elements from packages are used that lead to unusual spacing, e.g. when \vspace is hardcoded in a package

I'd like to find a way to automatically revert to the baseline when such an element has been used. For example, in the MWE below, I'm looking for a command \baselinerevert that automatically calculates and inserts the needed vertical skip between the tabular and the main text such that the baselines in the main text on the facing pages match.

(In terms of Adobe's InDesign, I need the equivalent of the "align to baseline grid" setting in the paragraph settings)


MWE:

\documentclass{scrbook}
\usepackage{kantlipsum,booktabs}
\begin{document}
    \kant[1-3]
    \begin{table}{\footnotesize
        \caption{A table that does not make much sense.}
        \begin{tabular}{lrr}
        \toprule
        Variable & Value 1 & Value 2\\\midrule
        A & 42.0 & 1.2\\
        B & 0.5  & 2.1\\
        \bottomrule
        \end{tabular}}
    \end{table}
    \kant[6-7]
\end{document}

MWE output

  • 2
    the one tag you didn't add was for grid typesetting, searching this site for that tag will reveal several approaches, tex doesn't make staying on the grid that easy, – David Carlisle Nov 26 '19 at 15:38
3

You can try the returntogrid package. It needs a few compilations until it settles.

Be aware

  • top tables are a problem. In your example it works as it on the first page, but in real document you will have to ensure that they have the correct height not to disturb the grid.

  • \flushbottom is a problem as it will constantly change the labels, so I use \raggedbottom.

\documentclass{scrbook}
\usepackage{kantlipsum,booktabs}
\usepackage{returntogrid,tikz}
\AddToShipoutPictureBG {\AtTextUpperLeft{\showdebugpagegrid}}
\raggedbottom
\begin{document}
    \returntogrid aaaaa\kant[1-3]
    \begin{table}{\footnotesize
        \caption{A table that does not make much sense.}
        \begin{tabular}{lrr}
        \toprule
        Variable & Value 1 & Value 2\\\midrule
        A & 42.0 & 1.2\\
        B & 0.5  & 2.1\\
        \bottomrule
        \end{tabular}}
    \end{table}
    \kant[6-7]
\end{document}

enter image description here

|improve this answer|||||
  • Thank you! Do I understand the package correctly as using the current page as the reference point, by calculating the current distance from the top corner? I was wondering what you would think about a purely float/environment-internal reference, e.g. by measuring the height of the current float/environment, checking if that is a whole-number multiplier of \baselineskip, and if not, adding the respective \vspace to the end of the current float/environment. – Felix Emanuel Dec 1 '19 at 13:13
  • Yes something like this should be done with (top)-floats. That is what the documentation means with "or give them a height that pushes the text below onto the grid without manual adjustment". You could write a gridfloats package which implments this. – Ulrike Fischer Dec 1 '19 at 13:21

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.