quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.99k stars 328 forks source link

Long code block inside callout not rendered properly #5302

Open Edoch94 opened 1 year ago

Edoch94 commented 1 year ago

Bug description

Running the quarto render on a project folder with a .qmd file that includes a long code block inside a callout block, generates a odd-formatted pdf file, as the one in attachment test.pdf

Here a sample .md (.qmd) that causes this issue test.md

The YAML of the project is the following

project:
  title: "qproject"
  output-dir: output

format:    
  pdf: 
    toc: true
    toc-depth: 2
    number-sections: true
    code-line-numbers: true
    code-block-bg: "#f0f3f5"
    cap-location: top

I'm running quarto 1.2.335

> quarto --version
1.2.335

on vscode 1.77.3

> code --version
1.77.3
704ed70d4fd1c6bd6342c436f1ede30d1cff4710
x64

on Ubuntu 22.04 LTS

> lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.2 LTS
Release:    22.04
Codename:   jammy

quarto check returns the following

> quarto check

[✓] Checking Quarto installation......OK
      Version: 1.2.335
      Path: /opt/quarto/bin

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

[✓] Checking Python 3 installation....OK
      Version: 3.9.16 (Conda)
      Path: /home/edoardo/miniconda3/envs/DABDPA/bin/python
      Jupyter: 5.3.0
      Kernels: python3, bash

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

[✓] Checking R installation...........(None)

      Unable to locate an installed version of R.
      Install R from https://cloud.r-project.org/

Checklist

dragonstyle commented 1 year ago

This is a result of using tcolorbox in LaTeX to produce both the outer callout and and the code formatting. We are attempting to make them both breakable, allowing them to span pages, but this is explicitly forbidden by tcolorbox (TIL):

You can nest an unbreakable tcolorbox inside another tcolorbox, even inside a breakable one. But you cannot not nest a breakable box inside a breakable box. The /tcb/breakable key for a nested box is ignored automatically, i. e. inner boxes are always unbreakable.

After all, in the unlikely case you really want to have the nested box to be breakable, use /tcb/enforce breakable for the nested box. But, a breakable box inside a breakable box will usually give a mess.

We'll need to address this one way or another (perhaps by dropping tcolorbox for code formatting or finding some other workaround).