Open julianbarg opened 1 year ago
set chapter numbers so they are consistent
I do, they are, but there's a caveat: if you use --number-sections
, it's pandoc itself which numbers sections, not pandoc-crossref, thus there's a disconnect. That's one of the reasons why numberSections
exists.
Now that I think about it, pandoc itself kind of supports number
attribute (at least for some writers), so it should be possible to bodge a compatibility layer by force-setting all numbers. But IMO it's pretty low priority, as numberSections
offers more flexibility in terms of formatting. Still, here's a silly little lua filter you can use right now if you want:
function Header(el)
el.attributes.number = el.attributes.label
el.attributes.label = nil;
return el
end
You need to enable setLabelAttribute
metadata option, e.g., assuming you named the lua filter above fixup-header-nums.lua
:
$ pandoc -F pandoc-crossref -L fixup-header-nums.lua --number-sections -MsetLabelAttribute input.md -t docx -o out.docx
An alternative is to let pandoc-crossref number sections:
$ pandoc -F pandoc-crossref -MnumberSections -MsectionsDepth=-1 input.md -t docx -o out.docx
Thanks, I had missed -M numberSections
. Got it to work now, which is fabulous. Didn't get the first option to work, but it's probably for the best -- lot of complexity and things interacting going on here, not necessarily the right direction to take pandoc-crossref
As described in the title. Appreciate the new feature, I think the next step would be to computationally set chapter numbers so they are consistent. Example: I set the chapter number of the first chapter of my document to 0 (foreword), but the chapter after became chapter 2, i.e., there was no chapter 1. In case this is format dependent, I was converting a markdown document to .docx. System is Ubuntu 22.04, pandoc 3.1.5, pandoc-crossref 0.3.16.0 (love those nightlies).