Skip to main content

matrix_demo/
matrix_demo.rs

1use term_maths::render;
2
3fn main() {
4    let examples = [
5        (
6            r"\begin{pmatrix} a & b \\ c & d \end{pmatrix}",
7            "2x2 pmatrix",
8        ),
9        (
10            r"\begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}",
11            "2x2 identity bmatrix",
12        ),
13        (
14            r"\begin{vmatrix} a & b \\ c & d \end{vmatrix}",
15            "2x2 determinant",
16        ),
17        (
18            r"\begin{pmatrix} \frac{1}{2} & 0 \\ 0 & \frac{3}{4} \end{pmatrix}",
19            "Matrix with fractions",
20        ),
21        (
22            r"\begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{bmatrix}",
23            "3x3 bmatrix",
24        ),
25        // Math font tests
26        (r"\mathbb{R}", "Blackboard bold R"),
27        (r"\mathbb{Z}", "Blackboard bold Z"),
28        (r"\mathcal{L}", "Calligraphic L"),
29        (r"\mathbf{x}", "Bold x"),
30        (r"\mathfrak{g}", "Fraktur g"),
31        (r"\mathbb{R}^n", "R^n"),
32    ];
33
34    for (latex, label) in &examples {
35        println!("--- {} ---", label);
36        println!("LaTeX: {}", latex);
37        println!();
38        println!("{}", render(latex));
39        println!();
40    }
41}