-
-
Notifications
You must be signed in to change notification settings - Fork 212
Persistent headings
Giorgio Garofalo edited this page Oct 17, 2025
·
1 revision
The .lastheading {depth}
[docs] function makes it possible to reference the last heading of a given depth across pages or slides.
Used in combination with page margin content, it allows for persistent headings, such as chapter titles or section names, to be displayed in the page margins.
depth
refers to the heading level:1
for#
,2
for##
, and so on.
.pagemargin {topcenter}
*.lastheading depth:{1}*
# Chapter 1
.repeat {10}
.loremipsum

Note that headings of lesser depth reset the last reference. In the following example, the depth-2 persistent heading is shown when on a depth-2 section (page 2), but resets when entering a depth-1 section (page 3):
.pagemargin {topleft}
*.lastheading depth:{1}*
.pagemargin {topright}
*.lastheading depth:{2}*
# Chapter 1
.repeat {6}
.loremipsum
## Subsection
.loremipsum
# Chapter 2
.repeat {2}
.loremipsum

- Figures
- Image size
- TeX formulae
- Table caption
- Code caption
- Decorative headings
- Alerts (quote types)
- Quotation source
- Cross-references
- Page breaks
- Text symbols (text replacement)
- Emojis
- Document metadata
- Theme
- CSS
- Fonts
- Page format
- Page margin content
- Page counter
- Persistent headings
- Automatic page break
- Numbering
- Paragraph style
- Caption position
- Table of contents
- Bibliography
- Footnotes
- Stacks (row, column, grid)
- Container
- Align
- Float
- Figure
- Clip
- Box
- Collapsible
- Landscape
- Whitespace
- Variables
- Optionality
- Math
- Conditional statements
- Loops
- Let
- Destructuring
- String manipulation
- Table manipulation: sorting, computing, and more
- Table generation
- String
- Number
- Markdown content
- Boolean
- None
- Enumeration entry
- Iterable
- Dictionary
- Range
- Lambda
- Size(s)
- Color
- Dynamic
- Paper: abstract, definitions, theorems, and more