diff --git a/pdf/creator/chapters.go b/pdf/creator/chapters.go index fecd1c8c..dd119692 100644 --- a/pdf/creator/chapters.go +++ b/pdf/creator/chapters.go @@ -141,8 +141,10 @@ func (chap *Chapter) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, if chap.includeInTOC { // Add to TOC. chapNumber := "" - if chap.number != 0 { - chapNumber = strconv.Itoa(chap.number) + "." + if chap.showNumbering { + if chap.number != 0 { + chapNumber = strconv.Itoa(chap.number) + "." + } } chap.toc.Add(chapNumber, chap.title, strconv.Itoa(ctx.Page), 1) diff --git a/pdf/creator/subchapter.go b/pdf/creator/subchapter.go index b35a3ccc..386b4665 100644 --- a/pdf/creator/subchapter.go +++ b/pdf/creator/subchapter.go @@ -148,15 +148,18 @@ func (subchap *Subchapter) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawCo if subchap.includeInTOC { // Add to TOC. subchapNumber := "" - if subchap.chapterNum != 0 { - subchapNumber = strconv.Itoa(subchap.chapterNum) - } - if subchap.subchapterNum != 0 { - if subchapNumber != "" { - subchapNumber += "." - } - subchapNumber += strconv.Itoa(subchap.subchapterNum) + "." + if subchap.showNumbering { + if subchap.chapterNum != 0 { + subchapNumber = strconv.Itoa(subchap.chapterNum) + } + if subchap.subchapterNum != 0 { + if subchapNumber != "" { + subchapNumber += "." + } + + subchapNumber += strconv.Itoa(subchap.subchapterNum) + "." + } } subchap.toc.Add(subchapNumber, subchap.title, strconv.Itoa(ctx.Page), 2)