Design

Commutative Diagrams In Notion

katex-notion-diagrams-commutative-math.png

🖋 Notion Diagrams

KaTex, or math blocks, in Notion is a function that is seldom appreciated on my blog, so I sat down and put together the list below. The examples illustrate how math blocks can be used to draw commutative diagrams. These diagrams are from the amscd LaTeX package, a recent update to Notion math blocks. Here's how it works:

Get Started

  • Trigger "/mathb"

notion-diagram-commutative-1.png
\begin{CD}
...code here...
\end{CD}

Commutative Diagram Arrows

  • @<<< left arrow

  • @AAA up arrow

  • @VVV down arrow

  • @. empty arrow

  • @>>> right arrow

  • @= horizontal equals

  • @| vertical equals

View all arrows

Screen Shot 2021-06-09 at 3.00.13 PM.png
\begin{CD}
     @>>> @<<< @AAA @VVV @= @| @.
\end{CD}

Diagram Example

notion-diagram-commutative-2.png
\begin{CD}
1 @<<< 2 @= 3\\
@. @| @VVV\\
@. 4 @= 5
\end{CD}

Labels

Upper

notion-diagram-arrow-cd.png
\begin{CD}
\text{A} @>label>> \text{B}
\end{CD}

Lower

notion-diagram-lower-label.png
\begin{CD}
\text{A} @>>label> \text{B}
\end{CD}

Left

notion-diagram-arrow-label-left.png
\begin{CD}
\text{A}
\\@VlabelVV\\
\text{B}
\end{CD}

Right

notion-diagram-arrow-down-right.png
\begin{CD}
\text{A}
\\@VVlabelV\\
\text{B}
\end{CD}

Long Label Alignment

If one arrow has a long label and an arrow parallel to it has no label, the parallel label will be shorter. The following code should be added to fix this:

  • @>{\phantom{\text{this text should match the parallel arrow label}}}>>

Before

notion-diagram-long-label-cd.png
\begin{CD}
1 @>>> 2
@>\text{this is a really long label}>> 3\\
@VVV @VVV @VVV\\
4 @>>> 5@>>> 6
\end{CD}

After

notion-diagram-label-phantom-cd.png
\begin{CD}
1 @>>> 2
@>\text{this is a really long label}>> 3\\
@VVV @VVV @VVV\\
4 @>>> 5 @>{\phantom{\text{this is a really long label}}}>> 6
\end{CD}

Long Label Alignment + Label

If you want to add a label to the phantom arrow, Incorporate the following rlap structure to the phantom command:

  • {\\rlap{$\\scriptstyle{\\text{The Label}}$}\\phantom{\\text{this text should match the parallel arrow label}}}

notion-diagram-note-relationship.png
\begin{CD}
1 @>>> 2
@>\text{this is a really long label}>> 3\\
@VVV @VVV @VVV\\
4 @>>> 5 @>{\rlap{$\scriptstyle{\text{shorter}}$}\phantom{\text{this is a really long label}}}>> 6
\end{CD}

Note Relationship Diagram

notion-diagram-note-relationship.png
\begin{CD}
\text{High-Tier}
@>\text{next entry}>> 
\text{Parent}
@>\text{next entry}>>
\text{Orphan} \\ 
@VrelatedVV 
@VrelatedVV \\
\text{Connector} 
@>\text{next entry}>> 
\text{Child}\\ 
@VrelatedVV \\
\text{Child}\\
\end{CD}

Array Diagram Arrows

You can use array commands to create diagrams too. Here is a list of LaTeX arrows you can choose from.

Array Diagram Example

notion-array-diagram.png
\begin{array}{ccccc}
&& \text{High-Tier} && \\
& \swarrow & \downarrow & \searrow & \\
\text{Connector} && \text{Child} && \text{Connector} \\
\downarrow &&&& \downarrow \\
\text{Child} &&&& \text{Child}
\end{array}
 

Further Reading