quarto-dev / quarto-dev/quarto-cli

Formatting issue with R chunks with lst-label and lst-cap

Open
#8,669 2 comments 0 reactions 1 assignee View on GitHub

@cscheid is already working on this.

Since Feb 10, 2024.

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

Description

Bug description

When using lst-label and lst-cap, the formatting of R chunks is messed up.

When rendering to a pdf, the code is ugly (no syntax coloring, or background shading) but acceptable.
When rendering to a .docx, the code is worse. It is centered, rather than being left-justified, there is no syntax coloring, although the background is shaded.
In the docx file, the code is shown as using the "Source Code" style, but the style settings are over-ridden
The messed up docx occurs whether or not a template docx file is used.

Steps to reproduce
---
title: "Reproducible Quarto Document"
format: docx
engine: knitr
---

This is a minimal self-contained reproducible Quarto document using `format: docx` and `knitr` engine.
It is written in Markdown and contains embedded R code.

This chunk uses the label and caption settings
```{r}
#| warning: false
#| output: false
#| eval: false
#| lst-label: lst-setpaths
#| lst-cap: Set file paths. The paths will need to be edited for your system.  
output_path <- "output/"
figure_path <- "figures/"
```

This one does not
```{r}
output_path <- "output/"
figure_path <- "figures/"
```
Expected behavior

The first chunk should be rendered in the same way as the second,i.e. with syntax colouring, and left-justified text.

Actual behavior

The second chunk renders correctly. The first chunk is not formatted properly. When rendered to a pdf there is no code syntax colouring. When rendered to a .docx, the code is centred and there is no syntax coloring.

Your environment

IDE: Rstudio 2023.12.1 Build 402
OS: Linux Mint Linux Mint 21.3

Quarto check output

Quarto 1.4.549
[✓] 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.549
Path: /opt/quarto/bin

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

[✓] Checking LaTeX....................OK
Using: TinyTex
Path: /home/kevin/.TinyTeX/bin/x86_64-linux
Version: 2023

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

[✓] Checking Python 3 installation....OK
Version: 3.10.12
Path: /usr/bin/python3
Jupyter: 5.7.1
Kernels: python3

[✓] Checking Jupyter engine render....OK

R scripting front-end version 4.1.2 (2021-11-01)
[✓] Checking R installation...........(None)

No idea why I get that message about not finding R.
R is running just fine in Rstudio.
Have not had any other issues running Quarto thru Rstudio

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.