@@ -4,13 +4,13 @@ document. By default, it will assume that it is used in the header of your docum
44the last heading if and only if it is numbered and the next heading is not the first on the current
55page.
66
7- By default hdyra assumes that you use ` a4 ` page size, see the FAQ if you use different page size or
8- margins.
7+ By default hydra also assumes that you use ` a4 ` page size, see the FAQ if you use different page
8+ size or margins.
99
1010## Example
1111``` typst
1212#import "@preview/hydra:0.0.1": hydra
13- #set page(header: hydra())
13+ #set page(header: #[ hydra() #line(length: 100%)] )
1414#set heading(numbering: "1.1")
1515#show heading.where(level: 1): it => pagebreak(weak: true) + it
1616
@@ -32,20 +32,41 @@ margins.
3232![ example2] [ example2 ]
3333
3434## Non-default behavior
35+ Changing the default behavior can be done using its keyword arguments:
36+ ``` typst
37+ #let hydra(
38+ sel: heading, // the elements to consider
39+ getter: default.get-adjacent, // gets the neighboring elements according to sel
40+ prev-filter: default.prev-filter, // checks if the last element is valid
41+ next-filter: default.next-filter, // checks if the next element is valid
42+ display: default.display, // displays the last element
43+ resolve: default.resolve, // contains the glue code combining the other given args
44+ is-footer: false, // whether this is used from a footer
45+ ) = {
46+ ...
47+ }
48+ ```
49+ These functions generally take a queried element and sometimes the current location, see the source
50+ for more info. The defaults assume only headings and fail if another element type is provided.
51+
52+ The ` sel ` argument can be an element function or selector, or either an array containing either
53+ of those and an addiitonal filter function. The additional filter function is applied before the
54+ adjacent arguments are selected from the result of the queries.
55+
3556### Configuring filter and display
36- By default it will hydra will display ` [#numbering #body] ` of the heading and this reject unnumbered
37- ones. This filtering can be configured using ` prev-filter ` and ` next-filter ` , if those are changed
38- to include unnumbered headings ` display ` be changed too.
57+ By default hydra will display ` [#numbering #body] ` of the heading and this reject unnumbered
58+ ones. This filtering can be configured using ` prev-filter ` and ` next-filter ` .
3959``` typst
40- #set page(header: hydra(prev-filter: _ => true, display: h => h.body ))
60+ #set page(header: hydra(prev-filter: (_, _) => true ))
4161```
4262
4363Keep in mind that ` next-filter ` is also responsible for checking that the next heading is on the
4464current page.
4565
4666### In the footer
4767To use the hydra functon in the footer of your doc, pass ` is-footer: true ` and place a
48- ` #metadata(()) <hydra> ` somewhere in your header.
68+ ` #metadata(()) <hydra> ` somewhere in your header, or before your headings. Hydra will use the
69+ location of this label to search for the correct headings instead of searching from the footer.
4970
5071``` typst
5172#set page(header: [#metadata(()) <hydra>], footer: hydra(is-footer: true))
@@ -62,7 +83,7 @@ specific levels of headings, pass the appropriate selector.
6283#set page(header: hydra(sel: heading.where(level: 1)))
6384
6485// only consider level 1 - 3
65- #set page(header: hydra(sel: (heading, h => h.level <= 3)))
86+ #set page(header: hydra(sel: (heading, (h, _) => h.level <= 3)))
6687
6788// consider also figures with this kind, must likely override all default functions other than
6889// resolve, or resolve directly, see source
0 commit comments