### Bug description

Hi,
when templating a document structure and adding literature references
```
quarto create-project --type book
cat intro.qmd 
# Introduction
@knuth84
# Chapter 2
## Subchap 1
## Subchap 2
### Subsubchap 1
### Subsubchap 2 
```
it migtht come to this strange result for all formats:
<img width="732" alt="Bildschirmfoto 2022-11-07 um 11 13 21" src="https://user-images.githubusercontent.com/91615683/200284904-fba85f95-7e74-42d7-9ce5-10e84d242375.png">

Adding a blank line before chapter 2 doesn't lead to this, so I think parsing get's here confused.

```
quarto --version
1.2.258
uname -mrs
Darwin 21.6.0 arm64
```

### Checklist

- [X] Please include a minimal, fully reproducible example in a single .qmd file? Please provide the whole file rather than the snippet you believe is causing the issue.
- [X] Please [format your issue](https://quarto.org/bug-reports.html#formatting-make-githubs-markdown-work-for-us) so it is easier for us to read the bug report.
- [X] Please document the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
- [X] Please document the operating system you're running. If on Linux, please provide the specific distribution.
2022-11-07T10:21:26Z
iusgit
closed
Citation disturbs templated TOC
https://github.com/quarto-dev/quarto-cli/issues/3208