documentation

KaTeX and Mermaid Rendering Examples

Site Owner: Michael Baggett

This page demonstrates six examples of KaTeX math and six Mermaid diagrams. KaTeX supports inline expressions wrapped in dollar signs and display equations wrapped in double dollar signs. Mermaid diagrams use fenced code blocks labeled mermaid.

KaTeX math examples

1. Inline equation

The Pythagorean theorem relates the sides of a right triangle: $a^2 + b^2 = c^2$.

2. Quadratic formula

The solutions to a quadratic equation are:

$$ x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} $$

3. Derivative

The derivative of the exponential function is itself:

$$ \frac{d}{dx}e^x = e^x $$

4. Definite integral

The area under the square function from zero to one is:

$$ \int_0^1 x^2\,dx = \frac{1}{3} $$

5. Infinite geometric series

For a convergent geometric series, the sum is:

$$ \sum_{k=0}^{\infty} ar^k = \frac{a}{1-r} $$

6. Matrix

A two-by-two matrix can be written as:

$$ \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} $$

Mermaid block examples

1. Flowchart

flowchart TD
    Start([Start]) --> Read[Read the request]
    Read --> Valid{Is it valid?}
    Valid -- Yes --> Process[Process the request]
    Valid -- No --> Correct[Ask for corrections]
    Correct --> Read
    Process --> Done([Done])

2. Sequence diagram

sequenceDiagram
    actor User
    participant Browser
    participant Site
    User->>Browser: Open a page
    Browser->>Site: Request the page
    Site-->>Browser: Return HTML
    Browser-->>User: Display the page

3. Class diagram

classDiagram
    class Page {
        +String title
        +String path
    }
    class Category {
        +String name
    }
    Page --> Category : belongs to

4. State diagram

stateDiagram-v2
    [*] --> Draft
    Draft --> Published: approve
    Published --> Archived: retire
    Archived --> [*]

5. Entity relationship diagram

erDiagram
    AUTHOR ||--o{ POST : writes
    POST ||--|{ TAG_ASSIGNMENT : has
    TAG ||--o{ TAG_ASSIGNMENT : labels

6. Gantt chart

gantt
    title Documentation release
    dateFormat YYYY-MM-DD
    section Work
    Outline the page :done, outline, 2026-12-01, 1d
    Write examples :active, write, after outline, 2d
    Review rendering :review, after write, 1d

Posted: