Skip to content

class GlueSpecNode

  • supers: Node

Skips are about the only type of data objects in traditional TeX that are not a simple value. They are inserted when TeX sees a space in the text flow but also by hskip and vskip. The structure that represents the glue components of a skip is called a glue_spec.

The effective width of some glue subtypes depends on the stretch or shrink needed to make the encapsulating box fit its dimensions. For instance, in a paragraph lines normally have glue representing spaces and these stretch or shrink to make the content fit in the available space. The effective_glue function that takes a glue node and a parent (hlist or vlist) returns the effective width of that glue item. When you pass true as third argument the value will be rounded.

A glue_spec node is a special kind of node that is used for storing a set of glue values in registers. Originally they were also used to store properties of glue nodes (using a system of reference counts) but we now keep these properties in the glue nodes themselves, which gives a cleaner interface to Lua.

The indirect spec approach was in fact an optimization in the original TeX code. First of all it can save quite some memory because all these spaces that become glue now share the same specification (only the reference count is incremented), and zero testing is also a bit faster because only the pointer has to be checked (this is no longer true for engines that implement for instance protrusion where we really need to ensure that zero is zero when we test for bounds). Another side effect is that glue specifications are read-only, so in the end copies need to be made when they are used from Lua (each assignment to a field can result in a new copy). So in the end the advantages of sharing are not that high (and nowadays memory is less an issue, also given that a glue node is only a few memory words larger than a spec).

In addition there are the width, stretch stretch_order, shrink, and shrink_order fields. Note that we use the key width in both horizontal and vertical glue. This suits the TeX internals well so we decided to stick to that naming.

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!


fields


GlueSpecNode.width


GlueSpecNode.width : integer

The horizontal or vertical displacement.

GlueSpecNode.stretch


GlueSpecNode.stretch : integer

An extra (positive) displacement or stretch amount.

GlueSpecNode.stretch_order


GlueSpecNode.stretch_order : integer

Factor applied to stretch amount.

GlueSpecNode.shrink


GlueSpecNode.shrink : integer

An extra (negative) displacement or shrink amount.

GlueSpecNode.shrink_order


GlueSpecNode.shrink_order : integer

Factor applied to shrink amount.