Mermaid diagrams with LaTeX

Can you use LaTeX within mermaid diagrams?

I was trying a simple diagram:

graph TD;
    A-->B;
    A-->C;
    B-->D;
    C-->D;

which renders nicely in Obsidian as:

Screenshot 2023-05-27 at 13.40.54

However when I try to insert an equation:

graph TD;
    A-->$f(x)$;
    A-->C;
    B-->D;
    C-->D;

it fails with a parsing error:

Error parsing Mermaid diagram!

Parse error on line 2:
…ph TD; A–>$f(x)$; A–>C; B-
----------------------^
Expecting ‘SEMI’, ‘NEWLINE’, ‘SPACE’, ‘EOF’, ‘STYLE_SEPARATOR’, ‘START_LINK’, ‘LINK’, got ‘PUNCTUATION’

3 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.