我正在使用 制作交换图tikz-cd
。但是,我在垂直放置箭头标签时遇到了麻烦。正如您在图片中看到的,分数\tfrac{a}{b_0}
缩小了左右箭头。因此标签\phi
与中间箭头的标签不在同一高度。是否有可能垂直对齐所有箭头标签,使它们位于同一高度?
这是生成图表的最小工作示例。
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}[row sep=large]
0\arrow[r]&\tfrac{a}{b_0}X\arrow[d,"\phi"]\arrow[r]&X\arrow[d,"\phi"'] \arrow[r] & X/\tfrac{a}{b_0}X\arrow[d,"\phi"']\arrow[r]&0\\
0\arrow[r]&\tfrac{a}{b_0}Y\arrow[r] &Y \arrow[r]& Y/\tfrac{a}{b}Y\arrow[r]&0
\end{tikzcd}
\end{document}
答案1
除了 Salim 的回答之外,您还可以使用\vphantom
任何您喜欢的内容:
% arara: pdflatex
% arara: pdflatex
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}[row sep=large,remember picture]
0\arrow[r]&\tfrac{a}{b_0}X\arrow[d,"\phi"]\arrow[r]&\vphantom{\tfrac{a}{b_0}}X\arrow[d,"\phi"'] \arrow[r] & X/\tfrac{a}{b_0}X\arrow[d,"\phi"']\arrow[r]&0\\
0\arrow[r]&\tfrac{a}{b_0}Y\arrow[r] &Y \arrow[r]& Y/\tfrac{a}{b}Y\arrow[r]&0
\end{tikzcd}
\begin{tikzpicture}[remember picture,overlay]
\draw[thick,red] ([xshift=-1cm,yshift=-.99cm]\tikzcdmatrixname-1-1.west) -- ([xshift=1cm,yshift=-.99cm]\tikzcdmatrixname-1-5.east);
\end{tikzpicture}
\end{document}
答案2
标签未对齐,因为第一行元素的深度不相等,您可以定义一个支柱使它们相等。对于第二行,只需简单\strut
获得相等的高度即可
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}
\def\mystrut{\vrule width0pt height.7\baselineskip depth.4\baselineskip}
\begin{document}
\begin{tikzcd}[row sep=large]
0\arrow[r]&\mystrut \tfrac{a}{b_0}X\arrow[d,"\phi"]\arrow[r]& \mystrut X\arrow[d,"\phi"'] \arrow[r] & \mystrut X/\tfrac{a}{b_0}X\arrow[d,"\phi"']\arrow[r]&0\\
0\arrow[r]&\strut \tfrac{a}{b_0}Y\arrow[r] & \strut Y \arrow[r]& \strut Y/\tfrac{a}{b}Y\arrow[r]&0
\end{tikzcd}
\end{document}