我有这个交换图:
\begin{equation*}
\begin{tikzcd}
A\arrow[r,"a"]\arrow[d,"a"]&A\arrow[d,"a"]\\
A\arrow[r,"a"]&A
\end{tikzcd}
\end{equation*}
我想用大写字母 C 来命名图表,那么如何在图表中间放置大写字母 C?
答案1
一种可能的方法。
\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}
如果您有许多带有 2x2 节点的图表,您可以将其设置为一种样式。
\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}