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?

  • 3
    display math entries are often relatively large, so the only way to preserve any grid alignment would be to grab and measure each row and force its vertical size to be an integer multiple of \baselineskip. If you disable \lineskiplimit you don't force grid alignment, just force that large rows just stack whatever size they are, if you \smash large rows then they over-print adjacent rows. – David Carlisle Apr 15 '12 at 17:08
  • @DavidCarlisle: thanks for your comment. Of course you are right, I didn't mean display math, but rather inline formulae. – mbork Apr 15 '12 at 21:28
  • so now I'm confused as your question is mostly about the align environment which is a display environment. – David Carlisle Apr 15 '12 at 22:17
  • OK, I was writing my comment in a bit of a hurry, sorry. What I wanted to achieve was something I'd call "partial grid typesetting": unless there was any display material, I wanted everything else to be placed on grid, and in case of displays, who cares. I thought that setting \lineskiplimit=-\maxdimen would do exactly this: give me grid with no displays, and if they appeared, I wouldn't care about the grid on such a page. But it turned out that this setting messed displays completely-hence my question. – mbork Apr 15 '12 at 23:49
  • 1
    Would it be possible to use LuaTeX in your setting? I'm thinking that going through the page at shipout time and shifting the lines to fit on the grid could work, more or less. – Bruno Le Floch Jul 13 '12 at 19:51

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).


FWIW, ConTeXt supports grid typesetting (\setuplayout[grid=yes]). For inline math formulas, there is a \gform macro that snaps the inline formula to the grid. See the It's in the Details manual for ...well... the details. I am including one page from the manual that shows the different formatting options.

enter image description here

  • Thanks Aditya, I knew that - but I had good reasons not to use ConTeXt for that project... – mbork Aug 8 '12 at 19:13
  • It may still be worthwhile to check the definition of \gform in ConTeXt and see if it can be translated to LaTeX. – Aditya Aug 10 '12 at 20:43
  • I'll add it to my to-do list, just for the sake of curiosity, since that project is finished (typeset, printed, delivered to the readers;)). – mbork Aug 10 '12 at 23: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.