答案1
我们可以将盒子放在中间,作为“近端”的标签,但要稍微降低一点,深度要小一些。对于上面的盒子,我使用\overset
,但为了安全起见,将盒子的宽度设为零。
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}
\newcommand{\sboxed}[1]{%
\,\raisebox{-1ex}[\height][0pt]{\fbox{$\scriptstyle\mathstrut#1$}}%
}
\newcommand{\uboxed}[1]{%
\makebox[0pt]{\fbox{$\scriptstyle\mathstrut#1$}}%
}
\begin{document}
\begin{tikzcd}[row sep=huge,column sep=large]
0 \arrow[r] &
C_{p+1} \arrow[r,"\phi"] \arrow[d,"\partial_C"',"\sboxed{c_p}" near end] &
\overset{\uboxed{d_{p+1}}}{D_{p+1}}
\arrow[r,"\psi"] \arrow[d,"\partial_D"',"\sboxed{d_p}" near end] &
\overset{\uboxed{e_{p+1}}}{E_{p+1}}
\arrow[r] \arrow[d,"\partial_E"',"\sboxed{e_p}" near end] &
0 \\
0 \arrow[r] &
C_{p} \arrow[r,"\phi"] \arrow[d,"\partial_C"',"\sboxed{c_{p-1}}" near end] &
D_{p} \arrow[r,"\psi"] \arrow[d,"\partial_D"',] &
E_{p} \arrow[r] \arrow[d,"\partial_E"'] &
0 \\
0 \arrow[r] &
C_{p-1} \arrow[r,"\phi"] &
D_{p-1} \arrow[r,"\psi"] &
E_{p-1} \arrow[r] &
0
\end{tikzcd}
\end{document}
答案2
有更好的 TikZ 方法(使用节点选项label
):
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}
\tikzset{% my label style:
myls/.style={
draw, text height=height("$d$")
}
}
\begin{document}
\begin{tikzcd}[row sep=large,column sep=large]
0 \arrow[r] &
C_{p+1} \arrow[r,"\phi"] \arrow[d,"\partial_C"'] & |[label={[myls]d_{p+1}}]|D_{p+1}
\arrow[r,"\psi"] \arrow[d,"\partial_D"'] &
|[label={[myls]e_{p+1}}]|E_{p+1}
\arrow[r] \arrow[d,"\partial_E"'] &
0 \\
0 \arrow[r] &
|[label={[myls]45:c_p}]|C_{p} \arrow[r,"\phi"] \arrow[d,"\partial_C"'] &
|[label={[myls]45:d_p}]|D_{p} \arrow[r,"\psi"] \arrow[d,"\partial_D"',] &
|[label={[myls]45:e_p}]|E_{p} \arrow[r] \arrow[d,"\partial_E"'] &
0 \\
0 \arrow[r] &
|[label={[myls]45:c_{p-1}}]|C_{p-1} \arrow[r,"\phi"] &
D_{p-1} \arrow[r,"\psi"] &
E_{p-1} \arrow[r] &
0
\end{tikzcd}
\end{document}