[Tex/LaTex] Why is grid typesetting available in ConTeXt

contextgrid-typesettingluatextypography

As I understand, the problem with the grid typesetting lies in the mechanism TeX uses for page construction. There are a few packages that try to fix that and that may be done (hopefully) with LaTeX3.

My question is why the mechanics used in ConTeXt cannot be used in LaTeX, and what made grid typesetting in ConTeXt possible.

Best Answer

The key ingredient to grid typesetting is making sure that a line will end up at a fixed vertical position on the page, independent of content before or after.

In LaTeX this is not realised because the vertical glue inserted after equations or figures is always the same and does not adapt itself to the height of the equation or figure. The problem with this is that basically everything can break the grid. For example if you implement the adaptive glue for equations and figures but forget it for tables, those will mess with your vertical spacing again. There are some LaTeX packages which attempt to perform this task but they only work in a very limited range of the highly heterogeneous universe of documentclasses and packages.

ConTeXt on the other hand is very monolithic apart from very few third-party modules. This allows for a fully consistent implementation of the adaptive vertical glue and makes it kind of hard for the user to break this mechanism as long as high-level ConTeXt macros are used consistently.

The reason why that is not available for LaTeX has been partly laid out above already (heterogeneous environment, modular approach). Another point is that in ConTeXt MKIV the grid snapping is implemented in Lua and even if it was possible to port this to LaTeX, the resulting functionality would be limited to users of LuaTeX.


Finally a little example of grid typesetting in ConTeXt:

\setuplayout[grid=yes]

\showgrid

\starttext

\input knuth

\startformula
  E = m c^2
\stopformula

\startplacefigure[title={The Dutch cow}]
  \externalfigure[cow]
\stopplacefigure

\input ward

\stoptext

enter image description here