# lastheading

    .lastheading depth:{Int} -> Node

Content copied to clipboard

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

    # The heading

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

Content copied to clipboard

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" -->

Content copied to clipboard

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

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

Content copied to clipboard

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 -->

Content copied to clipboard

#### Return

a new LastHeading node

#### Parameters

depth

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

#### See also

pageMarginContent

#### Wiki page

persistent-headings

#### Target

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