Skip to content

code in figures are centered in docx documents #11937

Open
@ejeandel

Description

@ejeandel

Bug description

When a .qmd document is rendered in docx, then each line of the python code in the figure will be centered, which makes it completely unusable.

the bug doesn't appear with the .odt, .tex or .html format

The code-line-numbers functionality also doesn't work. But nothing in the documentation states that it should work for formats other than tex and html, so maybe that's normal.

PS: (Any chance .odt will work with the book format at some point ?)

Steps to reproduce

---
format: docx
---

::: {#fig-python} 

```{.python code-line-numbers="true"}
for i in range(3):
    print(i)
    if i < 2:
        print(i+1)
```

interesting code 
:::



```python
for i in range(3):
    print(i)
    if i < 2:
        print(i+1)
```

Expected behavior

The figure should be left aligned, and the spacing from python should be respected

Actual behavior

Each row of the code in the figure is centered

Your environment

Linux Debian 12,

Quarto check output

Quarto 1.6.40
[✓] Checking environment information...
      Quarto cache location: /home/ejeandel/.cache/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.40
      Path: /opt/quarto/bin

[✓] Checking tools....................OK
      TinyTeX: (not installed)
      Chromium: (not installed)

[✓] Checking LaTeX....................OK
      Using: Installation From Path
      Path: /usr/bin
      Version: 2024

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

(bug also happens on 1.7.13)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdocxIssues with the docx formatthemesRelated to HTML theming or any other style related issue (like highlight-style)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions