Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Both figure and table captions are being converted to actual table structures within Word. This results in the captions being displayed as tables, not text, completely breaking the document layout and structure. #11756

Open
Younthing opened this issue Dec 30, 2024 · 7 comments
Assignees
Labels
crossref docx Issues with the docx format enhancement New feature or request triaged-to Issues that were not self-assigned, signals that an issue was assigned to someone.

Comments

@Younthing
Copy link

Younthing commented Dec 30, 2024

Bug description

"I'm encountering a significant issue when converting Quarto documents to Word (.docx) format. Instead of correctly rendering figure and table captions as either "Image Caption" or "Table Caption" styles, Quarto is erroneously converting them into actual Word "Table" elements. This means that the captions are not displayed as text paragraphs but are instead rendered as full-fledged tables within the Word document. This is a very peculiar and serious error, as the captions should clearly be text content associated with figures and tables, not actual tables themselves.
To be more specific:
Expected behavior: Figure captions should be rendered using the "Image Caption" style in Word, and table captions should be rendered using the "Table Caption" style (or at least as normal paragraph text associated with table/figures ).
Actual behavior: Both figure and table captions are being converted to actual table structures within Word. This results in the captions being displayed as tables, not text, completely breaking the document layout and structure.
This is happening in all cases, regardless of whether the caption is for a figure or a table. I've checked for any potential configuration issues and verified that my Pandoc setup is correct, which leads me to believe that this might be a bug within Quarto itself.
I would be grateful if you could investigate this issue and provide a potential workaround or solution."

Steps to reproduce

---
title: "test"
execute:
    keep-md: true
format: 
  docx: 
    df-print: kable

---

## Quarto
```{r}
#| echo: false
#| warning: false
#| tbl-cap: iris
#| table-style: CaptionStyle
#| label: notbl-iris


head(iris) |>
  pander::pander()
  
```
  


```{r}
#| echo: false
#| warning: false
#| tbl-cap: hello
#| table-style: CaptionStyle
#| label: tbl-tcmdatapath


head(iris) |>
  pander::pander()
```

Expected behavior

Figure captions should be rendered using the "Image Caption" style in Word, and table captions should be rendered using the "Table Caption" style (or at least as normal paragraph text associated with table/figures

Actual behavior

Both figure and table captions are being converted to actual table structures within Word. This results in the captions being displayed as tables, not text, completely breaking the document layout and structure.

Your environment

windows11 ,Rstudio ,quarto latest 1.6*

Quarto check output

$ quarto check
Quarto 1.6.39
[>] Checking environment information...
Quarto cache location: C:\Users\fanxf\AppData\Local\quarto
[>] Checking versions of quarto binary dependencies...
Pandoc version 3.4.0: OK
Dart Sass version 1.70.0: OK
Deno version 1.46.3: OK
Typst version 0.11.0: OK
[>] Checking versions of quarto dependencies......OK
[>] Checking Quarto installation......OK
Version: 1.6.39
Path: C:\ProgramData\chocolatey\lib\quarto\tools\bin
CodePage: 65001

[>] Checking tools....................OK
TinyTeX: (external install)
Chromium: (not installed)

[>] Checking LaTeX....................OK
Using: TinyTex
Path: C:\Users\fanxf\AppData\Roaming\TinyTeX\bin\windows
Version: 2024

[>] Checking basic markdown render....OK

[>] Checking Python 3 installation....OK
Version: 3.12.4
Path: C:/Python312/python.exe
Jupyter: (None)

  Jupyter is not available in this Python installation.
  Install with py -m pip install jupyter

[>] Checking R installation...........OK
Version: 4.4.1
Path: C:/PROGRA1/R/R-441.1
LibPaths:
- C:/Users/fanxf/AppData/Local/R/win-library/4.4
- C:/Program Files/R/R-4.4.1/library
knitr: 1.48
rmarkdown: 2.28

[>] Checking Knitr engine render......OK

@Younthing Younthing added the bug Something isn't working label Dec 30, 2024
@mcanouil
Copy link
Collaborator

mcanouil commented Dec 30, 2024

Could you properly format your post using code blocks for code and terminal outputs? Thanks.
If your code contains code blocks, you need to enclose it using more backticks, i.e., usually four ````.
See https://quarto.org/bug-reports.html#formatting-make-githubs-markdown-work-for-us.

Where did you see table-style as a valid option? Please, use only valid and required options when making an example to avoid confusing future readers.

@mcanouil
Copy link
Collaborator

mcanouil commented Dec 30, 2024

To note, the captions are using the style from the reference document (Pandoc), namely Image Caption.

InputOutput
---
title: "Quarto Playground"
format: docx
---

![An image]({{< placeholder 600 400 >}}){#fig-placeholder}

| A | B | C |
|---|---|---|
| 1 | 2 | 3 |
| 4 | 5 | 6 |

: This is a table {#tbl-one}
Screen.Recording.2024-12-30.at.14.15.10.mov

completely breaking the document layout and structure.

How is it breaking the document structure exactly?

This being said, Pandoc does use Table Caption for tables by default but Quarto uses (most likely as a side effect) Image Caption for all cross-reference.

InputOutput
| A | B | C |
|---|---|---|
| 1 | 2 | 3 |
| 4 | 5 | 6 |

: This is a table
quarto pandoc --from markdown --to docx -o index.docx index.md
Image

@mcanouil mcanouil added enhancement New feature or request crossref docx Issues with the docx format triaged-to Issues that were not self-assigned, signals that an issue was assigned to someone. and removed bug Something isn't working labels Dec 30, 2024
@Younthing
Copy link
Author

Thanks so much!

Because I'm using reference.docx to set the table style, specifically the required outer border, the table style is also being applied to the table captions。 I'm using a Python filter with Pandoc to temporarily get the results I need。

Why are the captions formatted with the table style?
Image

To note, the captions are using the style from the reference document (Pandoc), namely Image Caption.

Input Output

title: "Quarto Playground"
format: docx

![An image]({{< placeholder 600 400 >}}){#fig-placeholder}

A B C
1 2 3
4 5 6

: This is a table {#tbl-one}
Screen.Recording.2024-12-30.at.14.15.10.mov

completely breaking the document layout and structure.

How is it breaking the document structure exactly?

This being said, Pandoc does use Table Caption for tables by default but Quarto uses (most likely as a side effect) Image Caption for all cross-reference.

Input Output

A B C
1 2 3
4 5 6

: This is a table
quarto pandoc --from markdown --to docx -o index.docx index.md
Image

@CaoWZ254
Copy link

CaoWZ254 commented Dec 31, 2024

I'm having the same problem. Ideally, the table caption should be a separate line of text, rather than presented as a ‘nested table’. Especially, when we need to write academic papers and have to use cross-references and three-line tables, extra time must be spent reformatting. Also, I think there is a more detailed description in #10587.

@mcanouil
Copy link
Collaborator

mcanouil commented Dec 31, 2024

This bug is a pain in the arse when we need to write academic papers and have to use cross-references and three-line tables!

@CaoWZ254

Important

We appreciate your interest in the Quarto project, but the content above violates our Code of Conduct.

As a member of the Quarto community, you are expected to follow our Code of Conduct, which outlines the standards of behavior and communication that we value. The Code of Conduct applies to all online interactions within the Quarto project, and it is enforced by the Quarto team. By participating in the Quarto community, you agree to abide by the Code of Conduct and respect the rights and dignity of others. You can find the Code of Conduct at https://github.com/quarto-dev/quarto-cli?tab=coc-ov-file#readme.

Thank you for your cooperation and contribution. 🙏

@mcanouil
Copy link
Collaborator

#10587 is indeed related but is not exactly the same thing.

@CaoWZ254
Copy link

Sorry, I used a machine translation directly and didn't double-check the rude expression, I've just revised the above comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crossref docx Issues with the docx format enhancement New feature or request triaged-to Issues that were not self-assigned, signals that an issue was assigned to someone.
Projects
None yet
Development

No branches or pull requests

4 participants