lastheading

.lastheading depth:{Int} -> <Error class: unknown class>

Displays the last heading, of the given depth, encountered in the current page.

# The heading

.lastheading depth:{1} <!-- Displays "The heading" -->

If the current page does not contain any, the last heading of the previous page is used instead, continuing backwards until a heading is found. If, ultimately, no such heading is found in the whole document, nothing is displayed.

<!-- Page 1 -->

# Heading 1

## Heading 2

<!-- Page 2 -->

.lastheading depth:{2} <!-- Displays "Heading 2" -->

This can be particularly useful in combination with pagemargin, to show the current section of the document:

.pagemargin {bottomcenter}
.lastheading depth:{1}

Note that encountering a heading of lesser depth than depth resets the current last heading. For instance:

<!-- Page 1 -->

# Heading 1

## Heading 2

<!-- Page 2 -->

# Heading 3

.lastheading depth:{2} <!-- Empty -->

Return

a new LastHeading node

Parameters

depth

the depth of the last Heading to match (1-6)

See also

Wiki page

Persistent headings

Target

This function is only available for the following document types: paged, slides.