quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.92k stars 324 forks source link

table of contents (TOC) included in TOC in docx book #10692

Open michalovadek opened 2 months ago

michalovadek commented 2 months ago

Bug description

When rendering a book in docx, Quarto by default includes the Table of contents (TOC) in the TOC. I think this is unusual and undesired in most book projects and would suggest that reference to the TOC should by default be excluded from the TOC. Since it's possible to delist and denumber a chapter heading, this should be possible with respect to the TOC as well?

Steps to reproduce

in the book project's _quarto.yml set the following:

project:
  type: book

format:
  docx:
    number-sections: true
    toc: true

Expected behavior

The TOC itself should not be referenced in the TOC.

Actual behavior

image

Your environment

R version 4.2.3 (2023-03-15 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 22631) Quarto: ‘1.3.296’

Quarto check output

‘1.3.296’

mcanouil commented 2 months ago

You are using a quite old version, please upgrade to 1.5 and confirm this is still an issue. Thank you.

michalovadek commented 2 months ago

same behaviour in 1.5.57

mcanouil commented 2 months ago

Could you share a small self-contained "working" (reproducible) example to work with, i.e., a complete Quarto document or a Git repository? The goal is to make it as easy as possible for us to recreate your problem so that we can fix it: please help us help you! Thanks.


You can share a self-contained "working" (reproducible) Quarto document using the following syntax, i.e., using more backticks than you have in your document (usually four ````). See https://quarto.org/bug-reports.html#small-is-beautiful-aim-for-a-single-document-with-10-lines.

If you have multiple files (and if it is absolutely required to have multiple files), please share as a Git repository.

RPython
`````md ````qmd --- title: "Reproducible Quarto Document" format: html engine: knitr --- This is a reproducible Quarto document. {{< lipsum 1 >}} ```{r} x <- c(1, 2, 3, 4, 5) y <- c(1, 4, 9, 16, 25) plot(x, y) ``` ![An image]({{< placeholder 600 400 >}}){#fig-placeholder} {{< lipsum 1 >}} The end after @fig-placeholder. ```` ````` `````md ````qmd --- title: "Reproducible Quarto Document" format: html engine: jupyter --- This is a reproducible Quarto document. {{< lipsum 1 >}} ```{python} import matplotlib.pyplot as plt x = [1, 2, 3, 4, 5] y = [1, 4, 9, 16, 25] plt.plot(x, y) plt.show() ``` ![An image]({{< placeholder 600 400 >}}){#fig-placeholder} {{< lipsum 1 >}} The end after @fig-placeholder. ```` `````

Additionally and if not already given, please share the output of quarto check within a code blocks (i.e., using three backticks ```txt), see https://quarto.org/bug-reports.html#check.

michalovadek commented 2 months ago

after trying to replicate it I think I pinned down the issue to my custom reference docx file (attached), as the TOC was not referenced in a minimal example before I applied it. But it is not obvious to me what in it is causing the problem custom-reference.docx

here is the minimal YAML file:

project:
  type: book

book:
  title: "Book"
  author: "Jane Doe"
  chapters:
    - index.qmd

format:
  docx:
    toc: true
    reference-doc: custom-reference.docx
mcanouil commented 1 month ago

Did you follow the instruction to make this reference document? https://quarto.org/docs/output-formats/ms-word-templates.html

Did the same thing happen using a simple document (not a book)?


````qmd
---
title: "Reproducible Quarto Document"
format:
  docx:
    toc: true
    reference-doc: custom-reference.docx
engine: markdown
---

# Section 1

This is a reproducible Quarto document.

# Section 2

{{< lipsum 1 >}}

# Section 3

![An image]({{< placeholder 600 400 >}}){#fig-placeholder}

# Section 4

{{< lipsum 1 >}}

# Section 5

The end after @fig-placeholder.
michalovadek commented 1 month ago

the simple document (not book) suffers from the same issue.

The template was created from the Quarto reference document, but using a version from a few years back, so perhaps there was some change along the way which removed the problem, because the default reference document does not entail the problem right now. Alternatively, I introduced the issue by changing something in the reference doc, but it really isn't clear to me what. I might reapply my styles to a fresh reference document at some point and hopefully that would solve it (or at least identify the issue)

mcanouil commented 1 month ago

The reference document is a Pandoc feature on which Quarto does not intervene. If the default one works, then the issue is in yours.