quarto-dev / quarto-dev/quarto-cli

Cross-referenced longtable caption repeated on page break

Open
#14,146 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

crossref enhancement latex tables
Dominant language
JavaScript
Stars
6k
Forks
458
Avg merge
1d 9h
Merged PRs (30d)
41

Description

Quarto injects the \caption and \label into the longtable, but places them before \endhead without adding a separate \endfirsthead block. This causes the caption to repeat on every page.

Discussed in https://github.com/orgs/quarto-dev/discussions/14145

Originally posted by jtatria March 3, 2026

Description

I'm trying t format a very long table with repeated headers in each page using gt with latex options longtable and header_repeat, but I'm getting repeated table captions on each page, and multiple entries in the list of tables.

How can I accomplish a long table with repeated headers but a single caption?

I already tried using gt's own gt:tab_caption, but the caption wouldn't show in quarto.

MRE:

---
title: "gt demo"
format:
  pdf:
    documentclass: report
    lot: true
---

## Demo

```{r}
#| label: tbl-demo
#| tbl-cap: "Caption repeats"
	gt::gt( iris ) |> gt::tab_options(
		latex.use_longtable=TRUE,
		latex.header_repeat=TRUE
	)
```
```
Screenshot_20260303_103723

Any help would be greatly appreciated. Thanks!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the supplied Quarto/gt MRE with PDF output, longtable, and repeated headers, then trace the longtable caption and label generation in Quarto CLI. Verify the result by confirming one caption and one list-of-tables entry while headers still repeat on page breaks.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, latex
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.