quarto-dev / quarto-dev/quarto-cli

Code cell option "layout-ncol" for multiple figures produces error when embedded in another document

Open
#12,988 2 comments 1 reaction 1 assignee View on GitHub

@cderv is already working on this.

Since Jun 27, 2025.

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

Description

I have:
  • searched the issue tracker for similar issues
  • installed the latest version of Quarto CLI
  • formatted my issue following the Bug Reports guide
Bug description

I am a huge fan of the embeddings functionality in Quarto, as it in principle perfectly fits my personal preference of having one manuscript document for writing and, depending on the extent of the project, one or more code documents for the data science part. I then embed figures I produce in these code documents in my manuscript, which usually works fine (aside from lower resolutions in pdf outputs as already reported here and here, which is another problem for itself).

EDIT July 27th 2025: Above mentioned lower resolution issues can be solved (for knitr) by including #| fig-dpi: 300 in the source code cell of the wanted figure.

However, I cannot render my manuscript document (with the embed command in it) once my code cell producing the desired figures contains the layout-ncol option (same for layout-nrow), even though there is an example of exactly that in the documentation.

Steps to reproduce

I have added a minimal reproducible example with one manuscript.qmd file in which two embed calls are included as well as two code documents code_1.qmd and code_2.qmd in which the code cells are contained. Both code files essentially produce the same ggplots, the only difference is that in code_2.qmd, I use #| layout-ncol: 2 to make the subplots appear next to each other in the final output. Removing this option allows for rendering again, but also by default prints the subplots in separate rows.

The error persists when changing the output format from pdf to html.

manuscript.qmd

---
title: "Title"
author: "Firstname Lastname"
date: last-modified
date-format: long
format: pdf
---

# Introduction

{{< lipsum 1 >}}

# Embedding 1

{{< embed code_1.qmd#fig-penguins >}}

# Embedding 2

{{< embed code_2.qmd#fig-penguins-row >}}

code_1.qmd

---
title: "code_1"
format: html
---


```{r}
#| label: fig-penguins
#| fig-cap: "Distribution of Bill Characteristics Across Penguin Species"
#| fig-subcap:
#|   - "Bill Length"
#|   - "Bill Depth"

library(tidyverse)
library(palmerpenguins)

ggplot(penguins) +
  geom_violin(aes(x = species,
                  y = bill_length_mm)) +
  theme_bw()

ggplot(penguins) +
  geom_violin(aes(x = species,
                  y = bill_depth_mm)) +
  theme_bw()
```

code_2.qmd

---
title: "code_2"
format: html
---


```{r}
#| label: fig-penguins-row
#| fig-cap: "Distribution of Bill Characteristics Across Penguin Species"
#| fig-subcap:
#|   - "Bill Length"
#|   - "Bill Depth"
#| layout-ncol: 2

library(tidyverse)
library(palmerpenguins)

ggplot(penguins) +
  geom_violin(aes(x = species,
                  y = bill_length_mm)) +
  theme_bw()

ggplot(penguins) +
  geom_violin(aes(x = species,
                  y = bill_depth_mm)) +
  theme_bw()
```
Actual behavior

This is the output when I try to render manuscript.qmd

==> quarto preview manuscript.qmd --to pdf --no-watch-inputs --no-browse

Rendering qmd embeds
[1/2] code_1.qmd


processing file: code_1.qmd
                                                                                                         
output file: code_1.knit.md

[2/2] code_2.qmd


processing file: code_2.qmd
                                                                                                             
output file: code_2.knit.md

Error running filter C:/Users/Tris/AppData/Local/Programs/Quarto/share/filters/main.lua:
Block, list of Blocks, or compatible element expected, got Blocks
	while retrieving function argument content
	while retrieving arguments for function Div
stack traceback:
	...ris/AppData/Local/Programs/Quarto/share/filters/main.lua:23672: in field 'render'
	...ris/AppData/Local/Programs/Quarto/share/filters/main.lua:1217: in local 'filter_fn'
	...ris/AppData/Local/Programs/Quarto/share/filters/main.lua:653: in function <...ris/AppData/Local/Programs/Quarto/share/filters/main.lua:643>
	(...tail calls...)
	...uarto\share\pandoc\datadir\..\..\filters\modules/jog.lua:34: in upvalue 'run_filter_function'
	...uarto\share\pandoc\datadir\..\..\filters\modules/jog.lua:223: in function <...uarto\share\pandoc\datadir\..\..\filters\modules/jog.lua:202>
	(...tail calls...)
	[C]: in function 'pandoc.List.map'
	...uarto\share\pandoc\datadir\..\..\filters\modules/jog.lua:125: in upvalue 'recurse'
	...uarto\share\pandoc\datadir\..\..\filters\modules/jog.lua:222: in local 'jogger'
	...uarto\share\pandoc\datadir\..\..\filters\modules/jog.lua:171: in upvalue 'recurse'
	...uarto\share\pandoc\datadir\..\..\filters\modules/jog.lua:222: in function <...uarto\share\pandoc\datadir\..\..\filters\modules/jog.lua:202>
	(...tail calls...)
	...ris/AppData/Local/Programs/Quarto/share/filters/main.lua:572: in function <...ris/AppData/Local/Programs/Quarto/share/filters/main.lua:550>
	(...tail calls...)
	...ris/AppData/Local/Programs/Quarto/share/filters/main.lua:1318: in local 'callback'
	...ris/AppData/Local/Programs/Quarto/share/filters/main.lua:1336: in upvalue 'run_emulated_filter_chain'
	...ris/AppData/Local/Programs/Quarto/share/filters/main.lua:1372: in function <...ris/AppData/Local/Programs/Quarto/share/filters/main.lua:1369>
ERROR: Rendering of qmd notebook produced an unexpected result
Expected behavior

Ideally it should work just like the jupyter notebook example in the Quarto documentation, i.e. include the figure as desired in the rendered document.

Your environment
> sessioninfo::session_info()
─ Session info ─────────────
 setting  value
 version  R version 4.4.3 (2025-02-28 ucrt)
 os       Windows 11 x64 (build 22621)
 system   x86_64, mingw32
 ui       RStudio
 language (EN)
 collate  English_United States.utf8
 ctype    English_United States.utf8
 tz       Europe/Berlin
 date     2025-06-26
 rstudio  2025.05.1+513 Mariposa Orchid (desktop)
 pandoc   NA

─ Packages ─────────────────
 package     * version date (UTC) lib source
 cli           3.6.5   2025-04-23 [1] CRAN (R 4.4.3)
 rstudioapi    0.17.1  2024-10-22 [1] CRAN (R 4.4.3)
 sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.4.1)

 [1] C:/Users/Tris/AppData/Local/R/win-library/4.4
 [2] C:/Program Files/R/R-4.4.3/library

────────────────────────────
Quarto check output
$ quarto check
Quarto 1.7.31
[>] Checking environment information...
      Quarto cache location: C:\Users\Tris\AppData\Local\quarto
[>] Checking versions of quarto binary dependencies...
      Pandoc version 3.6.3: OK
      Dart Sass version 1.85.1: OK
      Deno version 1.46.3: OK
      Typst version 0.13.0: OK
[>] Checking versions of quarto dependencies......OK
[>] Checking Quarto installation......OK
      Version: 1.7.31
      Path: C:\Users\Tris\AppData\Local\Programs\Quarto\bin
      CodePage: 1252

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

[>] Checking LaTeX....................OK
      Using: TinyTex
      Path: C:\Users\Tris\AppData\Roaming\TinyTeX\bin\windows\
      Version: 2025

[>] Checking Chrome Headless....................OK
      Using: Chrome found on system
      Path: C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe
      Source: Windows Registry

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

[>] Checking Python 3 installation....(None)

      Unable to locate an installed version of Python 3.
      Install Python 3 from https://www.python.org/downloads/

[>] Checking R installation...........OK
      Version: 4.4.3
      Path: C:/PROGRA~1/R/R-44~1.3
      LibPaths:
        - C:/Users/Tris/AppData/Local/R/win-library/4.4
        - C:/Program Files/R/R-4.4.3/library
      knitr: 1.50
      rmarkdown: 2.29

[>] Checking Knitr engine render......OK

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.