LaTex2Web logo

LaTeX2Web, a web authoring and publishing system

If you see this, something is wrong

Collapse and expand sections

To get acquainted with the document, the best thing to do is to select the "Collapse all sections" item from the "View" menu. This will leave visible only the titles of the top-level sections.

Clicking on a section title toggles the visibility of the section content. If you have collapsed all of the sections, this will let you discover the document progressively, from the top-level sections to the lower-level ones.

Cross-references and related material

Generally speaking, anything that is blue is clickable.

Clicking on a reference link (like an equation number, for instance) will display the reference as close as possible, without breaking the layout. Clicking on the displayed content or on the reference link hides the content. This is recursive: if the content includes a reference, clicking on it will have the same effect. These "links" are not necessarily numbers, as it is possible in LaTeX2Web to use full text for a reference.

Clicking on a bibliographical reference (i.e., a number within brackets) will display the reference.

Speech bubbles indicate a footnote. Click on the bubble to reveal the footnote (there is no page in a web document, so footnotes are placed inside the text flow). Acronyms work the same way as footnotes, except that you have the acronym instead of the speech bubble.

Discussions

By default, discussions are open in a document. Click on the discussion button below to reveal the discussion thread. However, you must be registered to participate in the discussion.

If a thread has been initialized, you can reply to it. Any modification to any comment, or a reply to it, in the discussion is signified by email to the owner of the document and to the author of the comment.

Publications

The blue button below that says "table of contents" is your tool to navigate in a publication.

The left arrow brings you to the previous document in the publication, and the right one brings you to the next. Both cycle over the publication list.

The middle button that says "table of contents" reveals the publication table of contents. This table is hierarchical structured. It has sections, and sections can be collapsed or expanded. If you are a registered user, you can save the layout of the table of contents.

Table of contents

First published on Wednesday, Sep 24, 2025 and last modified on Thursday, Oct 2, 2025

I am normally hidden by the status bar

Mermaid charts

François Chaplais

1 Introduction

LaTeX2Web supports mermaid charts. Chart 1 is an flow chart example straight from the documentation. Chart 2 shows the same one with custom colors.

flowchart TD
 A[Start] --> B{Is it?}
 B -->|Yes| C[OK]
 C --> D[Rethink]
 D --> B
 B ---->|No| E[End]

Diagram 1. A flow chart example.

---
config:
    theme: base
    themeVariables:
        primaryColor: '#FF0000'
        secondaryColor: '#ADFF2F'
        fontFamily: verdana
        fontSize: 20px
        secondaryTextColor: '#FFFFFF'
        textColor: '#FFFFFF'
        lineColor: '#0000FF'
---
flowchart TD
 A[Start] --> B{Is it?}
 B -->|Yes| C[OK]
 C --> D[Rethink]
 D --> B
 B ---->|No| E[End]

Diagram 2. The same diagram with custom colors, font and font size.

Here is the list of supported diagrams.

  • Flow charts
  • Sequence diagrams
  • Class diagrams (UML)
  • State diagrams
  • Entity Relationship Diagrams
  • User Journey Diagrams
  • Gantt diagrams
  • Pie charts
  • Quadrant Chart
  • Requirement Diagrams
  • GitGraph Diagrams
  • XY Chart
  • Block Diagrams
  • Packet Diagrams
  • Kanban Diagram

This document lists examples of common diagram types with links to the documentation.

2 Themeing and styling

Mermaid supports five native themes.

  • default
  • dark
  • forest
  • neutral
  • base

As the name suggest, the default style is applied by default. The base theme is the only one that can be customized.

3 Styling

Here is the list of the styling parameters that can be applied to the base theme.

  • primaryColor
  • secondaryColor
  • tertiaryColor
  • primaryTextColor
  • primaryBorderColor
  • secondaryTextColor
  • secondaryBorderColor
  • tertiaryTextColor
  • tertiaryBorderColor
  • noteTextColor
  • noteBkgColor
  • noteBorderColor
  • lineColor
  • textColor
  • mainBkg
  • fontFamily
  • fontSize

Except the last two items, the value for the style items must be the name of a color.

For details of diagram themeing, see the mermaid documentation. On this page you will also find styling options which are specific to certain diagram types. These are also supported by LaTeX2Web.

Remember to use the base theme when styling a diagram. Also, opacity is not supported when defining colors.

Note do not use mermaid frontmatter as it will conflict with the frontmatter generated by LaTeX2Web.

4 Syntax

Mermaid diagrams are encapsulated in a mermaid environment. An optional parameter for the environment is the name of a theme. If the theme is base, the \mermaidStyle command is used to specify the styling of the diagram. The parameter for this command is a list of words with the syntax key=value. After this is the mermaid code for the diagram.

Diagrams can have a label.

Here is, as an example, the code for the styled diagram 2.

\begin{mermaid}[base]\label{styled-diagram}
\caption{The same diagram with custom colors, font and font size.}
\mermaidStyle{primaryColor=red secondaryColor=greenyellow fontFamily=verdana fontSize=20 secondaryTextColor=white textColor=white lineColor=blue}
flowchart TD
 A[Start] --> B{Is it?}
 B -->|Yes| C[OK]
 C --> D[Rethink]
 D --> B
 B ---->|No| E[End]
\end{mermaid}

The mermaid code is

flowchart TD
 A[Start] --> B{Is it?}
 B -->|Yes| C[OK]
 C --> D[Rethink]
 D --> B
 B ---->|No| E[End]

which just the code that was used for chart 1.

The default configuration is very simple.

\begin{mermaid}
... mermaid code ...
\end{mermaid}

5 Diagram types and examples

5.1 Flow charts

This is a very common and highly customizable type of diagram. The two introductory examples are flow charts. Here is an example with sub-graphs.

flowchart TB
 c1-->a2
 subgraph one
 a1-->a2
 end
 subgraph two
 b1-->b2
 end
 subgraph three
 c1-->c2
 end

The mermaid documentation for this kind of diagram is here.

5.2 Sequence diagrams

A Sequence diagram is an interaction diagram that shows how processes operate with one another and in what order.

Here is an example.

---
config:
    theme: base
    themeVariables:
        actorBkg: '#663399'
        actorTextColor: '#FFFFFF'
---
sequenceDiagram
 Alice->>John: Hello John, how are you?
 John-->>Alice: Great!
 Alice-)John: See you later!

Diagram 4. A styled sequence diagram. The background of the actors has been set to rebeccapurple and the corresponding text has been set to white.

The mermaid documentation for this kind of diagram is here.

5.3 Class diagrams

"In software engineering, a class diagram in the Unified Modeling Language (UML) is a type of static structure diagram that describes the structure of a system by showing the system’s classes, their attributes, operations (or methods), and the relationships among objects."

-Wikipedia

Here is an example with the forest theme.

---
config:
  theme: 'forest'
---
classDiagram
 note "From Duck till Zebra"
 Animal <|-- Duck
 note for Duck "can fly; can swim; can dive; can help in debugging"
 Animal <|-- Fish
 Animal <|-- Zebra
 Animal : +int age
 Animal : +String gender
 Animal: +isMammal()
 Animal: +mate()
 class Duck{
 +String beakColor
 +swim()
 +quack()
 }
 class Fish{
 -int sizeInFeet
 -canEat()
 }
 class Zebra{
 +bool is_wild
 +run()
 }

Diagram 5. Animal example

The mermaid documentation for this kind of diagram is here.

5.4 State diagrams

"A state diagram is a type of diagram used in computer science and related fields to describe the behavior of systems. State diagrams require that the system described is composed of a finite number of states; sometimes, this is indeed the case, while at other times this is a reasonable abstraction."

Wikipedia

Here is an advanced example with the neutral theme.

---
config:
  theme: 'neutral'
---
stateDiagram-v2
 [*] --> First
 state First {
 [*] --> second
 second --> [*]
 }

 [*] --> NamedComposite
 NamedComposite: Another Composite
 state NamedComposite {
 [*] --> namedSimple
 namedSimple --> [*]
 namedSimple: Another simple
 }

The mermaid documentation for this kind of diagram is here.

5.5 Entity Relationship Diagrams

An entity–relationship model (or ER model) describes interrelated things of interest in a specific domain of knowledge. A basic ER model is composed of entity types (which classify the things of interest) and specifies relationships that can exist between entities (instances of those entity types).

Wikipedia

Here is an example with the base (unstyled) theme.

---
config:
  theme: 'base'
---
erDiagram
 CUSTOMER ||--o{ ORDER : places
 ORDER ||--|{ LINE-ITEM : contains
 CUSTOMER }|..|{ DELIVERY-ADDRESS : uses

Diagram 7. Order example

The mermaid documentation for this kind of diagram is here.

5.6 User Journey Diagram

User journeys describe at a high level of detail exactly what steps different users take to complete a specific task within a system, application or website. This technique shows the current (as-is) user workflow, and reveals areas of improvement for the to-be workflow.

Wikipedia

Here is a styled example with fillType0=lawngreen and fillType1=lightskyblue.

---
config:
    theme: base
    themeVariables:
        fillType0: '#7CFC00'
        fillType1: '#87CEFA'
---
journey
    title My working day
    section Go to work
      Make tea: 5: Me
      Go upstairs: 3: Me
      Do work: 1: Me, Cat
    section Go home
      Go downstairs: 5: Me
      Sit down: 5: Me

The mermaid documentation for this kind of diagram is here.

5.7 Gantt diagrams

A Gantt chart is a type of bar chart, first developed by Karol Adamiecki in 1896, and independently by Henry Gantt in the 1910s, that illustrates a project schedule and the amount of time it would take for any one project to finish. Gantt charts illustrate number of days between the start and finish dates of the terminal elements and summary elements of a project.

Here is an example.

gantt
    dateFormat  YYYY-MM-DD
    title       Adding GANTT diagram functionality to mermaid
    excludes    weekends
    %% (`excludes` accepts specific dates in YYYY-MM-DD format, days of the week ("sunday") or "weekends", but not the word "weekdays".)

    section A section
    Completed task            :done,    des1, 2014-01-06,2014-01-08
    Active task               :active,  des2, 2014-01-09, 3d
    Future task               :         des3, after des2, 5d
    Future task2              :         des4, after des3, 5d

    section Critical tasks
    Completed task in the critical line :crit, done, 2014-01-06,24h
    Implement parser and jison          :crit, done, after des1, 2d
    Create tests for parser             :crit, active, 3d
    Future task in critical line        :crit, 5d
    Create tests for renderer           :2d
    Add to mermaid                      :until isadded
    Functionality added                 :milestone, isadded, 2014-01-25, 0d

    section Documentation
    Describe gantt syntax               :active, a1, after des1, 3d
    Add gantt diagram to demo page      :after a1  , 20h
    Add another diagram to demo page    :doc1, after a1  , 48h

    section Last section
    Describe gantt syntax               :after doc1, 3d
    Add gantt diagram to demo page      :20h
    Add another diagram to demo page    :48h

The mermaid documentation for this kind of diagram is here.

5.8 Pie chart diagrams

A pie chart (or a circle chart) is a circular statistical graphic, which is divided into slices to illustrate numerical proportion. In a pie chart, the arc length of each slice (and consequently its central angle and area), is proportional to the quantity it represents. While it is named for its resemblance to a pie which has been sliced, there are variations on the way it can be presented. The earliest known pie chart is generally credited to William Playfair’s Statistical Breviary of 1801.

Wikipedia

Here is an example.

---
config:
  pie:
    textPosition: 0.5
  themeVariables:
    pieOuterStrokeWidth: "5px"
---
pie showData
    title Key elements in Product X
    "Calcium" : 42.96
    "Potassium" : 50.05
    "Magnesium" : 10.01
    "Iron" :  5

The mermaid documentation for this kind of diagram is here.

Note: pie charts can also rendered by chart.js.

5.9 Quadrant Chart

A quadrant chart is a visual representation of data that is divided into four quadrants. It is used to plot data points on a two-dimensional grid, with one variable represented on the x-axis and another variable represented on the y-axis. The quadrants are determined by dividing the chart into four equal parts based on a set of criteria that is specific to the data being analyzed. Quadrant charts are often used to identify patterns and trends in data, and to prioritize actions based on the position of data points within the chart. They are commonly used in business, marketing, and risk management, among other fields.

Here is an example.

quadrantChart
    title Reach and engagement of campaigns
    x-axis Low Reach --> High Reach
    y-axis Low Engagement --> High Engagement
    quadrant-1 We should expand
    quadrant-2 Need to promote
    quadrant-3 Re-evaluate
    quadrant-4 May be improved
    Campaign A: [0.3, 0.6]
    Campaign B: [0.45, 0.23]
    Campaign C: [0.57, 0.69]
    Campaign D: [0.78, 0.34]
    Campaign E: [0.40, 0.34]
    Campaign F: [0.35, 0.78]

The mermaid documentation for this kind of diagram is here.

5.10 Requirement Diagram

A Requirement diagram provides a visualization for requirements and their connections, to each other and other documented elements. The modeling specs follow those defined by SysML v1.6.

Here is an example.

requirementDiagram

    requirement test_req {
    id: 1
    text: the test text.
    risk: high
    verifymethod: test
    }

    element test_entity {
    type: simulation
    }

    test_entity - satisfies -> test_req

The mermaid documentation for this kind of diagram is here.

5.11 GitGraph Diagrams

A Git Graph is a pictorial representation of git commits and git actions(commands) on various branches.

Here is an example.

gitGraph
       commit
       commit
       branch develop
       commit
       commit
       commit
       checkout main
       commit
       commit
       merge develop
       commit
       commit

The mermaid documentation for this kind of diagram is here.

5.12 XY Chart

In the context of mermaid-js, the XY chart is a comprehensive charting module that encompasses various types of charts that utilize both x-axis and y-axis for data representation. Presently, it includes two fundamental chart types: the bar chart and the line chart. These charts are designed to visually display and analyze data that involve two numerical variables.

It’s important to note that while the current implementation of mermaid-js includes these two chart types, the framework is designed to be dynamic and adaptable. Therefore, it has the capacity for expansion and the inclusion of additional chart types in the future. This means that users can expect an evolving suite of charting options within the XY chart module, catering to various data visualization needs as new chart types are introduced over time.

Here is an example.

xychart
    title "Sales Revenue"
    x-axis [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
    y-axis "Revenue (in $)" 4000 --> 11000
    bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
    line [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]

The mermaid documentation for this kind of diagram is here.

Note: this kind of chart can also be drawn with chart.js.

5.13 Block Diagrams

Block diagrams are an intuitive and efficient way to represent complex systems, processes, or architectures visually. They are composed of blocks and connectors, where blocks represent the fundamental components or functions, and connectors show the relationship or flow between these components. This method of diagramming is essential in various fields such as engineering, software development, and process management.

Here is an example.

block
  columns 3
  Start(("Start")) space:2
  down<[" "]>(down) space:2
  Decision{{"Make Decision"}} right<["Yes"]>(right) Process1["Process A"]
  downAgain<["No"]>(down) space r3<["Done"]>(down)
  Process2["Process B"] r2<["Done"]>(right) End(("End"))

  style Start fill:#969;
  style End fill:#696;

The mermaid documentation for this kind of diagram is here.

5.14 Packet Diagram

A packet diagram is a visual representation used to illustrate the structure and contents of a network packet. Network packets are the fundamental units of data transferred over a network.

Here is an example.

---
title: "TCP Packet"
---
packet
0-15: "Source Port"
16-31: "Destination Port"
32-63: "Sequence Number"
64-95: "Acknowledgment Number"
96-99: "Data Offset"
100-105: "Reserved"
106: "URG"
107: "ACK"
108: "PSH"
109: "RST"
110: "SYN"
111: "FIN"
112-127: "Window"
128-143: "Checksum"
144-159: "Urgent Pointer"
160-191: "(Options and Padding)"
192-255: "Data (variable length)"

The mermaid documentation for this kind of diagram is here.

5.15 Kanban Diagram

Mermaid’s Kanban diagram allows you to create visual representations of tasks moving through different stages of a workflow. This guide explains how to use the Kanban diagram syntax, based on the provided example.

Here is an example.

---
config:
  kanban:
    ticketBaseUrl: 'https://mermaidchart.atlassian.net/browse/#TICKET#'
---
kanban
  Todo
    [Create Documentation]
    docs[Create Blog about the new diagram]
  [In progress]
    id6[Create renderer so that it works in all cases. We also add some extra text here for testing purposes. And some more just for the extra flare.]
  id9[Ready for deploy]
    id8[Design grammar]@{ assigned: 'knsv' }
  id10[Ready for test]
    id4[Create parsing tests]@{ ticket: MC-2038, assigned: 'K.Sveidqvist', priority: 'High' }
    id66[last item]@{ priority: 'Very Low', assigned: 'knsv' }
  id11[Done]
    id5[define getData]
    id2[Title of diagram is more than 100 chars when user duplicates diagram with 100 char]@{ ticket: MC-2036, priority: 'Very High'}
    id3[Update DB function]@{ ticket: MC-2037, assigned: knsv, priority: 'High' }

  id12[Can't reproduce]
    id3[Weird flickering in Firefox]

The mermaid documentation for this kind of diagram is here.