Skip to content

The chapters are incorrectly numbered based on lexicographical ordering of the book part file names (Jupyter Book) #17

Open
@So-Cool

Description

@So-Cool

Describe the bug

The following ToC

- file: intro

- part: b
  numbered: 2
  chapters:
  - file: chapter1
  - file: chapter2

- part: a
  numbered: 2
  chapters:
  - file: chapter3

always produces the correct chapter numbering:

Welcome to your Jupyter Book

B
1. ch1
2. ch2

A
3. ch3

However, when the parts are sourced from files the chapter numbering order depends on the lexicographical ordering of the book part file names, i.e.:

- file: intro

- part:
  numbered: 2
  file: a
  chapters:
  - file: chapter1
  - file: chapter2

- part:
  numbered: 2
  file: b
  chapters:
  - file: chapter3

give the correct numbering:

Welcome to your Jupyter Book

a
1. ch1
2. ch2

b
3. ch3

but

- file: intro

- part:
  numbered: 2
  file: b
  chapters:
  - file: chapter1
  - file: chapter2

- part:
  numbered: 2
  file: a
  chapters:
  - file: chapter3

reorders the numbering:

Welcome to your Jupyter Book

b
2. ch1
3. ch2

a
1. ch3

To Reproduce

  1. Build a Jupyter Book with the following _toc.yml:
    - file: intro
    
    - part:
      numbered: 2
      file: b
      chapters:
      - file: chapter1
      - file: chapter2
    
    - part:
      numbered: 2
      file: a
      chapters:
      - file: chapter3
    
    It is important to preserve the naming of the part files, i.e., a.md and b.md
  2. The chapter numbering sequence is determined by the lexicographical ordering of the book part file names

Expected behavior

The chapter numbering should be consistent with the order given in the _toc.yml file.

Environment

  • Python Version [e.g. 3.7.1]: 3.8.2
  • Package versions or output of jupyter-book --version: 0.1.2 (6683e3f)
  • Operating System: MacOS 10.15.6

Additional context

Jupyter Book: 0.9.1
MyST-NB: 0.10.1
Sphinx Book Theme: 0.0.39
MyST-Parser: 0.12.10
Jupyter-Cache: 0.4.1
NbClient: 0.5.1

Jupyter Book installed from the latest master branch commit (jupyter-book/jupyter-book@3845dd5)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions