From b92adbbe4b10cf17bc09ad2134abec31b5241068 Mon Sep 17 00:00:00 2001 From: Alan Lujan Date: Wed, 19 Aug 2026 11:28:48 -0400 Subject: [PATCH] Render algorithm, assumption, criterion and property in LaTeX export kindToEnvironment mapped 11 of the 15 PROOF_KINDS. The other four matched no case and were dropped from the .tex output along with their labels, so cross-references to them rendered as ??. Adds the four cases, their \newtheorem declarations, and fixture coverage for each. Also corrects proof:criteria to proof:criterion in the proof-kinds table, since the registered kind is criterion. --- .changeset/olive-donkeys-shave.md | 5 ++ docs/proofs-and-theorems.md | 2 +- packages/myst-to-tex/src/proof.ts | 12 ++++ packages/myst-to-tex/tests/proofs.spec.ts | 12 ++++ packages/myst-to-tex/tests/proofs.yml | 80 +++++++++++++++++++++++ 5 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 .changeset/olive-donkeys-shave.md create mode 100644 packages/myst-to-tex/tests/proofs.spec.ts diff --git a/.changeset/olive-donkeys-shave.md b/.changeset/olive-donkeys-shave.md new file mode 100644 index 0000000000..c4ecc8044c --- /dev/null +++ b/.changeset/olive-donkeys-shave.md @@ -0,0 +1,5 @@ +--- +'myst-to-tex': patch +--- + +Render algorithm, assumption, criterion, and property proof kinds in LaTeX export diff --git a/docs/proofs-and-theorems.md b/docs/proofs-and-theorems.md index 78c3962b92..71edd1f788 100644 --- a/docs/proofs-and-theorems.md +++ b/docs/proofs-and-theorems.md @@ -48,7 +48,7 @@ The vector $\hat y$ is called the **orthogonal projection** of $y$ onto $S$. - `proof:axiom` - `proof:conjecture` * - `proof:corollary` - - `proof:criteria` + - `proof:criterion` - `proof:definition` * - `proof:example` - `proof:lemma` diff --git a/packages/myst-to-tex/src/proof.ts b/packages/myst-to-tex/src/proof.ts index d456d7f1f6..fde82cef0f 100644 --- a/packages/myst-to-tex/src/proof.ts +++ b/packages/myst-to-tex/src/proof.ts @@ -31,6 +31,14 @@ function kindToEnvironment(kind: ProofKind): string { return 'observation'; case 'corollary': return 'corollary'; + case 'algorithm': + return 'algorithm'; + case 'assumption': + return 'assumption'; + case 'criterion': + return 'criterion'; + case 'property': + return 'property'; default: return ''; } @@ -99,6 +107,10 @@ export class TexProofSerializer { '\\newtheorem{axiom}{Axiom}[section]', '\\newtheorem{conjecture}{Conjecture}[section]', '\\newtheorem{observation}{Observation}[section]', + '\\newtheorem{algorithm}{Algorithm}[section]', + '\\newtheorem{assumption}{Assumption}[section]', + '\\newtheorem{criterion}{Criterion}[section]', + '\\newtheorem{property}{Property}[section]', ]; const block = writeTexLabelledComment( 'theorem', diff --git a/packages/myst-to-tex/tests/proofs.spec.ts b/packages/myst-to-tex/tests/proofs.spec.ts new file mode 100644 index 0000000000..dbfbe9f9ae --- /dev/null +++ b/packages/myst-to-tex/tests/proofs.spec.ts @@ -0,0 +1,12 @@ +import { describe, test, expect } from 'vitest'; +import { TexProofSerializer } from '../src/proof'; + +describe('TexProofSerializer preamble', () => { + test.each(['algorithm', 'assumption', 'criterion', 'property'])( + 'declares a \\newtheorem environment for %s', + (env) => { + const { preamble } = new TexProofSerializer(); + expect(preamble).toContain(`\\newtheorem{${env}}`); + }, + ); +}); diff --git a/packages/myst-to-tex/tests/proofs.yml b/packages/myst-to-tex/tests/proofs.yml index 4ad1fa8b6a..f677c5b408 100644 --- a/packages/myst-to-tex/tests/proofs.yml +++ b/packages/myst-to-tex/tests/proofs.yml @@ -207,3 +207,83 @@ cases: Some text before an observation \begin{observation}\label{obs-t1}This is it.\end{observation} + - title: algorithm after paragraph + mdast: + type: root + children: + - type: paragraph + children: + - type: text + value: 'Some text before an algorithm' + - type: proof + kind: algorithm + label: alg-t1 + identifier: alg-t1 + enumerated: true + children: + - type: text + value: 'Do this, then that.' + latex: |- + Some text before an algorithm + + \begin{algorithm}\label{alg-t1}Do this, then that.\end{algorithm} + - title: assumption after paragraph + mdast: + type: root + children: + - type: paragraph + children: + - type: text + value: 'Some text before an assumption' + - type: proof + kind: assumption + label: asm-t1 + identifier: asm-t1 + enumerated: true + children: + - type: text + value: 'Assume this holds.' + latex: |- + Some text before an assumption + + \begin{assumption}\label{asm-t1}Assume this holds.\end{assumption} + - title: criterion after paragraph + mdast: + type: root + children: + - type: paragraph + children: + - type: text + value: 'Some text before a criterion' + - type: proof + kind: criterion + label: crit-t1 + identifier: crit-t1 + enumerated: true + children: + - type: text + value: 'This is the criterion.' + latex: |- + Some text before a criterion + + \begin{criterion}\label{crit-t1}This is the criterion.\end{criterion} + - title: property after paragraph + mdast: + type: root + children: + - type: paragraph + children: + - type: text + value: 'Some text before a property' + - type: proof + kind: property + label: prop-p1 + identifier: prop-p1 + enumerated: true + children: + - type: text + value: 'This property holds.' + latex: |- + Some text before a property + + \begin{property}\label{prop-p1}This property holds.\end{property}