The following document can result in the code listing floating away from its annotations:

````markdown
---
title: Hello World
format: html
---

## Hello

{{< lipsum 1-2 >}}

```{#lst-customers .r lst-cap="Customers Query"}


# this is a comment that adds length to the code block
# this is a comment that adds length to the code block
# this is a comment that adds length to the code block

library(tidyverse)

# this is a comment that adds length to the code block
# this is a comment that adds length to the code block
# this is a comment that adds length to the code block

library(palmerpenguins)
penguins |>                                      # <1>
  mutate(                                        # <2>
    bill_ratio = bill_depth_mm / bill_length_mm, # <2>
    bill_area  = bill_depth_mm * bill_length_mm  # <2>
  )                                              # <2>
```
1. Take `penguins`, and then,
2. add new columns for the bill ratio and bill area.

{{< lipsum 3-4 >}}
````

note that we define the code listing environment as:

```latex
\\@ifundefined{c@chapter}{\\newfloat{codelisting}{h}{lop}}{\\newfloat{codelisting}{h}{lop}[chapter]}
```

We should create an option for float hold, always float hold, or do something smarter here.
dragonstyle
2023-04-10T13:35:58Z
dragonstyle
bug
v1.3
closed
In PDF output, code listings can float away from their annotations
https://github.com/quarto-dev/quarto-cli/issues/5142