3

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?

6

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}

enter image description here

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}
3

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

enter image description here

\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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.