quarto-dev / quarto-dev/quarto-cli
LaTeX - Floats defined by `newfloat` don't support subfloats: listings, custom crossrefs, etc.
@cscheid is already working on this.
Since Apr 24, 2024.
- Dominant language
- JavaScript
- Stars
- 6k
- Forks
- 458
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 41
Description
Bug description
Issue: Sublistings Failing to Render in PDF Output
When attempting to render a Quarto document to PDF, sublistings are not being supported.
The error varies depending on whether the listings option is enabled or disabled.
I have expected to work the same way as figures.
It works as expected for the HTML output.
Possible Solution
-
When
listings: true: Define thecodelistingenvironment within the LaTeX preamble to mimic the behavior of figures, allowing for the inclusion of captions and references for code listings. -
When
listings: false: Add initialization of the `subcodelisting' counter to the default TeX template/preamble.
Additional Notes
The expected functionality was assumed to be analogous to that of figures within the document.
However, due to my limited knowledge in Quarto, LaTeX, and Lua, I am not able to provide a more comprehensive solution.
Steps to reproduce
---
title: Sublistings Issue
format:
pdf:
listings: true
keep-tex: true
---
:::: {#lst-multiple-listings}
::: {#lst-foo}
```{.json}
{
"test": "foo"
}
```
Foo
:::
::: {#lst-bar}
```{.json}
{
"test": "bar"
}
```
Bar
:::
::::
Referencing listing group @lst-multiple-listings.
Referencing sublistings @lst-foo, @lst-bar.
Expected behavior
The document should render to PDF without any errors, supporting sublistings similar to how sub-figures are handled.
Actual behavior
When listings: true
sublistings_issue_listings_true.log
quarto render sublistings_issue.qmd
pandoc
to: latex
output-file: sublistings_issue.tex
standalone: true
pdf-engine: xelatex
variables:
graphics: true
tables: true
default-image-extension: pdf
listings: true
metadata
documentclass: scrartcl
classoption:
- DIV=11
- numbers=noendperiod
papersize: letter
header-includes:
- '\KOMAoption{captions}{tableheading}'
block-headings: true
title: Sublistings Issue
Rendering PDF
running xelatex - 1
This is XeTeX, Version 3.141592653-2.6-0.999996 (TeX Live 2024) (preloaded format=xelatex)
restricted \write18 enabled.
entering extended mode
updating tlmgr
updating existing packages
ERROR:
compilation failed- error
LaTeX Error: Environment codelisting undefined.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.149 \begin{codelisting}
see sublistings_issue.log for more information.
ERROR: Error
at renderFiles (file:///opt/quarto/bin/quarto.js:77074:29)
at eventLoopTick (ext:core/01_core.js:183:11)
at async render (file:///opt/quarto/bin/quarto.js:81807:21)
at async Command.fn (file:///opt/quarto/bin/quarto.js:81954:32)
at async Command.execute (file:///opt/quarto/bin/quarto.js:8104:13)
at async quarto (file:///opt/quarto/bin/quarto.js:114968:5)
at async file:///opt/quarto/bin/quarto.js:114986:9
When listings: false
sublistings_issue_listings_false.log
quarto render sublistings_issue.qmd
pandoc
to: latex
output-file: sublistings_issue.tex
standalone: true
pdf-engine: xelatex
variables:
graphics: true
tables: true
default-image-extension: pdf
listings: false
metadata
documentclass: scrartcl
classoption:
- DIV=11
- numbers=noendperiod
papersize: letter
header-includes:
- '\KOMAoption{captions}{tableheading}'
block-headings: true
title: Sublistings Issue
Rendering PDF
running xelatex - 1
This is XeTeX, Version 3.141592653-2.6-0.999996 (TeX Live 2024) (preloaded format=xelatex)
restricted \write18 enabled.
entering extended mode
updating tlmgr
updating existing packages
ERROR:
compilation failed- error
Package caption Error: Undefined counter `subcodelisting'.
See the caption package documentation for explanation.
Type H <return> for immediate help.
...
l.194 \subcaption
{\label{lst-foo}Foo}
see sublistings_issue.log for more information.
ERROR: Error
at renderFiles (file:///opt/quarto/bin/quarto.js:77074:29)
at eventLoopTick (ext:core/01_core.js:183:11)
at async render (file:///opt/quarto/bin/quarto.js:81807:21)
at async Command.fn (file:///opt/quarto/bin/quarto.js:81954:32)
at async Command.execute (file:///opt/quarto/bin/quarto.js:8104:13)
at async quarto (file:///opt/quarto/bin/quarto.js:114968:5)
at async file:///opt/quarto/bin/quarto.js:114986:9
Rendering to HTML
Rendering to HTML works without errors, output looks as expected.
quarto render sublistings_issue.qmd --to html
pandoc
to: html
output-file: sublistings_issue.html
standalone: true
section-divs: true
html-math-method: mathjax
wrap: none
default-image-extension: png
metadata
document-css: false
link-citations: true
date-format: long
lang: en
title: Sublistings Issue
Output created: sublistings_issue.html
Your environment
- IDE: Notepad + Terminal
- OS: Linux Mint 20.3 Cinnamon
Quarto check output
quarto check
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: v2024.03.13
Chromium: 869685
[✓] Checking LaTeX....................OK
Using: TinyTex
Path: /home/bertlluk/.TinyTeX/bin/x86_64-linux
Version: 2024
[✓] Checking basic markdown render....OK
[✓] Checking Python 3 installation....OK
Version: 3.8.10
Path: /usr/bin/python3
Jupyter: 5.3.0
Kernels: python3
[✓] 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/
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.