8

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.

5
  • 8
    it could, it just needs someone to do it, but context has been re-written from the ground up as a luatex-only system which means that it's easier (perhaps) to integrate lua into the core layout functionality of context than it would be for latex which still supports pdftex and xetex as well as luatex. That said it probably wouldn't be impossibly difficult to abstract this out and use as a latex package cf the way context's font handler code is the basis of luaotfload font handling in lualatex. Aug 15, 2017 at 20:49
  • 1
    @DavidCarlisle: You want to seriously work on the output routine again? Aug 15, 2017 at 21:32
  • 1
    @DavidCarlisle So it is not because of the way LaTeX handles things? I thought it was a LaTeX, rather than a TeX, problem. (But maybe I just thought this because I knew ConTeXt did it, without thinking about the Lua aspect.)
    – cfr
    Aug 15, 2017 at 21:44
  • 7
    Note that ConTeXt has had support for grid typesetting since the early 2000s, much before LuaTeX!
    – Aditya
    Aug 15, 2017 at 22:42
  • 3
    @Aditya true but as far as my limited looking determined it wasn't that different from latex packages that do the same and worked in simple cases, but the lua implementation is better than anything currently available in latex I suspect. Aug 16, 2017 at 19:25

1 Answer 1

15

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

2
  • (+1). I just want to add that everything does not work perfectly in ConTeXt, at least not the last time I tried. For example, for multiline formulas it is a problem coming back to the grid. Maybe you know how to do that (if so, please consider adding an answer to that question)?
    – mickep
    Aug 16, 2017 at 5:30
  • 1
    @mickep I'm not aware of any problems right now. I've added an answer there but I think it might have been a regression. Aug 23, 2017 at 5:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .