Hello everyone,
Back for new questions (and I have another topic at hand, but soon). Part of it is a followup to my former topic about parts. I’m transitioning the rules made there + the others I could do by myself to create a template used for other files (quite the ambitious level up when I don’t have the skill to understand what I’m doing). Two of the rules don’t work as intended.
- The displaying of parts.
For displaying parts, a gentle soul (Y.D.X) brought me this code
#let _part = figure.where(kind: "part")
#show _part: it => {
set align(right)
set par(justify: false)
set text(font: "Josefin Sans", weight: "bold")
v(20%)
text(18pt)[Partie ] + context text(18pt, counter(_part).display())
v(.5em)
line(length: 100%, stroke: 1.5pt)
v(-0.5em)
text(24pt, it.body)
}
#let part(body) = figure(body, caption: body, kind: "part", supplement: "Partie")
This works perfectly when used in the main file of the project but when I use it in a template, I get this:
So not quite what I was aiming for. For this one, I have no idea why it doesn’t work. I’ve tried putting the function inside the layout rule (For which I use #show layout.with(), but I also have other rules outside of it for the outline or recurring stuff) and then using #part[blabla] just doesn’t work: “Unknown variable: _part”, and outside, for which I can display the picture above (and it works perfectly for the outline).
So there is something I’m missing.
- My headers
I have a “toggleable” rule for displaying headers inside of chapters. I can #show it and also turn it off with a no-deco rule (which seems to work) when necessary.
Current code
#let en-tete(body)={
set page(header: context {
set text(size:.8em)
if calc.even(here().page()){
align(center, smallcaps[#book-author])
line(length: 100%, stroke:0.1pt)}
else if query(heading.where(level: 1)).any(it => it.location().page() == here().page()) and(calc.odd(here().page())) {}
else {
if heading.numbering != none [
#align(left, [#smallcaps[#book-title] #h(1fr) #smallcaps[Chapitre #counter(heading.where(level: 1)).display()]])
#line(length: 100%, stroke:0.1pt)]
else {
align(center, [#smallcaps[#book-title]])
line(length: 100%, stroke:0.1pt)
}
}})
body
}
The thing is, I use variables for this, namely the book’s title and author that are determined in the layout part of the template. It obviously will not work when outside the layout rule (unlike the no-deco rule which works great outside of it). But when it is inside the layout rule, #show-ing it just results in an unknown variable error.
What’s more, it now doesn’t work anymore in the main file (for instance by calling a #layout.book-author variable), since I “cannot access field on user-defined functions”
So for this one, I feel like I have a bit more understanding of what’s going wrong, but I still am not able to find a proper solution.
Hence I am asking here haha
Thanks a lot for your help, again !
