Skip to content

Commit

Permalink
Fix #4017 Use alphabets for appendix numbering
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Yu committed Oct 9, 2023
1 parent b487fc4 commit 2d0688b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/providers/structurelib/latex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,15 @@ function addSectionNumber(struct: TeXElement[], config: StructureConfig, tag?: s
if (element.type === TeXElementType.Section) {
counter[config.secIndex[element.name]] = (counter[config.secIndex[element.name]] ?? 0) + 1
}
const sectionNumber = tag +
let sectionNumber = tag +
'0.'.repeat(config.secIndex[element.name] - lowest) +
(counter[config.secIndex[element.name]] ?? 0).toString()
element.label = `${inAppendix ? 'A.' : ''}${element.type === TeXElementType.Section ? sectionNumber : '*'} ${element.label}`
if (inAppendix) {
const segments = sectionNumber.split('.')
segments[0] = String.fromCharCode(parseInt(sectionNumber.split('.')[0]) + 64)
sectionNumber = segments.join('.')
}
element.label = `${element.type === TeXElementType.Section ? sectionNumber : '*'} ${element.label}`
if (element.children.length > 0) {
addSectionNumber(element.children, config, sectionNumber + '.', config.secIndex[element.name] + 1)
}
Expand Down

0 comments on commit 2d0688b

Please sign in to comment.