设置三个交叉箭头的顺序

设置三个交叉箭头的顺序

我正在绘制一个三维的图表,其中有 27 个点,分为三层,每层九个点。我想要做的是能够优先考虑线条如何交叉。当我使用“交叉”时,一条线似乎会自动交叉它接触的任何其他线。例如,14 和 15 之间的线应该与 11 和 20 之间的线重叠,因为它更靠前,但 9 和 18 之间的线应该与 14 和 15 之间的线重叠,因为它在前面。如果我对 14->15 使用“交叉”,它将与 9->18 重叠,即使我在那里也使用“交叉”。这是我使用的代码:

\documentclass[12pt]{article}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}[cells={nodes={draw=gray}}, row sep=scriptsize, column sep=scriptsize]
& & & & 1 \arrow[dll, dash] \arrow[rrr, dash] \arrow[ddd, dash] & & & 2 \arrow[dll, dash] \arrow[rrr, dash] \arrow[ddd, dash] & & & 3 \arrow[dll, dash] \arrow[ddd, dash] \\
& & 4 \arrow[dll, dash] \arrow[rrr, crossing over, dash] \arrow[ddd, dash] & & & 5 \arrow[dll, crossing over, dash] \arrow[rrr, crossing over, dash] \arrow[ddd, dash] & & & 6 \arrow[dll, crossing over, dash] \arrow[ddd, dash] & &\\
 7 \arrow[rrr, crossing over, dash] \arrow[ddd, dash] & & & 8 \arrow[rrr, crossing over, dash] \arrow[ddd, dash] & & & 9 \arrow[ddd, crossing over, dash] & & & &\\
 & & & & 10 \arrow[dll, dash] \arrow[rrr, dash] \arrow[ddd, dash] & & & 11 \arrow[dll, dash] \arrow[rrr, dash] \arrow[ddd, dash] & & & 12 \arrow[dll, dash] \arrow[ddd, dash] \\
& & 13 \arrow[dll, dash] \arrow[rrr, crossing over, dash] \arrow[ddd, dash] & & & 14 \arrow[dll, dash] \arrow[rrr, crossing over, dash] \arrow[ddd, dash] & & & 15 \arrow[dll, dash] \arrow[ddd, dash] & &\\
 16 \arrow[rrr, crossing over, dash] \arrow[ddd, dash] & & & 17 \arrow[rrr, crossing over, dash] \arrow[ddd, dash] & & & 18 \arrow[ddd, dash] & & & &\\
& & & & 19 \arrow[dll, dash] \arrow[rrr, dash] & & & 20 \arrow[dll, dash] \arrow[rrr, dash] & & & 21 \arrow[dll, dash] \\
& & 22 \arrow[dll, dash] \arrow[rrr, crossing over, dash] & & & 23 \arrow[dll, dash] \arrow[rrr, crossing over, dash] & & & 24 \arrow[dll, dash] & &\\
25 \arrow[rrr, crossing over, dash] & & & 26 \arrow[rrr, crossing over, dash] & & & 27 & & & &\\
\end{tikzcd}
\end{document}

感谢您的帮助!

答案1

您可以使用键推迟箭头from。例如,9不要从 绘制箭头到 ,18而是从18绘制箭头,就像

18  \arrow[from=uuu, crossing over]

使其看起来位于顶部。

\documentclass[12pt]{article}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}[cells={nodes={draw=gray}}, row sep=scriptsize, column sep=scriptsize]
& & & & 1 \arrow[dll, dash] \arrow[rrr, dash] \arrow[ddd, dash] & & & 2 \arrow[dll, dash] \arrow[rrr, dash] \arrow[ddd, dash] & & & 3 \arrow[dll, dash] \arrow[ddd, dash] \\
& & 4 \arrow[dll, dash] \arrow[rrr, crossing over, dash] \arrow[ddd, dash] & & & 5 \arrow[dll, crossing over, dash] \arrow[rrr, crossing over, dash] \arrow[ddd, dash] & & & 6 \arrow[dll, crossing over, dash] & &\\
 7 \arrow[rrr, crossing over, dash] \arrow[ddd, dash] & & & 8 \arrow[rrr, crossing over, dash] & & & 9 & & & &\\
 & & & & 10 \arrow[dll, dash] \arrow[rrr, dash] \arrow[ddd, dash] & & & 11 \arrow[dll, dash] \arrow[rrr, dash] \arrow[ddd, dash] & & & 12 \arrow[dll, dash] \arrow[ddd, dash] \\
& & 13 \arrow[dll, dash] \arrow[rrr, crossing over, dash] \arrow[ddd, dash] & & & 14 \arrow[ddd,crossing over,dash]\arrow[rrr, crossing over, dash] \arrow[ddd, dash] & & & 15 \arrow[from=uuu,crossing over, dash]& &\\
 16 \arrow[rrr, crossing over, dash] \arrow[ddd, dash] & & & 17 \arrow[from=rru,crossing over, dash] \arrow[from=uuu,crossing over, dash]\arrow[rrr, crossing over, dash] & & & 18 \arrow[from=rru,crossing over, dash] \arrow[from=uuu, crossing over,dash] & & & &\\
& & & & 19 \arrow[dll, dash] \arrow[rrr, dash] & & & 20 \arrow[dll, dash] \arrow[rrr, dash] & & & 21 \arrow[dll, dash] \\
& & 22 \arrow[dll, dash] \arrow[rrr, crossing over, dash] & & & 23 \arrow[dll, dash] \arrow[rrr, crossing over, dash] & & & 24 \arrow[from=uuu,crossing over, dash] \arrow[dll, dash] & &\\
25 \arrow[rrr, crossing over, dash] & & & 26 \arrow[from=uuu,crossing over, dash]\arrow[rrr, crossing over, dash] & & & 27 \arrow[from=uuu,crossing over, dash]& & & &\\
\end{tikzcd}
\end{document}

在此处输入图片描述

相关内容