6

I'm wanting to re-use notation used in a paper, but I'm having trouble formatting it in LaTeX. I'm trying to put a small (either a 2x2 or a 2x1 matrix) on top or to the right of an arrow. I want something like this (but with matrices with parentheses instead of brackets): enter image description here

I've tried typesetting the bottom row, and here is my attempt and the output:

\begin{displaymath}
    \xymatrix{ G_{1} \oplus F_{2} \ar[r]^{\begin{psmallmatrix}- $\psi_{1}$ & 0 \\ g & \phi_2 \end{psmallmatrix}} 
 & F_{1} \oplus G_{2} \ar[r]^{\begin{psmallmatrix}- $\phi_{1}$ & 0 \\f & $\psi_2$ \end{psmallmatrix}} } 
& $G_{1} \oplus F_{2}$ }
\end{displaymath}

....... attempt

I'm using the packages xy and mathtools.

1
  • 1
    For such things I prefer tikz package... You can control anything and you need simple commands... almost everything can be inside a node and with a few hours of practice you can do almost (if not) anything.
    – koleygr
    Oct 28, 2017 at 20:50

4 Answers 4

7

You need to increase the row and column spacing. The first realization is more appealing to me, the second one is similar to the original picture.

The statement @R+1pc increases the row spacing by 1pc = 12pt; similarly @C+1pc.

\documentclass{article}
\usepackage{amsmath}
\usepackage[all,cmtip]{xy}

\newcommand{\spmat}[1]{%
  \left(\begin{smallmatrix}#1\end{smallmatrix}\right)%
}

\begin{document}

\begin{equation*}
\xymatrix@C+2pc{
  G_{1} \oplus F_{2} \ar[r]^{\spmat{-\psi_{1} & 0 \\ g & \phi_2}}
  &
  F_{1} \oplus G_{2} \ar[r]^{\spmat{-\phi_{1} & 0 \\f & \psi_2}}
  &
  G_{1} \oplus F_{2}
}
\end{equation*}

\begin{equation*}
\xymatrix@R+1pc@C+2pc{
  F_2 \ar[r]^{\phi_2} \ar[d]^{\spmat{0 \\ 1_{F_2}}}
  &
  G_2 \ar[r]^{\psi_2} \ar[d]^{\spmat{0 \\ 1_{G_2}}}
  &
  F_2 \ar[d]^{\spmat{0 \\ 1_{F_2}}}
  \\
  G_1\oplus F_1 \ar[r]^{\spmat{-\psi_1 & 0 \\ g & \psi_2}}
  &
  F_1\oplus G_2 \ar[r]^{\spmat{-\phi_1 & 0 \\ f & \psi_2}}
  &
  G_1\oplus F_2
}
\end{equation*}

\begin{equation*}
\xymatrix@C+3pc{
  F_2 \ar[r]^{\phi_2} \ar[d]^{\spmat{0 \\ 1_{F_2}}}
  &
  G_2 \ar[r]^{\psi_2} \ar[d]^{\spmat{0 \\ 1_{G_2}}}
  &
  F_2 \ar[d]^{\spmat{0 \\ 1_{F_2}}}
  \\
  G_1\oplus F_1 \ar[r]^{\spmat{-\psi_1 & 0 \\ g & \psi_2}}
  &
  F_1\oplus G_2 \ar[r]^{\spmat{-\phi_1 & 0 \\ f & \psi_2}}
  &
  G_1\oplus F_2
}
\end{equation*}

\end{document}

enter image description here

With tikz-cd one needs to be careful when nesting arrays in tikzcd.

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}

\begingroup\lccode`~=`& \lowercase{\endgroup
\newcommand{\spmat}[1]{%
  \left(
  \let~=&
  \begin{smallmatrix}#1\end{smallmatrix}
  \right)
}}

\begin{document}

\begin{equation*}
\begin{tikzcd}
  G_{1} \oplus F_{2} \arrow[r,"\spmat{-\psi_{1} & 0 \\ g & \phi_2}"]
  &
  F_{1} \oplus G_{2} \arrow[r,"\spmat{-\phi_{1} & 0 \\f & \psi_2}"]
  &
  G_{1} \oplus F_{2}
\end{tikzcd}
\end{equation*}


\begin{equation*}
\begin{tikzcd}[column sep=huge,row sep=large]
  F_2 \arrow[r,"\phi_2"] \arrow[d,"\spmat{0 \\ 1_{F_2}}"]
  &
  G_2 \arrow[r,"\psi_2"] \arrow[d,"\spmat{0 \\ 1_{G_2}}"]
  &
  F_2 \arrow[d,"\spmat{0 \\ 1_{F_2}}"]
  \\
  G_1\oplus F_1 \arrow[r,"\spmat{-\psi_1 & 0 \\ g & \psi_2}"]
  &
  F_1\oplus G_2 \arrow[r,"\spmat{-\phi_1 & 0 \\ f & \psi_2}"]
  &
  G_1\oplus F_2
\end{tikzcd}
\end{equation*}

\begin{equation*}
\begin{tikzcd}[column sep=4pc]
  F_2 \arrow[r,"\phi_2"] \arrow[d,"\spmat{0 \\ 1_{F_2}}"]
  &
  G_2 \arrow[r,"\psi_2"] \arrow[d,"\spmat{0 \\ 1_{G_2}}"]
  &
  F_2 \arrow[d,"\spmat{0 \\ 1_{F_2}}"]
  \\
  G_1\oplus F_1 \arrow[r,"\spmat{-\psi_1 & 0 \\ g & \psi_2}"]
  &
  F_1\oplus G_2 \arrow[r,"\spmat{-\phi_1 & 0 \\ f & \psi_2}"]
  &
  G_1\oplus F_2
\end{tikzcd}
\end{equation*}

\end{document}

enter image description here

The awkward (but safe) trick above can be avoided, still defining \spmat as in the Xy-pic case. The downside is that one needs to input the tikzcd in a slightly different fashion (only when nested arrays are needed):

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}

\newcommand{\spmat}[1]{%
  \left(
  \begin{smallmatrix}#1\end{smallmatrix}
  \right)
}

\begin{document}

\begin{equation*}
\begin{tikzcd}[ampersand replacement=\&,column sep=huge]
  G_{1} \oplus F_{2} \arrow[r,"\spmat{-\psi_{1} & 0 \\ g & \phi_2}"]
  \&
  F_{1} \oplus G_{2} \arrow[r,"\spmat{-\phi_{1} & 0 \\f & \psi_2}"]
  \&
  G_{1} \oplus F_{2}
\end{tikzcd}
\end{equation*}

\begin{equation*}
\begin{tikzcd}[ampersand replacement=\&,column sep=huge,row sep=large]
  F_2 \arrow[r,"\phi_2"] \arrow[d,"\spmat{0 \\ 1_{F_2}}"]
  \&
  G_2 \arrow[r,"\psi_2"] \arrow[d,"\spmat{0 \\ 1_{G_2}}"]
  \&
  F_2 \arrow[d,"\spmat{0 \\ 1_{F_2}}"]
  \\
  G_1\oplus F_1 \arrow[r,"\spmat{-\psi_1 & 0 \\ g & \psi_2}"]
  \&
  F_1\oplus G_2 \arrow[r,"\spmat{-\phi_1 & 0 \\ f & \psi_2}"]
  \&
  G_1\oplus F_2
\end{tikzcd}
\end{equation*}

\begin{equation*}
\begin{tikzcd}[ampersand replacement=\&,column sep=4pc]
  F_2 \arrow[r,"\phi_2"] \arrow[d,"\spmat{0 \\ 1_{F_2}}"]
  \&
  G_2 \arrow[r,"\psi_2"] \arrow[d,"\spmat{0 \\ 1_{G_2}}"]
  \&
  F_2 \arrow[d,"\spmat{0 \\ 1_{F_2}}"]
  \\
  G_1\oplus F_1 \arrow[r,"\spmat{-\psi_1 & 0 \\ g & \psi_2}"]
  \&
  F_1\oplus G_2 \arrow[r,"\spmat{-\phi_1 & 0 \\ f & \psi_2}"]
  \&
  G_1\oplus F_2
\end{tikzcd}
\end{equation*}

\end{document}
2
  • 2
    however, op said that parentheses were wanted, not brackets. Oct 29, 2017 at 1:08
  • @barbarabeeton I oversaw it.
    – egreg
    Oct 29, 2017 at 8:42
5

A solution with tikz-cd and a solution with pstricks:

\documentclass{article}
\usepackage{mathtools}
\usepackage{tikz-cd}
\newcommand{\mymatrix}[1]{\begin{psmallmatrix} #1 \end{psmallmatrix}}
\usepackage{pst-node} 
\usepackage{auto-pst-pdf} %% to compile pstricks code with pdflatex

\begin{document}

 \[  \begin{tikzcd}[arrows=-stealth, ampersand replacement=\&, column sep=4em, row sep=3em]%[column sep=-0.5em, row sep=0.8em]
F_2 \dar{\mymatrix{0\\\mkern-5mu\mathbf{1}_{F_2\mkern-4mu}}}\rar{\phi_2} \& G_2 \dar{\mymatrix{0\\\mkern-5mu\mathbf{1}_{G_2\mkern-4mu}}}\rar{\psi_2} \& F_2\dar{\mymatrix{0\\\mkern-5mu\mathbf{1}_{F_2\mkern-4mu}}}\\
G_1\oplus F_2\rar{\mymatrix{\mkern-5mu-\psi_1\! & 0\\g &\phi_2\mkern-4mu}} \& F_1\oplus G_2 \rar{\mymatrix{\mkern-5mu-\phi_1\! & 0\\ f &\psi_2\mkern-4mu}} \& G_1\oplus F_2
\end{tikzcd} \]
\bigskip

\[ \begin{psmatrix}[rowsep=1.25cm, colsep=1.6cm]
%% Nodes
  F_2 & G_2 & F_2 \\
G_1\oplus F_2 & F_1\oplus G_2 & G_1\oplus F_2
%% Arrows and labels%
\everypsbox{\scriptstyle}
\psset{linewidth=0.6pt, arrows=->, arrowinset=0.15, nodesep=2pt, labelsep=3pt}
%% Horizontal arrows
\ncline{1,1}{1,2}\naput{\phi_2}
\ncline{1,2}{1,3}\naput{\psi_2}
\ncline{2,1}{2,2}\naput{\mymatrix{\mkern-5mu-\psi_1\! & 0\\g &\phi_2\mkern-4mu}}
\ncline{2,2}{2,3}\naput{\mymatrix{\mkern-5mu-\phi_1\! & 0\\ f &\psi_2\mkern-4mu}}
%% Vertical arrows
\psset{npos=0.45}
\ncline{1,1}{2,1}\naput{\mymatrix{0\\\mkern-5mu\mathbf{1}_{F_2\mkern-4mu}}}
\ncline{1,2}{2,2}\naput{\mymatrix{0\\\mkern-5mu\mathbf{1}_{G_2\mkern-4mu}}}
\ncline{1,3}{2,3}\naput{\mymatrix{0\\\mkern-5mu\mathbf{1}_{F_2\mkern-4mu}}}
\end{psmatrix} \]

\end{document} 

enter image description here

3
  • This is the solution I prefer, I would also show the possibility to draw the matrix of the first down arrow on the left.
    – CarLaTeX
    Oct 29, 2017 at 6:05
  • @CarLaTeX: I considered this possibility, but there's no real symmetry in the labels of the vertical arrows, due to the middle one. Unless I center it on the arrow… Do you think I should?
    – Bernard
    Oct 29, 2017 at 11:37
  • You're right, let it as is :)
    – CarLaTeX
    Oct 29, 2017 at 11:40
5

Here's a solution that employs the machinery of the amscd package, along with the bsmallmatrix environment provided by the mathtools package.

enter image description here

\documentclass{article}  
\usepackage{mathtools,amscd}
\begin{document}
\[\begin{CD}
F_2 @>\phi_2>> G_2 @>\phi_2>> F_2 \\
@VV{\begin{psmallmatrix}0\\1^{}_{F_2}\end{psmallmatrix}}V
@VV{\begin{psmallmatrix}0\\1^{}_{G_2}\end{psmallmatrix}}V
@VV{\begin{psmallmatrix}0\\1^{}_{F_2}\end{psmallmatrix}}V \\
G_1\oplus F_2 
@>{\smash[t]{\,\begin{psmallmatrix}
   -\psi_1 & 0 \\ g & \phi_2
   \end{psmallmatrix}}}>> 
F_1\oplus G_2 
@>{\smash[t]{\,\,\begin{psmallmatrix}
   -\phi_1 & 0 \\ f & \psi_2
   \end{psmallmatrix}}}>> 
G_1\oplus F_2
\end{CD}\]
\end{document}
1
  • 2
    parentheses, not brackets ... Oct 29, 2017 at 1:09
4

An answer using tikz:

\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath}
\usetikzlibrary{positioning}

\begin{document}
   \begin{tikzpicture}
      \node (A) {$F_2$};
      \node[right=3cm of A] (B) {$G_2$};
      \node[right=3cm of B] (C) {$F_2$};
      \node[below=2cm of A] (D) {$G_1\oplus F_2$};
      \node[below=2cm of B] (E) {$F_1\oplus G_2$};
      \node[below=2cm of C] (F) {$G_1 \oplus F_2$};
      \draw[->] (A)--(B) node[midway, above] {$\phi_2$};
      \draw[->] (B)--(C) node[midway, above] {$\psi_2$};
      \draw[->] (D)--(E) node[midway, above,font=\small] {$\begin{pmatrix}-\psi_1 & 0\\ g& \phi_2\end{pmatrix}$};
      \draw[->] (E)--(F) node[midway, above,font=\small] {$\begin{pmatrix}-\phi_1 & 0\\f& \psi_2\end{pmatrix}$};
      \draw[->] (A)--(D) node[midway, right,font=\small] {$\begin{pmatrix}0\\1_{F_2}\end{pmatrix}$};
      \draw[->] (B)--(E) node[midway, right,font=\small] {$\begin{pmatrix}0\\1_{G_2}\end{pmatrix}$};
      \draw[->] (C)--(F) node[midway, right,font=\small] {$\begin{pmatrix}0\\1_{F_2}\end{pmatrix}$};

   \end{tikzpicture}

\end{document}

I suggest tikz because of really advanced user control and because after you learn the basics you can use it everywhere.

Output:

enter image description here

2
  • 1
    parentheses, not brackets ... Oct 29, 2017 at 1:09
  • Thanks @barbarabeeton... Funny that nobody noticed before from all of us...
    – koleygr
    Oct 29, 2017 at 1:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .