Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent behaviour between html and pdf for lists with (@) #11836

Open
kandolfp opened this issue Jan 10, 2025 · 3 comments
Open

Inconsistent behaviour between html and pdf for lists with (@) #11836

kandolfp opened this issue Jan 10, 2025 · 3 comments
Labels
books enhancement New feature or request
Milestone

Comments

@kandolfp
Copy link

Bug description

For a book, the numbering for lists when using (@) is not consistent over various formats. For html it will always start at zero for each new file (chapter) but in pdf it continuous for the entire document.

I would prefer the html behaviour for pdf but an option like continuous-numbering would be perfect.

Steps to reproduce

You can reproduce the example with the following files:

  • index.qmd
# Index

(@) one
(@) two
  • file.qmd
# First Chapter

(@) one
(@) two
  • _quarto.yml
project:
  type: book

book:
  title: "Debugging"
  date: last-modified
  chapters:
    - index.qmd
    - file.qmd

format:
  html:
  pdf:
    documentclass: scrreprt
    keep-tex: true

Expected behavior

pdf and html have the same numbering, i.e. in the index

  1. first
  2. second

and in the first chapter

  1. first
  2. second

To generate the pdf I use

pdm run quarto render --to pdf

Actual behavior

The pdf has the numbering (over multiple pages)

  1. first
  2. second

and in the first chapter

  1. first
  2. second

Your environment

Ubuntu 24.04
Quarto > 1.6.40 (tested also with latest build on github)

Quarto check output

quarto check
Quarto 1.6.40
[✓] Checking environment information...
      Quarto cache location: ~/.cache/quarto
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.4.0: OK
      Dart Sass version 1.70.0: OK
      Deno version 1.46.3: OK
      Typst version 0.11.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.6.40
      Path: /tmp/quartobug/.venv/lib/python3.12/site-packages/quarto_cli/bin

[✓] Checking tools....................OK
      TinyTeX: (not installed)
      Chromium: (not installed)

[✓] Checking LaTeX....................OK
      Using: Installation From Path
      Path: /usr/bin
      Version: 2023

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

[✓] Checking Python 3 installation....OK
      Version: 3.12.3
      Path: /tmp/quartobug/.venv/bin/python
      Jupyter: 5.7.2
      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/
@kandolfp kandolfp added the bug Something isn't working label Jan 10, 2025
@cderv cderv added the books label Jan 10, 2025
@cderv
Copy link
Collaborator

cderv commented Jan 10, 2025

I believe this is related to Pandoc behavior which will continue example list for the entire document.

And with Quarto

  • Quarto Book in HTML is made of several document rendered with Pandoc that are transform to a HTML book website. HTML book is not a format from Pandoc.
  • Quarto Book in PDF is made of a single PDF that is rendered using a book document class. All the rendered .qmd file are compiled into one .md file for Panodc to render to .tex file.

The example_list feature of Pandoc will then have continuation, as they document: https://pandoc.org/MANUAL.html#extension-example_lists

They don't document if an example list can be stopped and restarted 🤔 It seems the ending a list part https://pandoc.org/MANUAL.html#ending-a-list does not apply.

@tarleb do you know ?

I would prefer the html behaviour for pdf but an option like continuous-numbering would be perfect.

As of now, this would rather be html behavior not following the Pandoc default behavior. But probably starting at one chapter, or having a way to number the example by chapter in book could be good.

I wonder what we could do through Lua to tweak this 🤔

It seems Pandoc does a special Treatment on OrderedList

❯ quarto pandoc -t native 
# Preface {.unnumbered}

(@) one
(@) two

Some content

(@) one
(@) two
^Z
[ Header
    1 ( "preface" , [ "unnumbered" ] , [] ) [ Str "Preface" ]
, OrderedList
    ( 1 , Example , TwoParens )
    [ [ Plain [ Str "one" ] ] , [ Plain [ Str "two" ] ] ]
, Para [ Str "Some" , Space , Str "content" ]
, OrderedList
    ( 3 , Example , TwoParens )
    [ [ Plain [ Str "one" ] ] , [ Plain [ Str "two" ] ] ]
]

Changing the start number in OrderedList could work if we manage to find start and end of chapter...
but does Example style on OrderedList insure this was an example list used ? 🤔

I don't think so because, it seems this is equivalent to

(1) one
(2) two

Some content

(3) one
(4) two

So example_list is really about continuation through a document 🤔

This needs thinking of what could be done, if something. Otherwise, maybe this is Pandoc feature request 🤷‍♂ for PDF book format.

Or maybe .tex post processing to change \setcounter{enumi} value.

\begin{enumerate}
\def\labelenumi{(\arabic{enumi})}
\setcounter{enumi}{2}
\tightlist
\item
  one
\item
  two
\end{enumerate}

Not straighforward to have this feature but nice problem if someone wants to search for a possible workaround using Lua or else. 🤷

@cderv cderv added enhancement New feature or request and removed bug Something isn't working labels Jan 10, 2025
@cderv
Copy link
Collaborator

cderv commented Jan 10, 2025

And regarding

As of now, this would rather be html behavior not following the Pandoc default behavior.

I don't know if it is better to keep the difference between HTML and PDF here, or try to "fix" which would mean be sure that HTML does have continuation like.

Other thought:

Example list in Pandoc exist also as a way to reference some Example content easily. Quarto has its own Cross Reference feature for which you can have numbered Example that can be crossreferenced
Using defined example one: https://quarto.org/docs/authoring/cross-references.html#theorems-and-proofs
or
Using custom floats to define a specific one for example: https://quarto.org/docs/authoring/cross-references-custom.html

So maybe example_list feature from Pandoc should not really be used cross format.

@cderv cderv added this to the Future milestone Jan 10, 2025
@kandolfp
Copy link
Author

Thanks for having such a detailed look at it!! I'll ask in the pandoc repo, it might be similar to jgm/pandoc#5709

For my document, I worked around it with some reshuffling of the text and the references you provided (thanks once more)

I also found this related Q&A and link it here just for reference: #7496

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
books enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants