Skip to content

main.lua error in PDF with reference-location = margin #14358

@pbradl42

Description

@pbradl42

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'm getting a failure from main.lua in very specific circumstances. It takes a few files to replicate.

It appears to be something to do with footnotes and images. The files below are a 'book' template. The index.qmd has a footnote and does not fail. the file 'error_doesnotfail.qmd' has a footnote and a table and does not fail. The 'error_fails.qmd' has a footnote and an image and fails. If you change 'reference-location' _quarto.yml to anything other than 'margin', it does not fail.

It only fails on compiling PDF.

Steps to reproduce

Separate _quarto.yml file:

project:
type: book
output-dir: docs

book:
title: "Reproducible error"
author: "Peter Bradley"
editor: source
chapters:
- index.qmd ## Index.qmd can have a footnote in the margin
- error-doesnotfail.qmd
- error-fails.qmd ## This crashes iff 'reference-location: margin' in the PDF section below
execute:
debug: true
keep-md: true
format:
pdf:
toc: true
number-sections: true
reference-location: margin # document, section, block all work, 'margin' fails.
html:
theme: cosmo
toc: true
number-sections: true
reference-location: margin

Index.qmd:

::: {.content-hidden when-format="html"}

Preface

:::

::: {.content-hidden when-format="pdf"}

Welcome

:::
Follow guidelines for reproducible research in data science.1 It is produced using the open source technical publishing system quarto.

About the layout

This book is compiled using Quarto in RStudio. The creation of HTML and PDF versions is handled by pandoc and MacTex.

Many thanks to all those who contributed to these projects over the years.


error_doesnotfail.qmd:


title: "Tables"
editor: source

library(tidyverse)

This is some text2

#| tbl-cap: "This is table 1"
#| label: tbl-table-1

iris

error-fails.qmd:

title: "Images"
editor: source

library(tidyverse)

Chapter 1 text3

#| fig-cap: "Figure 1"

iris %>% ggplot(aes(x=Sepal.Length, y=Sepal.Width)) + geom_point()

Actual behavior

After compilation to multimarkdown files:

Error running filter /Applications/quarto/share/filters/main.lua:
/Applications/quarto/share/filters/main.lua:212: attempt to get length of a Block value (local 'blocks')
stack traceback:
/Applications/quarto/share/filters/main.lua:355: in upvalue 'process_content'
/Applications/quarto/share/filters/main.lua:462: in upvalue 'process_block_or_inline'
/Applications/quarto/share/filters/main.lua:473: in upvalue 'inner'
/Applications/quarto/share/filters/main.lua:271: in upvalue 'process_inlines'
/Applications/quarto/share/filters/main.lua:359: in upvalue 'process_content'
/Applications/quarto/share/filters/main.lua:462: in upvalue 'process_block_or_inline'
/Applications/quarto/share/filters/main.lua:473: in upvalue 'inner'
/Applications/quarto/share/filters/main.lua:215: in upvalue 'process_blocks'
/Applications/quarto/share/filters/main.lua:475: in function </Applications/quarto/share/filters/main.lua:466>
(...tail calls...)
/Applications/quarto/share/filters/main.lua:12297: in field 'Pandoc'
/Applications/quarto/share/filters/main.lua:588: in function 'run_emulated_filter'
/Applications/quarto/share/filters/main.lua:1317: in local 'callback'
/Applications/quarto/share/filters/main.lua:1335: in upvalue 'run_emulated_filter_chain'
/Applications/quarto/share/filters/main.lua:1371: in function </Applications/quarto/share/filters/main.lua:1368>

Expected behavior

Rendering PDF
running lualatex - 1
This is LuaHBTeX, Version 1.21.0 (TeX Live 2025)
restricted system commands enabled.

running lualatex - 2
This is LuaHBTeX, Version 1.21.0 (TeX Live 2025)
restricted system commands enabled.

Output created: docs/index.html

Your environment

RStudio and Positron. Running quarto from the command line, version 1.9.36
MacOS 14.6.1

R version 4.4.3

Quarto check output

Quarto 1.9.36
[✓] Checking environment information...
Quarto cache location: /Users/pbradley/Library/Caches/quarto
[✓] Checking versions of quarto binary dependencies...
Pandoc version 3.8.3: OK
Dart Sass version 1.87.0: OK
Deno version 2.4.5: OK
Typst version 0.14.2: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
Version: 1.9.36
Path: /Applications/quarto/bin

[✓] Checking tools....................OK
TinyTeX: (not installed)
Chromium: (not installed)
Chrome Headless Shell: (not installed)
VeraPDF: (not installed)

[✓] Checking LaTeX....................OK
Using: Installation From Path
Path: /Library/TeX/texbin
Version: 2025

[✓] Checking Chrome Headless....................OK
Using: Chrome found on system
Path: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
Source: MacOS known location

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

[✓] Checking R installation...........OK
Version: 4.4.3
Path: /Library/Frameworks/R.framework/Resources
LibPaths:
- /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library
knitr: 1.51
rmarkdown: 2.30

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

[✓] Checking Python 3 installation....OK
Version: 3.12.4 (Conda)
Path: /opt/miniconda3/bin/python
Jupyter: 5.7.2
Kernels: python3

Traceback (most recent call last):
File "/Applications/quarto/share/jupyter/jupyter.py", line 20, in
from notebook import notebook_execute, RestartKernel
File "/Applications/quarto/share/jupyter/notebook.py", line 15, in
from yaml import safe_load as parse_string
ModuleNotFoundError: No module named 'yaml'
(|) Checking Jupyter engine render....WARN: Error encountered when rendering files
[✓] Checking Jupyter engine render....OK

Footnotes

  1. See, e.g. Peng RD. Reproducible research in computational science. Science. 2011 Dec 2;334(6060):1226-7. doi: 10.1126/science.1213847. PMID: 22144613; PMCID: PMC3383002

  2. with a footnote

  3. here's a footnote

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds-reproIssues that are blocked until reporter provides an adequate reproduction

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions