w:lnNumType (Line Numbering)

Enables and configures automatic line numbering for a section, specifying the counting interval, starting number, distance from text, and restart behavior.

Parent elements

Description

w:lnNumType activates line numbering for the section. Line numbers are printed in the margin at a configurable interval. Line numbering is commonly used in legal documents, scripts, and code listings.

It is defined in ECMA-376 Part 1 §17.6.8.

Attributes

Attribute Type Possible Values Description
w:countBy xsd:integer Positive integer Print a line number every N lines (e.g. 5 = number lines 5, 10, 15…).
w:start xsd:integer Non-negative integer Starting line number (default 1).
w:distance xsd:integer Twips (twentieths of a point) Distance between line numbers and the text edge.
w:restart ST_LineNumberRestart newPage, newSection, continuous When line numbering resets.

w:restart values

Value Description
newPage Line numbering restarts at w:start on each new page.
newSection Line numbering restarts at w:start at the beginning of the section.
continuous Line numbering continues from the previous section without restarting.

Examples

<!-- Show a line number every 5 lines, restarting each page -->
<w:sectPr>
  <w:lnNumType w:countBy="5" w:start="1" w:distance="720" w:restart="newPage"/>
  <!-- pgSz, pgMar omitted -->
</w:sectPr>

Notes

  • w:distance is in twips (1 pt = 20 twips). A value of 720 corresponds to 36 pt (0.5 inch).
  • Individual paragraphs can suppress line numbering via w:suppressLineNumbers in their w:pPr.
  • w:lnNumType must be present for line numbering to be active; omitting it disables line numbers for the section.