Hi,

when I create a book project like the default with `quarto create-project --type book` and add an appendix like

```
project:
  type: book

book:
  title: "quartoiusbook"
  author: "Jane Doe"
  date: "3.11.2022"
  chapters:
    - index.qmd
    - intro.qmd
    - summary.qmd
    - references.qmd
  appendices: 
    - Appendix_01.qmd

bibliography: references.bib

format:
  html:
    theme: cosmo
  pdf:
    documentclass: scrreprt
```

then I end-up with the wrong page number in the TOC for the additional entry of "Appendices" (should be page 7 and not 6):

<img width="867" alt="Bildschirmfoto 2022-11-04 um 12 03 59" src="https://user-images.githubusercontent.com/91615683/199957947-3d4ee2ca-241b-4517-ac6b-4d7a910a8390.png">

This is caused here:
https://github.com/quarto-dev/quarto-cli/blob/346d80e55abc83e0a5b87e93a17730eac5656a92/src/resources/filters/quarto-pre/book-numbering.lua#L28

The reason – as I understand it – is that before a new chapter in KOMA etc is added a `\cleardoublepage` is done. The `\addcontentsline` does not see this. Whenever I create book documents with latex I add
```
\cleardoublepage
\phantomsection
\addcontentsline{toc}{part}{TOC entry title}
```
Note, that `\phantomsection` is needed to throw an anchor for the hyperlink, which otherwise would lead to the wrong page...

Can we extend the mentioned code like? E.g.
```
local appendixPara = pandoc.Para({
  pandoc.RawInline('latex', '\\cleardoublepage\n\\phantomsection\n\\addcontentsline{toc}{part}{')
})
tappend(appendixPara.content, el.content)
appendixPara.content:insert(pandoc.RawInline('latex', '}\n\\appendix'))
```

Cheers,
Maarten
2022-11-04T11:19:56Z
iusgit
closed
Wrong page number in the TOC for "Appendices"
https://github.com/quarto-dev/quarto-cli/issues/3164