# Naming diagrams drawn with tikz-cd

I have this commutative diagram:

\begin{equation*}
\begin{tikzcd}
A\arrow[r,"a"]\arrow[d,"a"]&A\arrow[d,"a"]\\
A\arrow[r,"a"]&A
\end{tikzcd}
\end{equation*}


I want to name the diagram with a capital C, so how can I put a capital C in the middle of the diagram?

One possible way.

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}
\begin{document}
\begin{equation*}
% based on https://tex.stackexchange.com/a/405152/121799
\begin{tikzcd}[execute at end picture={
\node at (barycentric cs:\tikzcdmatrixname-1-1=1,\tikzcdmatrixname-1-2=1,%
\tikzcdmatrixname-2-1=1,\tikzcdmatrixname-2-2=1) {C};
}]
A\arrow[r,"a"]\arrow[d,"a"]&A\arrow[d,"a"]\\
A\arrow[r,"a"]&A
\end{tikzcd}
\end{equation*}
\end{document}


If you have many diagrams with 2x2 nodes, you could make it a style.

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}
\begin{document}
\tikzset{cd name/.style={execute at end picture={
\node at (barycentric cs:\tikzcdmatrixname-1-1=1,\tikzcdmatrixname-1-2=1,%
\tikzcdmatrixname-2-1=1,\tikzcdmatrixname-2-2=1) {#1};
}}}
\begin{equation*}
% based on https://tex.stackexchange.com/a/405152/121799
\begin{tikzcd}[cd name=C]
A\arrow[r,"a"]\arrow[d,"a"]&A\arrow[d,"a"]\\
A\arrow[r,"a"]&A
\end{tikzcd}
\end{equation*}
\end{document}


Another solution using the measure .25cm to create a larger or smaller square with the letter C in the middle.

\documentclass[a4paper,12pt]{article}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}[column sep=.25cm,row sep=.25cm]
A \arrow[dd, "a"] \arrow[rr, "a"] &  & A \arrow[dd, "a"] \\
& \textrm{C} &  \\
A \arrow[rr, "a"] &  & A
\end{tikzcd}
\end{document}