Skip to content

Enumerated References Extension

Vladimir Schneider edited this page Mar 27, 2019 · 3 revisions

Enumerated references extension, in conjunction with the Attributes extension allows easy references with text and ordinal number to be created and automatically updated as the documentation evolves.

To create an element anchor or bookmark use the id attribute syntax of {#type:reference} after the element to be referenced. Where type is a category used to keep separate numbering within the category and reference is used to uniquely identify an element in the category. The anchor id of the element will be type:reference and this must be used by the enumerated reference label or link.

ℹ️ type must not start with a digit.

❗ Note that attributes extension is needed in order for the references to be properly resolved for rendering.

To refer to the element in the document use the enumerated reference elements:

  1. A reference link syntax [@type:reference] converts to a link based on type pattern defined in enumerated reference format definition. The target of the link will be an element with a {#type:reference} attribute assigned to it. The text of the link will be that which is defined by the enumerated reference definition for type.

  2. A reference text syntax [#type:reference] converts to text which is defined by the enumerated reference definition for type. This is to be used where the identifying text of the element within the document is needed.

  3. One reference definition for each type must be included in the document. Syntax [@type]: Label Text [#] is used to define how to create a label for all elements of the given type. This usually includes the ordinal position of the element in the document.

    Text following the [@type]: is used as the label with the [@] or [#] replaced by the ordinal number of the element in the document relative to other elements of the same type. The first element will have ordinal of 1, second 2, etc.

    If a type has no enumerated definition then type [#] will be used where type is the category type and [#] is the ordinal of the element in its category. It is equivalent to specifying [@type]: type [#] in the document.

For example:

![Fig](http://example.com/test.png){#fig:test}  
[#fig:test]

![Fig](http://example.com/test.png){#fig:test2}  
[#fig:test2]

| table |
|-------|
| data  |
[[#tbl:test] caption]
{#tbl:test}

See [@fig:test2]

See [@fig:test]

See [@tbl:test]


[@fig]: Figure [#].

[@tbl]: Table [#].

is equivalent to the following without having to manually keep track of numbering of individual elements:

![Fig](http://example.com/test.png){#fig:test}  
Figure 1.

![Fig](http://example.com/test.png){#fig:test2}  
Figure 2.

| table |
|-------|
| data  |
[Table 1. caption]
{#tbl:test}

See [Figure 2.](#fig:test2)

See [Figure 1.](#fig:test)

See [Table 1.](#tbl:test)

Enumerated Reference Text in Headings

Because headings contain their own anchor id an enumerated reference with only a type is allowed in headings and has the effect of adding an incremented counter to heading text.

# [#hd1] Heading 1

# [#hd1] Heading 2

# [#hd1] Heading 3

[@hd1]: [#].

Will render as:

<h1>1. Heading 1</h1>
<h1>2. Heading 2</h1>
<h1>3. Heading 3</h1>

Compound Types

Compound enumerated reference types are created by including more than one type reference with : separating each type.

The effect of compound reference is that all child reference counters are reset to 1 for change in parent type's ordinal allowing creation of legal numbering using enumerated references.

ℹ️ When combining enumerated type ordinal strings for compound enumerated reference if the last element of the enumerated format definition is an empty enumerated reference text [#] or empty enumerated reference link [@] then a . will be added after the parent enumerated ordinal text.

ℹ️ For compound type for headings without an element id, a trailing : is needed to prevent the last type from being interpreted as the element id.

# [#hd1] Heading 1

## [#hd1:hd2:] Heading 1.1

### [#hd1:hd2:hd3:] Heading 1.1.1

### [#hd1:hd2:hd3:] Heading 1.1.2

## [#hd1:hd2:] Heading 1.2

### [#hd1:hd2:hd3:] Heading 1.2.1

### [#hd1:hd2:hd3:] Heading 1.2.2

# [#hd1] Heading 2

## [#hd1:hd2:] Heading 2.1

### [#hd1:hd2:hd3:] Heading 2.1.1

### [#hd1:hd2:hd3:] Heading 2.1.2

[@hd1]: [#].
[@hd2]: [#].
[@hd3]: [#].

Will render as:

<h1>1. Heading 1</h1>
<h2>1.1. Heading 1.1</h2>
<h3>1.1.1. Heading 1.1.1</h3>
<h3>1.1.2. Heading 1.1.2</h3>
<h2>1.2. Heading 1.2</h2>
<h3>1.2.1. Heading 1.2.1</h3>
<h3>1.2.2. Heading 1.2.2</h3>
<h1>2. Heading 2</h1>
<h2>2.1. Heading 2.1</h2>
<h3>2.1.1. Heading 2.1.1</h3>
<h3>2.1.2. Heading 2.1.2</h3>