quarto-dev / quarto-dev/quarto-cli

code in figures are centered in docx documents

Open
#11,937 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug docx themes
Dominant language
JavaScript
Stars
6k
Forks
458
Avg merge
1d 9h
Merged PRs (30d)
41

Description

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)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by rendering the supplied .qmd example with Quarto 1.6.40 or 1.7.13 and compare its docx output with the odt, tex, and html outputs. Trace the docx rendering path for code inside figures; done means the figure code is left aligned, Python indentation is preserved, and the expected status of code-line-numbers is documented or verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.