quarto-dev / quarto-dev/quarto-cli
Adding a cross reference to a markdown table results in column alignment being ignored in docx output
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 6k
- Forks
- 458
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 41
Description
Bug description
When generating docx output, if I specify a markdown table with column alignments then adding a cross reference to that table results in the column alignments being ignored in the generated docx file.
Steps to reproduce
Here's a test Quarto document
---
title: "Test table column alignment with cross reference"
format:
docx:
keep-md: true
html:
embed-resources: true
pdf: default
engine: knitr
---
A test table with correct column alignment. Taken from [here](https://quarto.org/docs/authoring/tables.html#markdown-tables).
| Default | Left | Right | Center |
|---------|:-----|------:|:------:|
| 12 | 12 | 12 | 12 |
| 123 | 123 | 123 | 123 |
| 1 | 1 | 1 | 1 |
: Demonstration of pipe table syntax
Now I add @tbl-example, which has includes cross reference. In docx output the column alignment is not adhered to.
| Default | Left | Right | Center |
|---------|:-----|------:|:------:|
| 12 | 12 | 12 | 12 |
| 123 | 123 | 123 | 123 |
| 1 | 1 | 1 | 1 |
: Demonstration of pipe table syntax {#tbl-example}
Now I add @tbl-another, which includes the cross reference using the div syntax. Again in docx output the column alignment is not adhered to.
::: {#tbl-another}
| Default | Left | Right | Center |
|---------|:-----|------:|:------:|
| 12 | 12 | 12 | 12 |
| 123 | 123 | 123 | 123 |
| 1 | 1 | 1 | 1 |
: Demonstration of pipe table syntax
:::
The bug is that column alignments are ignored for tables 2 and 3 in docx output, and all columns are centred.
Whereas the html and pdf outputs use the specified alignments.
and
I am not 100% sure whether this a Quarto bug or a Pandoc bug. My guess is that it's a Quarto bug, since if I run the intermediate markdown file through pandoc, the tables use the specified column alignment. Also the column alignments are respected under both pandoc-crossref and bookdown::word_document2().
If helpful, my test repo is https://github.com/remlapmot/quarto-docx-tables-test.
Expected behavior
The column alignments (e.g., left or right) should be respected.
Actual behavior
All the columns are centred.
Your environment
RStudio 2023.12.1+402 "Ocean Storm" Release (4da58325ffcff29d157d9264087d4b1ab27f7204, 2024-01-29) for macOS
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) RStudio/2023.12.1+402 Chrome/116.0.5845.190 Electron/26.2.4 Safari/537.36
macOS Sonoma 14.3.1
Quarto check output
$ quarto check
Quarto 1.4.550
[✓] Checking versions of quarto binary dependencies...
Pandoc version 3.1.11: OK
Dart Sass version 1.69.5: OK
Deno version 1.37.2: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
Version: 1.4.550
Path: /Applications/quarto/bin
[✓] Checking tools....................OK
TinyTeX: (external install)
Chromium: (not installed)
[✓] Checking LaTeX....................OK
Using: TinyTex
Path: /Users/tom/Library/TinyTeX/bin/universal-darwin
Version: 2023
[✓] Checking basic markdown render....OK
[✓] Checking Python 3 installation....OK
Version: 3.12.2
Path: /opt/homebrew/opt/python@3.12/bin/python3.12
Jupyter: (None)
Jupyter is not available in this Python installation.
Install with python3 -m pip install jupyter
[✓] Checking R installation...........OK
Version: 4.3.3
Path: /Library/Frameworks/R.framework/Resources
LibPaths:
- /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library
knitr: 1.45
rmarkdown: 2.25
[✓] Checking Knitr engine render......OK
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the Quarto document and test repository described in the report, rendering to docx with and without the table cross references. Compare the intermediate markdown and the Pandoc-generated output to narrow down where alignment metadata is lost. Done means the docx output preserves the declared left, right, center, and default alignments for all three tables.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- markdown
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100