Folioby Interconnected
Log InSign Up

Diagrams and Tables — mermaid, tikzgraph, tikzcd, tabular

A complete guide to diagrams and tables on Folio. Covers mermaid flowcharts and sequence diagrams, tikzgraph for graph drawing, tikzcd for commutative diagrams, tabular for tables, figure/table environments, and includegraphics.

FO
Folio Official
March 3, 2026

1. Mermaid Diagrams

Folio provides a mermaid environment for text-based diagrams. This is a Folio-specific feature not available in standard LaTeX.

1.1. Flowcharts

\begin{mermaid}
graph TD
    A[Start] --> B{Condition}
    B -->|Yes| C[Process 1]
    B -->|No| D[Process 2]
    C --> E[End]
    D --> E
\end{mermaid}

Result:

graph TD
    A[Start] --> B{Condition}
    B -->|Yes| C[Process 1]
    B -->|No| D[Process 2]
    C --> E[End]
    D --> E

1.2. Horizontal Flowcharts

Use graph LR for left-to-right flow:

\begin{mermaid}
graph LR
    A[Input] --> B[Preprocessing]
    B --> C[Model]
    C --> D[Postprocessing]
    D --> E[Output]
\end{mermaid}

Result:

graph LR
    A[Input] --> B[Preprocessing]
    B --> C[Model]
    C --> D[Postprocessing]
    D --> E[Output]

1.3. Sequence Diagrams

\begin{mermaid}
sequenceDiagram
    participant C as Client
    participant S as Server
    participant D as Database
    C->>S: HTTP Request
    S->>D: Query
    D-->>S: Result
    S-->>C: Response
\end{mermaid}

Result:

sequenceDiagram
    participant C as Client
    participant S as Server
    participant D as Database
    C->>S: HTTP Request
    S->>D: Query
    D-->>S: Result
    S-->>C: Response

1.4. Use Case: Dependency Diagrams

Useful for showing topic dependencies in textbook series:

\begin{mermaid}
graph TD
    A["Sets and Maps"] --> B["Group Definition"]
    B --> C["Subgroups"]
    B --> D["Homomorphisms"]
    C --> E["Cosets"]
    E --> F["Normal Subgroups"]
    F --> G["Quotient Groups"]
    D --> G
    G --> H["Isomorphism Theorems"]

    style A fill:#f5f5f5,stroke:#333,color:#000
    style H fill:#f5f5f5,stroke:#333,color:#000
\end{mermaid}

Result:

graph TD
    A["Sets and Maps"] --> B["Group Definition"]
    B --> C["Subgroups"]
    B --> D["Homomorphisms"]
    C --> E["Cosets"]
    E --> F["Normal Subgroups"]
    F --> G["Quotient Groups"]
    D --> G
    G --> H["Isomorphism Theorems"]

    style A fill:#f5f5f5,stroke:#333,color:#000
    style H fill:#f5f5f5,stroke:#333,color:#000

2. tikzgraph: Graph Drawing

The tikzgraph environment draws graph-theory graphs (vertices and edges). It uses a syntax unified with LaTeX notation for undirected and directed graphs. This is a Folio-specific environment.

2.1. Basic Syntax

Define vertices with id or id/$label$, connect with --, and separate edge chains with ;:

\begin{tikzgraph}
  a/$v_1$ -- b/$v_2$ -- c/$v_3$;
  a -- c;
\end{tikzgraph}

Result:

v1​
v2​
v3​

Omitting the label displays the vertex ID as-is:

\begin{tikzgraph}
  a -- b -- c;
\end{tikzgraph}

Result:

a
b
c

2.2. Directed Graphs

Use -> for directed edges, <- for reverse, and <-> for bidirectional:

\begin{tikzgraph}
  a/$v_1$ -> b/$v_2$ -> c/$v_3$;
  c -> a;
\end{tikzgraph}

Result:

v1​
v2​
v3​

2.3. Edge Styles and Labels

Use square brackets for edge styles (dashed, dotted, thick, double) and labels:

\begin{tikzgraph}
  a/$u$ --[dashed] b/$v$;
  a --[thick, "3"] c/$w$;
  b --[dotted] c;
\end{tikzgraph}

Result:

3
u
v
w

2.4. Layouts

Choose a layout with the environment option. Default is spring layout (force-directed); circular layout arranges vertices in a circle:

\begin{tikzgraph}[circular layout]
  a/$1$ -- b/$2$ -- c/$3$ -- d/$4$ -- e/$5$ -- a;
\end{tikzgraph}

Result:

1
2
3
4
5

2.5. Syntax Summary

Syntax Meaning
a -- b Undirected edge
a -> b Directed edge (a→b)
a <- b Reverse edge (b→a)
a <-> b Bidirectional edge
a/$v_1$ Vertex a with KaTeX label v1​
--[dashed] Dashed style
--[dotted] Dotted style
--[thick] Thick style
--[double] Double-line style
--["label"] Edge label
[spring layout] Force-directed layout (default)
[circular layout] Circular layout

2.6. Multi-Edges

Defining multiple edges between the same pair automatically draws them as curves:

\begin{tikzgraph}
  A -- B; A -- B;
  A -- C; A -- C;
  A -- D;
  B -- D;
  C -- D;
\end{tikzgraph}

Result (Bridges of Kö

A
B
C
D

2.7. Subgraphs

Use {label: ...} to define subgraphs. Nodes within a subgraph are enclosed in a dashed border:

\begin{tikzgraph}
  {SCC $C_1$: a -> b -> c -> a;}
  {SCC $C_2$: d -> e -> d;}
  {SCC $C_3$: f;}
  c -> d;
  e -> f;
\end{tikzgraph}

Result:

SCC C1​
SCC C2​
SCC C3​
a
b
c
d
e
f

Use {a -- b;} without a colon for an unlabeled subgraph.

2.8. Differences from Real TikZ

tikzgraph bears a TikZ-like name but is a Folio-specific simplified graph drawing environment, quite different from real TikZ:

Feature tikzgraph TikZ
Coordinate specification Auto-layout only Arbitrary coordinates
Node shapes Circle only Rectangle, ellipse, polygon, etc.
Color specification Not supported Fully customizable
Label positioning Inside node only above, below, left, right
Edge curves Auto for multi-edges bend left/right, out/in angles
\foreach loops Not supported Supported
Decorations Not supported snake, zigzag, etc.

Note 1.
tikzgraph is specialized for basic graph-theory graph drawing. If you need custom node shapes or colors, consider using the mermaid environment instead.

3. tikzcd: Commutative Diagrams

The tikzcd environment draws commutative diagrams, useful for category-theoretic diagrams in math articles.

3.1. Basic Commutative Diagrams

\begin{tikzcd}
A \arrow[r, "f"] \arrow[d, "g"'] & B \arrow[d, "h"] \\
C \arrow[r, "k"'] & D
\end{tikzcd}

Result:

f
g
h
k
A
B
C
D

3.2. Arrow Types

\begin{tikzcd}
A \arrow[r, "f"] & B          % Regular morphism
A \arrow[r, hookrightarrow] & B   % Injection
A \arrow[r, twoheadrightarrow] & B % Surjection
A \arrow[r, dashed] & B       % Dashed
\end{tikzcd}

Result:

f
A
B
Regular
A
B
Injection
A
B
Surjection
A
B
Dashed
A
B
Double arrow
A
B
Mapsto

3.3. Exact Sequences

A short exact sequence:

\begin{tikzcd}
0 \arrow[r] & A \arrow[r, "f"] & B \arrow[r, "g"] & C \arrow[r] & 0
\end{tikzcd}

Result:

f
g
0
A
B
C
0

3.4. Complex Commutative Diagrams

\begin{tikzcd}
& A \arrow[dl, "p"'] \arrow[dr, "q"] & \\
B \arrow[dr, "f"'] & & C \arrow[dl, "g"] \\
& D &
\end{tikzcd}

Result:

p
q
f
g
A
B
C
D

4. Tables (tabular Environment)

4.1. Basic Tables

\begin{tabular}{lcc}
\hline
Name & Symbol & Order \\
\hline
Cyclic group & $\mathbb{Z}/n\mathbb{Z}$ & $n$ \\
Symmetric group & $S_n$ & $n!$ \\
Dihedral group & $D_n$ & $2n$ \\
\hline
\end{tabular}

Result:

Name Symbol Order
Cyclic group Z/nZ n
Symmetric group Sn​ n!
Dihedral group Dn​ 2n

4.2. Column Alignment

Use l (left), c (center), r (right):

\begin{tabular}{|l|c|r|}
\hline
Left & Center & Right \\
\hline
apple & banana & cherry \\
dog & elephant & fox \\
\hline
\end{tabular}

Result:

Left Center Right
apple banana cherry
dog elephant fox

5. figure and table Environments

Use float environments for captions and numbering:

\begin{figure}
\centering
\begin{tikzcd}
A \arrow[r, "f"] \arrow[d, "g"'] & B \arrow[d, "h"] \\
C \arrow[r, "k"'] & D
\end{tikzcd}
\caption{Example of a commutative diagram}
\label{fig:commutative}
\end{figure}

Figure \ref{fig:commutative} shows the basic form of a commutative diagram.

Result:

f
g
h
k
A
B
C
D
Figure 1: Example of a commutative diagram

Figure 1 shows the basic form of a commutative diagram.

\begin{table}
\centering
\begin{tabular}{lcc}
\hline
Group & Commutativity & Finiteness \\
\hline
$(\mathbb{Z}, +)$ & Abelian & Infinite \\
$S_3$ & Non-abelian & Finite \\
$(GL_2(\mathbb{R}), \cdot)$ & Non-abelian & Infinite \\
\hline
\end{tabular}
\caption{Classification of groups}
\label{tab:groups}
\end{table}

Table \ref{tab:groups} shows a basic classification of groups.

Result:

Table 1: Classification of groups
Group Commutativity Finiteness
(Z,+) Abelian Infinite
S3​ Non-abelian Finite
(GL2​(R),⋅) Non-abelian Infinite

Table 1 shows a basic classification of groups.

6. Images

The \includegraphics command works if you specify an image URL directly:

\includegraphics[width=0.8\textwidth]{https://example.com/image.png}

Note 2.
Only the width option is supported. Local file paths cannot be used, so you must specify a publicly accessible URL. For creating diagrams from text, mermaid, tikzgraph, and tikzcd are recommended.

7. Summary

On Folio, you can draw text-based diagrams with mermaid (flowcharts, etc.), tikzgraph (graph-theory graphs), and tikzcd (commutative diagrams). The tabular environment for tables works as expected. Next, we'll cover cross-references, links, and custom commands.

LaTeXFolioTutorialmermaidtikzgraphtikzcdTables
FO
Folio Official

Mathematics "between the lines" — exploring the intuition textbooks leave out, written in LaTeX on Folio.

1 followers·107 articles
Folio BasicsPart 6 of 8
Previous
Code Blocks and Algorithms — lstlisting, minted, algorithmic
Next
Cross-References, Links, and Custom Commands — label, ref, url, newcommand

Share your expertise with the world

Write articles with LaTeX support, build your audience, and earn from your knowledge.

Start Writing — It's Free

More from Folio Official

Folio Official·March 3, 2026

Mastering Theorem Environments — theorem, definition, proof, and Friends

A complete guide to Folio's 18+ built-in theorem environments. Covers theorem, definition, proof, lemma, corollary, example, remark, and more — usage, numbering, named arguments, and italic/roman styles explained.

LaTeXFolioTutorial
1
Folio Official·March 3, 2026

Writing Math — Every Notation Available in KaTeX

A comprehensive guide to Folio's math environments. Covers inline math, equation, align, gather, cases, matrix, and \newcommand — every KaTeX-based math notation explained.

LaTeXFolioTutorial
Folio Official·March 3, 2026

Folio LaTeX Reference: A Complete Guide to Commands, Environments, and Syntax

A single-page overview of Folio's LaTeX syntax. A quick reference covering text formatting, math, theorem environments, code blocks, diagrams, and cross-references, with support status shown as ✅⚠️❌.

LaTeXFolioTutorial
Folio Official·March 3, 2026

Folio LaTeX Basics — Differences from Standard LaTeX and Getting Started

A LaTeX introduction for writing articles on Folio. Covers the preamble-free system, section structure, text formatting, special character escaping, and a list of unsupported features, focusing on differences from standard LaTeX.

LaTeXFolioTutorial