quarto-dev / quarto-dev/quarto-cli
Wrong alignment for table/figure in `docx` (`fig-align` not working)
@cscheid is already working on this.
Since Dec 1, 2024.
- Dominant language
- JavaScript
- Stars
- 6k
- Forks
- 458
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 41
Description
Alignment is hardcoded by Quarto (not using reference style)
In theory, fig-align is supposed to control caption but it's not the case (maybe related to the cross-reference system refactoring/improvement)
| Input | Output |
|---|---|
|
|
Now, if I remove the alignment hardcoded/added, in addition to get fig-align working, you also get the reference document works by default as one might expect.
function docxParaStyles(align)
local styles = "<w:pPr>\n"
- local captionAlign = docxAlign(align)
- if captionAlign then
- styles = styles ..
- "<w:jc w:val=\"" .. captionAlign .. "\"/>\n"
- end
styles = styles ..
"<w:spacing w:before=\"200\" />\n" ..
"<w:pStyle w:val=\"ImageCaption\" />\n" ..
"</w:pPr>\n"
return styles
end
| Input | Output |
|---|---|
|
|
|
|
Unfortunately, the code which adds the alignment is needed for table caption to be aligned according to the document level tbl-align.
For short, the current implementation is in conflict with itself resulting in more bad results than good.
Quarto document
---
title: "Quarto Playground"
format:
docx:
reference-doc: centre-caption.docx
tbl-align: left
---
{#fig-placeholder-1}
| A | B | C |
|---|---|---|
| 1 | 2 | 3 |
| 4 | 5 | 6 |
: A table 1 {#tbl-table-1}
{#fig-placeholder-2 fig-align="right"}
| A | B | C |
|---|---|---|
| 1 | 2 | 3 |
| 4 | 5 | 6 |
: A table 2 {#tbl-table-2 tbl-align="right"}
| Version | Output | |
|---|---|---|
| v1.7 |
|
Results: 1 correct out of 4 cases |
| No alignment added in `docxDivCaption` |
|
Results: 3 correct out of 4 cases |
Originally posted by @mcanouil in https://github.com/quarto-dev/quarto-cli/discussions/11513#discussioncomment-11428572
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.
Assessment
This issue has not been assessed yet.