Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/olive-donkeys-shave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'myst-to-tex': patch
---

Render algorithm, assumption, criterion, and property proof kinds in LaTeX export
2 changes: 1 addition & 1 deletion docs/proofs-and-theorems.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
12 changes: 12 additions & 0 deletions packages/myst-to-tex/src/proof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 '';
}
Expand Down Expand Up @@ -99,6 +107,10 @@ export class TexProofSerializer {
'\\newtheorem{axiom}{Axiom}[section]',
'\\newtheorem{conjecture}{Conjecture}[section]',
'\\newtheorem{observation}{Observation}[section]',
'\\newtheorem{algorithm}{Algorithm}[section]',
Comment thread
alanlujan91 marked this conversation as resolved.
'\\newtheorem{assumption}{Assumption}[section]',
'\\newtheorem{criterion}{Criterion}[section]',
'\\newtheorem{property}{Property}[section]',
];
const block = writeTexLabelledComment(
'theorem',
Expand Down
12 changes: 12 additions & 0 deletions packages/myst-to-tex/tests/proofs.spec.ts
Original file line number Diff line number Diff line change
@@ -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}}`);
},
);
});
80 changes: 80 additions & 0 deletions packages/myst-to-tex/tests/proofs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}