jupyter-book icon indicating copy to clipboard operation
jupyter-book copied to clipboard

Equation numbering breaks for orphan pages

Open matthew-brett opened this issue 2 years ago • 4 comments

Describe the bug

I have some optional pages in my book, not in the table of contents, that contain math. They are therefore orphan pages, and marked as such.

Equation numbering fails for these pages - example:

https://uob-ds.github.io/cfd2021/extra/mean_sq_deviations.html

In particular, the equation numbers are always set as ().

I was expecting the equation numbers to work the same way in orphan and not-orphan pages.

Reproduce the bug

git clone https://github.com/matthew-brett/jb-math-numbering
cd jb-math-numbering
make
open _build/html/math2.html

List your environment

$ jupyter-book --version
Jupyter Book      : 0.13.0
External ToC      : 0.2.4
MyST-Parser       : 0.15.2
MyST-NB           : 0.13.2
Sphinx Book Theme : 0.3.2
Jupyter-Cache     : 0.4.3
NbClient          : 0.5.11
$ python --version
Python 3.9.10

macOS 11.6.5

matthew-brett avatar Jun 07 '22 10:06 matthew-brett

thanks @matthew-brett this is an interesting issue. I'm guessing that sphinx when building the html doesn't have chapter / section numbers defined when parsing orphan documents so skips writing a reference number as that document isn't part of the doctree structure of the project.

@AakashGfude any ideas here from your work on quantecon-book-theme when you added chapter numbers to equations?

mmcky avatar Jun 08 '22 04:06 mmcky

@mmcky unfortunately that concerns only things in toc. Will look at the math directive properly.

AakashGfude avatar Jun 22 '22 02:06 AakashGfude

@mmcky the equation number and labels, are stored in the env.toc_fignumbers variable which we had come across in sphinx-exercise, and sphinx-proof extensions as well. Since these are only populated by the docs in the toc, so this issue is imminent.

AakashGfude avatar Jun 22 '22 13:06 AakashGfude

@AakashGfude It isn't clear to me what the solution should be however. If a document is not contained in the toc there is no concept of chapter. So I see two possibilities.

  1. Add reference material at the end of a project in an appropriately named part
  2. if env.toc_fignumbers is not defined for a document then number the equations sequentially in that page only.

mmcky avatar Jun 27 '22 01:06 mmcky