# Drawing matrices on arrows of a short exact sequence (commuatative diagram)

I want to draw a short exact sequence using the tikz-cd package. But I want the labels on some of the arrows to be matrices. I can´t seem to make it look good. The arrows are not approtiatly sized and my colum and row matrices do not look the same (clearly this is because I use two different commands, but I am not able to do row vectors with comma in a different way). The following picture shows what I want to archive. The minimal working example is what I tried.

\documentclass[a4paper,11pt]{amsart}
\usepackage{amsmath,amscd,amssymb,amsfonts,mathrsfs}
\usepackage{mathtools}
\usepackage{tikz-cd}
\DeclarePairedDelimiter{\Vector}{\lparen}{\rparen}
\begin{document}
\begin{equation*}
\begin{tikzcd}
\Sigma_1 \colon \quad 0 \arrow{r} & M_1
\arrow{r}{\begin{pmatrix} u_1 \\ f_1  \end{pmatrix}} &
E \arrow[column sep = large]{r}{\Vector{f_2,u_2}}
& F \arrow{r} & 0
\end{tikzcd}
\end{equation*}
\end{document}


Are you looking for somrthing like this?

The length of arrow was changed by passing an optional argument to the cell separation character &[5ex] and smallmatrix was used instead of pmatrix.

\documentclass[a4paper,11pt]{amsart}
%\usepackage{amsmath,amscd,amssymb,amsfonts,mathrsfs}
%\usepackage{mathtools}
\usepackage{tikz-cd}
\begin{document}
\begin{equation*}
\begin{tikzcd}
\Sigma_1 \colon \quad 0 \arrow{r} & M_1
\arrow{r}{\left[\begin{smallmatrix} u_1 \\ f_1  \end{smallmatrix}\right]} &
E \arrow[column sep = large]{r}{[f_2,u_2]}
&[5ex] F \arrow{r} & 0
\end{tikzcd}
\end{equation*}
\end{document}

• I was using smallmatrix too...so I'm going to eliminate the one I was almost done with :-). My positive vote. – Sebastiano Aug 6 '19 at 16:08
• This is what I was looking for. – Bobior Aug 7 '19 at 9:13

Another ưay is using library positioning with realtive coordinates, so we can easily control length of arrows. (using absolute coordinates is not convenient in this case). Also note the order of options: node distance=5mm must be before right= of N2.

\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{equation*}
\begin{tikzpicture}[node distance=1cm]
\path node (M21) {$M_2\oplus N_1$}
node[left= of M21]  (M1)  {$M_1$}
node[node distance=5mm,left= of M1] (L) {$\Sigma_1 : 0$}
node[right= of M21] (N2)  {$N_2$}
node[node distance=5mm,right= of N2] (R) {$0$};

\draw[->] (L)--(M1);
\draw[->] (M1)--(M21) node[midway,above,scale=.8]
{$\begin{bmatrix}u_1\\f_1\end{bmatrix}$};
\draw[->] (M21)--(N2) node[midway,above,scale=.8]
{$\begin{bmatrix}f_2,u_2\end{bmatrix}$};
\draw[->] (N2)--(R);
\end{tikzpicture}
\end{equation*}
\end{document}


Do you need tikz-cd to begin with?

\documentclass[a4paper,11pt]{amsart}

\newcommand{\mapname}[1]{%
\left[\begin{smallmatrix}#1\end{smallmatrix}\right]%
}
\newcommand{\map}[1]{\xrightarrow{\mapname{#1}}}
\newcommand{\fmod}[1]{{\operatorname{mod-}}#1}

\begin{document}

Let
\begin{alignat*}{2}
\Sigma_1 &\colon &\quad& 0 \to M_1 \map{u_1 \\ f_1} M_2\oplus N_1 \map{f_2,u_2} N_2 \to 0 \\
\Sigma_2 &\colon &\quad& 0 \to M_2 \map{v_1 \\ f_2} M_3\oplus N_2 \map{f_3,v_2} N_3 \to 0
\end{alignat*}
be short exact sequences in $\fmod{A}$. Then the sequence
\begin{equation*}
\Sigma_3 \colon \quad 0 \to M_1 \map{v_1u_1 \\ f_1} M_3\oplus N_1 \map{f_3,-v_2u_2} N_3 \to 0
\end{equation*}
is exact. Moreover we have $\delta_{\Sigma_3}=\delta_{\Sigma_1}+\delta_{\Sigma_2}$.

\end{document}