Placing the index

By default the index goes at the end of the document. To put it somewhere else, write an empty div where you want it:

::: {.qi-index-here}
:::

Every back-end honours the same marker: the HTML index section and the LaTeX \printindex each land where you wrote it. A format with no index back-end drops the marker and leaves nothing in its place.

Seven rules, each of which warns rather than breaking your build:

  • Top level only. A marker inside a callout, a list or another div places nothing: a printed index inside a LaTeX group or environment is a render risk. It is dropped, and the index keeps its default place at the end. Anything written inside it is kept, spliced in where the marker stood.
  • A div, and nothing else. The marker class on a heading, on an inline span or on a code block places nothing and is reported. Your element is left exactly as you wrote it, class included: this extension removes markers, not the elements people mistake for them.
  • The first marker wins. A second one is reported by its position and dropped. In an HTML book, where each chapter renders on its own, that position is reported with the chapter it was counted in.
  • The marker is empty. Write anything inside it and your content stays where the marker was, with a warning. Nothing you wrote is deleted.
  • A marker in a document with no index marks places nothing, and says so.
  • An index no marker names, in an HTML book, goes at the end of the book’s last chapter, on every render, provided some chapter of the book places an index. Where that chapter carries a marker of its own the section follows the ones its markers place. The Books page has the whole of it.
  • A nested marker that was the only thing there empties the place it was written in, and that is reported by the number of the top-level block it sat under — with the chapter that number was counted in, in an HTML book. (A lone top-level marker places the index, so it empties nothing.) The report does not name what held it, on purpose: Quarto wraps a callout, a tabset and a captioned figure in divs it generates and you never wrote, so any name the extension could print is either invented or wrong — and a callout holding only a marker still renders its title bar, which is not “empty” at all. A marker nested inside another marker empties one place, not one per level.

A document carrying a marker loads imakeidx with its noautomatic option. Printing an index in the middle of a document otherwise closes the file the entries are collected in, and every term marked after the marker vanishes from the index with no error. The option changes nothing else: building the index is Quarto’s PDF loop’s job either way.

Putting the index after a bibliography. Quarto appends a document’s reference block after this extension has already placed the index, so a document that leaves the bibliography where Quarto puts it gets the index first and the references after. To have it the other way round, write your own References heading and an empty #refs div where the references belong, and the placement marker below them:

# References

::: {#refs}
:::

::: {.qi-index-here}
:::

Quarto fills that div in place, so the marker still sits below the finished bibliography and the index follows it — \printindex after the reference environment in LaTeX, the index section after the bibliography in HTML. Write no #refs div and nothing changes: the references are appended at the end, after the index.

The heading is yours to write because in neither back-end will anything else write one where you put the div. When Quarto appends the reference block itself it wraps it in an appendix block carrying a References heading of its own in HTML, and in LaTeX it appends the block under no sectioning command at all; either way, a #refs div you wrote gets neither the heading nor the wrapper, so a recipe with no heading of its own leaves the bibliography unlabelled.