Forum How do I...?

Last subsection title for header, string-set behavior

cayhorstmann
I use

h2 {
string-set: section content();
}

and

@top-center {
content: counter(chapter) "." counter(h2) " ▪ " string(section);
text-align: right;
...
}

to produce the running head in the attached screen capture. When a page has two headings, it's not clear which of the two should be used. My editor thinks it should be the last one. I think it should be "whichever one string-set picks :-)" But I don't understand the string-set behavior. Obviously it must do its thing before the header is computed. Otherwise it would pick the preceding section, which would surely be bad when the page starts with a new section, such as this one. But then why doesn't the second section's string-set kick in and replace the first one?
  1. Screenshot_2024-09-28_10-30-58.png300.3 kB
David J Prokopetz
Generated content functions in Prince have an optional second argument which explicitly dictates this behaviour:

https://www.princexml.com/doc/gen-content/#the-optional-page-policy-value