I want to write a commutative diagram with tikz where some arrows are labeled with matrices. I know that nesting creates problems in tikz, and I don't know how to handle this. I usually put the commands for arrows into square brakets, e.g. in the following way
\arrow[r, hook, "f"]
Now I have come up with a tentative solution, but this does not work writing it with square brakets for some reasons. So I must use curly ones. But with the latter, I can't move the label, so they overlap. How can I move the labels outside the diagram? (Or increase the space between columns, or any other solution, but I would prefer also to know how to swap side for the labels when writing with curly brakets)
Here is a MWE:
\documentclass[a4paper,11pt,twoside]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage{graphicx, tikz-cd}
\usepackage{indentfirst}
\usepackage{amsmath,amssymb, mathtools}
\usepackage{microtype}
\begin{tikzcd}[ampersand replacement=\&]
A_n\oplus A_{n-1} \arrow{r}{\begin{psmallmatrix} d_n^A & (-1)^n \\ 0 & d_{n-1}^A \end{psmallmatrix}} \arrow{d}{\begin{psmallmatrix} 0 & 1 \\ f_n & 0 \end{psmallmatrix}}
\&A_{n-1}\oplus A_{n-2}\arrow{d}{\begin{psmallmatrix} 0 & 1 \\ f_n & 0 \end{psmallmatrix}}
\\
A_{n-1} \oplus B_n \arrow{r}{\begin{psmallmatrix} -d^A_{n-1} & 0 \\ f_{n-1} & d^B_n \end{psmallmatrix}}
\& A_{n-2} \oplus B_{n-1}
\end{tikzcd}