答案1
看来 TikZ 无法正确计算倾斜标签的宽度;\mathclap
我们将其宽度设为零。您有责任查看图表并增加行或列间距以使其适合,但对于每个带有长标签的图表都是如此,因此这不是真正的问题。
我还添加了带有不倾斜标签的版本,我更喜欢这个版本,因为它不会强迫读者倾斜头部来查看标签。
\documentclass{article}
\usepackage{amsmath,mathtools}
\usepackage{tikz-cd}
\newcommand{\id}{\mathrm{id}}
\begin{document}
\begin{tikzcd}[column sep=huge,row sep=large]
k\otimes A
\arrow[r,"\eta\otimes\id_A"]
\arrow[dr,"\mathclap{\mu\circ(\eta\otimes\id_A)}"',sloped]
&
A\otimes A
\arrow[d,"\mu"]
&
A\otimes k
\arrow[l,"\id_A\otimes\eta"']
\arrow[dl,"\mathclap{\mu\circ(\id_A\otimes\eta)}",sloped]
\\
& A
\end{tikzcd}
\begin{tikzcd}[column sep=huge,row sep=large]
k\otimes A
\arrow[r,"\eta\otimes\id_A"]
\arrow[dr,"\mu\circ(\eta\otimes\id_A)"']
&
A\otimes A
\arrow[d,"\mu"]
&
A\otimes k
\arrow[l,"\id_A\otimes\eta"']
\arrow[dl,"\mu\circ(\id_A\otimes\eta)"]
\\
& A
\end{tikzcd}
\end{document}
答案2
pstricks
只是为了,,如果我很好地理解了你想要什么,那么使用nrot=
节点连接标签的键就非常容易了:
\documentclass[border=5pt, svgnames]{standalone}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\DeclareMathOperator{\id}{id}
\usepackage{pst-node}
\usepackage{auto-pst-pdf} % To compile with pdflatex --enable-write18 (MiKTeX) or pdflatex-shell-escape (TeX Live, MacTeX)
% pdflatex
\begin{document}
$ \everypsbox{\scriptstyle}\begin{psmatrix}
%% nodes
k \otimes A & A \otimes A & A \otimesk \\
& A
% arrows
\psset{arrows=->, arrowinset=0.12, nodesep=3pt, labelsep=1pt}
\ncline{1,1}{1,2}\naput{\eta \otimes\id_A}
\ncline[nodesepB=1pt]{1,1}{2,2}\nbput[nrot=:U]{\mu\circ(\eta \otimes\id_{A}\mkern-1mu)}
\ncline{1,2}{2,2}\naput{\mu}
\ncline{1,3}{1,2}\nbput{\id_A\otimes\eta}
\ncline[nodesepB=1pt]{1,3}{2,2}\naput[nrot=:D]{\mu\circ(\id_{A}\otimes\eta)}
\end{psmatrix} $
\end{document}