Search code examples
rdocxquartoflextable

Table column headers not repeating in multi-page flextables in Quarto docx


I'm using R and Quarto to publish to a Word document / docx with tables produced by flextable.

The column headers are nicely repeated at the top of each page for multi page tables. However if I add a #label to the chunk then the headers are no longer repeated on each page.

The #label is needed for the captions to work, and for cross-referencing. Is there any workaround to have both captions and repeated headers?

Thanks.

I am using quarto 1.4.549 and the flextable R package 0.9.4

This is my .qmd file which I publish using quarto::quarto_render()

---
title: "My document"
format:
  docx:
    colorlinks: true
---

This table with no caption repeats the headers at the start of each page

```{r}
flextable::flextable(iris)
```

This table has a caption but does not repeat caption headers

```{r}
#| label: tbl-test
#| fig-cap: Table caption
flextable::flextable(iris)
```

Solution

  • I can reproduce, thanks, I did not know about this bug. Quarto 1.4.549 is wrapping flextable XML code into a new XML table instruction, and that's canceling flextable settings. Sorry, there is nothing that can be done to fix the issue with that version of Quarto.