# draw diagrams with \xymatrix

I'm using \xymatrix to draw a diagram and I need some of the arrows to be named with a matrix over it. To draw the matrices over arrows, I'm using the \arrow command but, unfortunately, it puts very large matrices and collapses the diagram. The usual size-changing commands, such as \scriptstyle..., do not work. could somebody give a hint? Thanks in advance.

• Could you post the example code that you're working with, to give an indication of what you're trying to do and what's not working? – Arun Debray Jan 7 '16 at 20:44

The smallmatrix environments are the right thing to use here, since they by default are small enough to fit into a line of text. You can use \begin{smallmatrix}...\end{smallmatrix} in place of \begin{matrix}...\end{matrix} to get something that's small enough.

Then, if you use the mathtools package, you can add delimiters: psmallmatrix is like pmatrix (a matrix delimited by parentheses, but smaller), bsmallmatrix uses brackets like bmatrix, and so on.

Here's how this looks with arrows in a commutative diagram:

\documentclass{article}
\usepackage{mathtools}
\usepackage[all]{xy}
\begin{document}
$\xymatrix{ A \ar[r]^{\begin{psmallmatrix}1 & 0\\0 & 1\end{psmallmatrix}} \ar[d]_{\begin{psmallmatrix}1 & -1\\-1 & 1\end{psmallmatrix}} & B\ar[d]^{\begin{psmallmatrix}c & 0\\d & e\end{psmallmatrix}} \\ C\ar[r]_{\begin{bsmallmatrix}a & 0\\0 & b\end{bsmallmatrix}} & D }$
\end{document}


In addition to Arun's solution, this is how it would look like with :

% arara: pdflatex

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

\begin{document}
\begin{tikzcd}[ampersand replacement=\&]
A \arrow{d}[swap]{\begin{psmallmatrix}1 & 0\\0 & 1\end{psmallmatrix}} \arrow{r}{\begin{psmallmatrix}1 & 0\\0 & 1\end{psmallmatrix}} \& B \arrow{d}{\begin{psmallmatrix}1 & 0\\0 & 1\end{psmallmatrix}} \\
C \arrow{r}[swap]{\begin{psmallmatrix}1 & 0\\0 & 1\end{psmallmatrix}} \& D
\end{tikzcd}
\end{document}