Commutative Diagrams In Notion
Get Started
Trigger "/mathb"
\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
\begin{CD} @>>> @<<< @AAA @VVV @= @| @. \end{CD}
Diagram Example
\begin{CD} 1 @<<< 2 @= 3\\ @. @| @VVV\\ @. 4 @= 5 \end{CD}
Labels
Upper
\begin{CD} \text{A} @>label>> \text{B} \end{CD}
Lower
\begin{CD} \text{A} @>>label> \text{B} \end{CD}
Left
\begin{CD} \text{A} \\@VlabelVV\\ \text{B} \end{CD}
Right
\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
\begin{CD} 1 @>>> 2 @>\text{this is a really long label}>> 3\\ @VVV @VVV @VVV\\ 4 @>>> 5@>>> 6 \end{CD}
After
\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}}}
\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
\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
\begin{array}{ccccc} && \text{High-Tier} && \\ & \swarrow & \downarrow & \searrow & \\ \text{Connector} && \text{Child} && \text{Connector} \\ \downarrow &&&& \downarrow \\ \text{Child} &&&& \text{Child} \end{array}