Appearance
Contents Pages
Contents pages are compiled based on the document outline, which can only be accessed after the body of the document has been constructed. Hence we'll need to use a deferred page. Deferred pages are pages which are handled after the rest of the document, meaning they have the benefit of knowing the entire outline structure.
Defining a contents page
By default, the heading (h1, ..., h6) tags add entries to a hierarchical "headings" outline collection.
This can be used to create a contents page, as in this example:
xml
<press>
<flows>
<body type="markdown">
# Heading One
## Subheading One
lorem ipsum...
## Subheading Two
...
# Heading Two
...
</body>
<contents deferred="true">
<grid>
<repeat outline="headings" item="h1">
<row>
<cell>{{ h1.text-content }}</cell>
<cell>{{ h1.page-number }}</cell>
</row>
<repeat outline="h1" item="h2">
<row>
<cell padding-left="24pt">{{ h2.text-content }}</cell>
<cell>{{ h2.page-number }}</cell>
</row>
</repeat>
</repeat>
</grid>
</contents>
</flows>
<document format="a4" page-margin="2cm">
<page deferred="true">
<frame>Table of Contents</frame>
<flow name="contents" />
</page>
<page repeat="true" flow="body">
<flow name="body" />
</page>
</document>
</press>In the above example, a deferred page (declared with deferred="true") reads from the deferred "contents" flow which contains a simple grid displaying each h1's text content and page number, as well as the text content and page number for each h2 contained within it.
This would result in something like:
Table of Contents
Heading One
2
Subheading One
2
Subheading Two
3
Heading Two
3
Repeating over the outline
Within a deferred page (or deferred flow), the outline structure can be repeated over using a tag of the form:
xml
<repeat outline="{collection}" item="entry">
...
</repeat>where the outline attribute identifies a specific collection. The item attribute defines a scoped variable, similar to other repeats.
Two special properties are accessible about an outline entry from within a loop:
{{ entry.page-number }}evaluates to the entry's page number{{ entry.text-content }}evaluates to the unstyled text contained within the outline entry