Recently, I ask for achieve a custom header and number footer configuration for my document. Here the post. Answers suggest I use hydra package. But now, I want truncate the title that appears in the header, searching in this forum I found a solution with hydra, that solution is simple but I can’t merge it with the past script so I need to merge these scripts for achieve my objectives.
- First script (thanks @flokl):
#import "@preview/hydra:0.6.2": *
#set page(
header: context {
let page-num = counter(page).get().first()
if page-num != 1 {
if calc.even(page-num) {
set align(left)
counter(page).display("1")
h(1cm)
[Author Name]
} else {
set align(right)
hydra(1) // heading lvl 1
h(1cm)
counter(page).display("1")
}
}
},
footer: context {
let page-num = counter(page).get().first()
if page-num == 1 {
set align(center)
counter(page).display("[1]")
}
}
)
- Second script (Again, thanks @flokl ):
#import "@preview/hydra:0.5.1": hydra, selectors
#import selectors: custom
#let chapter(long, short) = {
[#metadata(short)<short>]
heading(long)
}
#set page(
header: context hydra(
skip-starting: false,
custom(<short>),
display: (_, elem) => {
elem.value
}
)
)
#chapter[Long title 1][Short 1]
#lorem(2000)
#chapter[Long title 2][Short 2]
#lorem(2000)
#chapter[Long title 3][Short 3]
#lorem(2000)