我正在处理一堆短正合序列,我认为当箭头长度约为 1 厘米时,它们看起来最好。如果需要,它只留出足够的空间在箭头上贴标签,但又不会太多,如果我选择不贴标签,它看起来会完全是空的。当节点有简单的标签时,设置节点距离就很好了
\begin{tikzpicture}[node distance = 1.25cm, auto]
\node (01) {$0$};
\node (A) [right of=01] {$A$};
\node (B) [right of=A] {$B$};
\node (C) [right of=B] {$C$};
\node (02) [right of=C] {$0$};
\draw[->] (01) to node {} (A);
\draw[->] (A) to node {$\alpha$} (B);
\draw[->] (B) to node {$\beta$} (C);
\draw[->] (C) to node {} (02);
\end{tikzpicture}
但是当节点标签变得更加复杂时,它就会开始变得混乱和有点尴尬。
\begin{tikzpicture}[node distance = 1.25cm, auto]
\node (01) {$0$};
\node (AM) [right of=01] {$A \oplus M$};
\node (BM) [right of=AM] {$B \oplus M$};
\node (C) [right of=BM] {$C$};
\node (02) [right of=C] {$0$};
\draw[->] (01) to node {} (AM);
\draw[->] (AM) to node {$\alpha'$} (BM);
\draw[->] (BM) to node {$\beta'$} (C);
\draw[->] (C) to node {} (02);
\end{tikzpicture}
(抱歉,我不知道如何让 TeX 编译并实际出现在这篇文章中)
那么,有没有办法设置标准箭头长度,或者让节点距离通过节点之间的空间而不是中心到中心来测量?
答案1
使用positioning
库和新语法
right =of 01
而不是right of=01
。我希望你的幸福感会增加;)
\documentclass[tikz]{standalone}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[node distance = 1.25cm, auto]
\node (01) {$0$};
\node (AM) [right =of 01] {$A \oplus M$};
\node (BM) [right =of AM] {$B \oplus M$};
\node (C) [right =of BM] {$C$};
\node (02) [right =of C] {$0$};
\draw[->] (01) to node {} (AM);
\draw[->] (AM) to node {$\alpha'$} (BM);
\draw[->] (BM) to node {$\beta'$} (C);
\draw[->] (C) to node {} (02);
\end{tikzpicture}
\begin{tikzpicture}[node distance = 1.25cm, auto]
\node (01) {$0$};
\node (A) [right =of 01] {$A$};
\node (B) [right =of A] {$B$};
\node (C) [right =of B] {$C$};
\node (02) [right =of C] {$0$};
\draw[->] (01) to node {} (A);
\draw[->] (A) to node {$\alpha$} (B);
\draw[->] (B) to node {$\beta$} (C);
\draw[->] (C) to node {} (02);
\end{tikzpicture}
\end{document}