Numbering Clauses and Cross-Referencing Them

Number clauses automatically in a wiki and refer to them by name, so numbering stays correct when clauses are dropped.

Help CentreForms & Data

Numbering Clauses and Cross-Referencing Them

Once a wiki drops clauses that do not apply, hand-typed numbering breaks. A will that skips the guardianship clause should not jump from 4 to 6, and a sentence reading "as set out in clause 7" should not point at whatever clause 7 happens to be this time.

Automatic numbering solves both. You mark clauses instead of numbering them, and the numbers are worked out after the logic has decided what survives.


Table of Contents

  1. Numbering Clauses
  2. Sub-Clauses
  3. Naming a Clause
  4. Cross-Referencing
  5. Why It Survives Dropped Clauses
  6. Common Mistakes

Numbering Clauses

Write {#clause} where the number should appear:

{#clause}. REVOCATION OF PRIOR WILLS
{#clause}. APPOINTMENT OF EXECUTOR
{#clause}. BEQUESTS

renders as

1. REVOCATION OF PRIOR WILLS
2. APPOINTMENT OF EXECUTOR
3. BEQUESTS

You never type the number. Add a clause in the middle, remove one, or wrap one in a condition – everything after it renumbers itself.


Sub-Clauses

Add a depth to number beneath the current clause:

TokenProducesResets when
{#clause}1, 2, 3Never
{#clause.2}1.1, 1.2, 2.1A new {#clause} starts
{#clause.3}1.1.1, 1.1.2A new {#clause} or {#clause.2} starts
{#clause}. BEQUESTS
{#clause.2}. My immovable property shall pass to my spouse.
{#clause.2}. My motor vehicles shall be sold.
{#clause}. RESIDUE
4. BEQUESTS
4.1. My immovable property shall pass to my spouse.
4.2. My motor vehicles shall be sold.
5. RESIDUE

Naming a Clause

To point at a clause from elsewhere, give it a name by adding a colon:

{#clause:residue}. RESIDUE OF THE ESTATE

That still numbers normally – the name is a label for referring to it, and never appears in the document. Names work at any depth: {#clause.2:trust-terms} is fine.

Use short, descriptive names in lower case with hyphens. A name must be unique within the wiki.


Cross-Referencing

Refer to a named clause with {@name}. It renders that clause's number, whatever it turns out to be:

The residue of my estate shall devolve as set out in clause {@residue}.

renders as

The residue of my estate shall devolve as set out in clause 7.

You may reference a clause before or after the point where it is defined – the numbers are resolved once the whole document is assembled.


Why It Survives Dropped Clauses

Numbering happens after conditions and loops have run. Only clauses that actually appear are counted.

{#clause:executor}. APPOINTMENT OF EXECUTOR
{IF:minor_count>0}
  {#clause:guardian}. APPOINTMENT OF GUARDIAN
{/IF}
{#clause:residue}. RESIDUE

Refer to clause {@residue} for the distribution.

With minor children, the residue clause is 3 and the sentence reads "clause 3". Without them, the guardianship clause never renders – the residue clause becomes 2, and the sentence reads "clause 2". Nothing had to be adjusted.

Note: Clauses produced inside a loop are numbered as they are emitted, so a bequest clause repeated for five assets takes five consecutive numbers.

Common Mistakes

SymptomUsual cause
{@name} appears as text in the PDFNo clause carries that name. Check the spelling – the sidebar suggests the closest match.
Two clauses share a numberThe same name was used twice. Names must be unique.
Sub-clause numbering restarts unexpectedlyA {#clause} between them started a new top-level clause.
The reference points at the wrong clauseThe name is on a different clause from the one intended – names attach to the clause marker they are written on.
A named clause is flagged as unreferencedInformation only. It is fine to name a clause you have not pointed at yet.

Next: Show or Hide Parts of a Document · back to Wiki Logic.

See it working on your own data

Everything documented here ships with the platform – try the document tools free, or go live in 7 days.