Summary
algorithm2e (LaTeX) numbers every algorithm line continuously (1…N) and conveys nesting — while / for / repeat bodies — through indentation. When such an algorithm is rendered in MyST (e.g. inside a {prf:algorithm} directive), the natural representation is an ordered list with a nested ordered list for each loop body. But CommonMark restarts numbering at 1 for every nested list, so the loop body is numbered 1, 2, 3… again instead of continuing the outer count.
Example
1. $t \leftarrow 0$
2. input $X_0$
3. **while** $t < \infty$ **do**
1. observe $X_t$
2. choose action $A_t$
3. receive reward $r(X_t, A_t)$
4. draw $X_{t+1}$ from $P(X_t, A_t, \cdot)$
5. $t \leftarrow t + 1$
4. **end**
Renders as: 1, 2, 3, then 1, 2, 3, 4, 5 (restarted), then 4.
algorithm2e (PDF) renders as: continuous 1 … 9, with the loop body indented but its line numbers continuing the sequence.
Request
An enhancement so algorithm-style content can render with continuous line numbering across nested blocks while keeping the indentation that shows loop/conditional structure — i.e. algorithm2e parity. This may take the form of a {prf:algorithm} option, a list-numbering mode, or directive-level support; the exact mechanism is open.
Context
Surfaced converting the QuantEcon Dynamic Programming Volume I book; reported downstream at QuantEcon/book-dp-public#31 (item 1). The converter side is tracked at QuantEcon/claude-latex-to-myst#169 — this upstream issue is the likely home if continuous-numbering-with-indentation cannot be produced in plain MyST/CommonMark.
Summary
algorithm2e(LaTeX) numbers every algorithm line continuously (1…N) and conveys nesting —while/for/repeatbodies — through indentation. When such an algorithm is rendered in MyST (e.g. inside a{prf:algorithm}directive), the natural representation is an ordered list with a nested ordered list for each loop body. But CommonMark restarts numbering at 1 for every nested list, so the loop body is numbered 1, 2, 3… again instead of continuing the outer count.Example
Renders as: 1, 2, 3, then 1, 2, 3, 4, 5 (restarted), then 4.
algorithm2e (PDF) renders as: continuous 1 … 9, with the loop body indented but its line numbers continuing the sequence.
Request
An enhancement so algorithm-style content can render with continuous line numbering across nested blocks while keeping the indentation that shows loop/conditional structure — i.e. algorithm2e parity. This may take the form of a
{prf:algorithm}option, a list-numbering mode, or directive-level support; the exact mechanism is open.Context
Surfaced converting the QuantEcon Dynamic Programming Volume I book; reported downstream at QuantEcon/book-dp-public#31 (item 1). The converter side is tracked at QuantEcon/claude-latex-to-myst#169 — this upstream issue is the likely home if continuous-numbering-with-indentation cannot be produced in plain MyST/CommonMark.