Skip to content

class RuleNode

  • supers: Node

A rule node stands for a solid black rectangle.

Contrary to traditional TeX, LuaTeX has more rule subtypes because we also use rules to store reuseable objects and images. User nodes are invisible and can be intercepted by a callback.

The left and right keys are somewhat special (and experimental). When rules are auto adapting to the surrounding box width you can enforce a shift to the right by setting left. The value is also subtracted from the width which can be a value set by the engine itself and is not entirely under user control. The right is also subtracted from the width. It all happens in the backend so these are not affecting the calculations in the frontend (actually the auto settings also happen in the backend). For a vertical rule left affects the height and right affects the depth. There is no matching interface at the TeX end (although we can have more keywords for rules it would complicate matters and introduce a speed penalty.) However, you can just construct a rule node with Lua and write it to the TeX input. The outline subtype is just a convenient variant and the transform field specifies the width of the outline.

Example:

assert.node_type("rule", nil, {
  id = "rule (2)",
  subtypes = {
    "normal (0)",
    "box (1)",
    "image (2)",
    "empty (3)",
    "user (4)",
    "over (5)",
    "under (6)",
    "fraction (7)",
    "radical (8)",
    "outline (9)",
  },
  fields = {
    "prev (-1)",
    "next (0)",
    "id (1)",
    "subtype (2)",
    "attr (3)",
    "width (4)",
    "depth (5)",
    "height (6)",
    "dir (7)",
    "index (8)",
    "left (9)",
    "right (10)",
  },
})

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!


fields


RuleNode.subtype


RuleNode.subtype : RuleNodeSubtype

RuleNode.attr


RuleNode.attr : Node {
    next: Node?,
    prev: Node?,
    id: integer,
    subtype: integer,
    head: Node?,
    attr: Node,
}

A list of attributes.

RuleNode.width


RuleNode.width : integer

the width of the rule where the special value −1073741824 is used for ‘running’ glue dimensions

RuleNode.height


RuleNode.height : integer

the height of the rule (can be negative)

RuleNode.depth


RuleNode.depth : integer

the depth of the rule (can be negative)

RuleNode.left


RuleNode.left : integer

shift at the left end (also subtracted from width)

RuleNode.right


RuleNode.right : integer

(subtracted from width)

RuleNode.dir


RuleNode.dir : DirectionSpecifier

the direction of this rule

RuleNode.index


RuleNode.index : integer

an optional index that can be referred too

RuleNode.transform


RuleNode.transform : integer

an private variable (also used to specify outline width)