[Tex/LaTex] How to do grid typesetting with amsmath

amsmathgrid-typesettingline-spacing

Following the advice in the answer to this question, I did set a huge negative \lineskiplimit. However, it turned out that align got quite upset about this. So my question is: what would you recommend to achieve (at least partially) grid typesetting with amsmath? By "partially" I mean that I accept not adhering to grid when there are, say, lots of theorem-like environments etc. on a page, but on pages with only text/sections/inline math I'd prefer to have it. I am rather afraid of using any packages for grid typesetting, since in the class I am using I redefined a lot of LaTeX internals (for example, I coded theorems, sections, enumerations from scratch, not even 100% compatibly with pure LaTeX). (I know this is risky, but "though this be madness, yet there's method in't";).)

So now I have a few options.

  1. Redefine align & friends to temporarily set \lineskiplimit to 0pt. Not something I'd like to do, obviously.

  2. Set \lineskiplimit back to 0pt, and \smash (or display) manually all "too big" formulae.

Currently I am leaning towards 2., but are there any other ideas?

Best Answer

The basic answer is that you have to make all your display objects fit into multiples of your grid, e.g., headings, display equations, etc. need to be preprocessed and boxed so that they fit the grid and similarly floats and footnotes have to be adjusted to honor the space requirements. There are a bunch of packages out there who are making an attempt at this, e.g., grid.sty from River Valley or ltxgrid from RevTeX and even if you do not want to use those, it might be worthwhile to look at what they do and how.

One option for something like display environments is to typeset them into a \vbox of column width and then measure the the amount of vertical space they occupy. Then add on top and below whatever is needed to get to the multiple of the grid. The tricky part then is to set \prevdepth properly so that the next line of text still aligns on the grid. Another problem is that you may want to split such material across the page. Using \unvbox might be an option but only ensure that you do not end up with stretchable glue that may break your grid.

Playing around with \lineskiplimit is possible and to some extend useful, but if set to a negative value for paragraphs it means that lines can overprint (and TeX will not detect this for you).