X

Auto-incrementing ordinals, any way you like

Sequencing

When you have an ever-changing document, it's a chore to keep your numbered sections in order. Blue-phrase answers this challenge with sequencing variables.

When you begin a new writing project, you'll have a broad outline in mind, which over time is enhanced and reorganized into the finished piece. In the interim, any sequence numbers you use to order chapters, sections, illustrations, figures, and so forth, will need to be renumbered each time an addition or rearrangement occurs.

For example, let's say you've settled on a document structure like this ...

1. Introduction
2. Spring-Mounted Racks
3. Lessons from the Field

After writing these, you realize that it would be better to split the first chapter into two separate chapters; to add a new chapter to compare racks and stacks; and to include a personal narrative before the final chapter. The new outline requires everything to be renumbered:

1. Off Road Gearing
2. Suspension Problems
3. Spring-Mounted Racks
4. Racks versus Stacks
5. Taking it for a Test Drive
6. Lessons from the Field

When you use sequencers this renumbering occurs automatically. To do this, simply declare a variable beforehand, and apply the auto-increment operator with each usage. Here's what it might look like:

!var *varname=CHAP *format=digits

section $CHAP++ Off Road Gearing
section $CHAP++ Suspension Problems
section $CHAP++ Spring-Mounted Racks
section $CHAP++ Racks versus Stacks
section $CHAP++ Taking it for a Test Drive
section $CHAP++ Lessons from the Field

This feature can also be used with figures and illustrations, where the subordinate numbering scheme restarts with each chapter, like this:

!var *varname=TBL *format=digits

$TBL=0
caption Table $CHAP.$TBL++ History of Suspensions
caption Table $CHAP.$TBL++ Market Value by Suspension Type

$TBL=0
caption Table $CHAP.$TBL++ Spring/Mass Ratios
caption Table $CHAP.$TBL++ Early Development Efforts

$TBL=0
caption Table $CHAP.$TBL++ Take Aways

The compiled HTML would look like this:

<section>1 Off Road Gearing</section>

<section>2 Suspension Problems</section>
<caption>Table 2.1 History of Suspensions</caption>
<caption>Table 2.2 Market Value by Suspension Type</caption>

<section>3 Spring-Mounted Racks</section>
<caption>Table 3.1 Spring/Mass Ratios</caption>
<caption>Table 3.2 Early Development Efforts</caption>

<section>4 Racks versus Stacks</section>

<section>5 Taking it for a Test Drive</section>

<section>6 Lessons from the Field</section>
<caption>Table 6.1 Take Aways</caption>

Formatting

The sequence number can be emitted as digits, letters, and other special symbols using the *format attribute. Here are the possibilities:

*format example
DIGITS 1 2 3 . . . 9 10 11
DIGITS2 01 02 03 . . . 09 10 11
DIGITS3 001 002 003 . . . 099 100 101
DIGITS4 0001 0002 0003 . . . 0999 1000 1001
ROMAN I II III . . . IX X XI
roman i ii iii . . . ix x xi
ALPHA A B C D E. . . X Y Z AA AB
ALPHA a b c d e . . . x y z aa ab
GREEK Α Β Γ Δ Ε . . . Υ Φ Χ Ψ Ω
greek α β γ δ ε . . . υ φ χ ψ ω
numericgreek αʹ βʹ γʹ δʹ εʹ . . . ιʹ κʹ λʹ μʹ νʹ . . . ρʹ σʹ τʹ υʹ φʹ
NUMERICGREEK Αʹ Βʹ Γʹ Δʹ Εʹ . . . Ιʹ Κʹ Λʹ Μʹ Νʹ . . . Ρʹ Σʹ Τʹ Υʹ Φʹ
abjad ا ب ج د ه و ز ح ط
hebrew א ב ג ד ה ו ז ח ט י יא יב יג יד ט״ו ט״ז יז יח יט

Auto-incrementing ordinals, any way you like