How to “design” and code a 3x3x3 3d diagram in tikz-cd

tikz-cd

I need to do a 3x3x3 diagram in tikz-cd and I'm wondering what's the best way to code it to make ti as clear as possible.

I've a little experience with 2x2x2 diagrams in tikz-cd using crossing-over, but when it comes to 3x3x3 the crossing over command fails:

\documentclass[11pt,a4paper]{article}
\usepackage[left=2cm,right=2cm,top=2.5cm,bottom=2.5cm]{geometry}
\usepackage{tikz-cd}
\newlength{\perspective}
\begin{document}
 \begin{tikzcd}[row sep=1.5em, column sep =.1]
 (k-1,j-1,i-1) \arrow{ddd} \arrow{dr}& &  & (k,j-1,i-1) \arrow{lll} \arrow{ddd}\arrow{dr}& &  & \\
{} & (k-1,j-1,i)\arrow[ddd, crossing over]\arrow{dr}&  & & (k,j-1,i)  \arrow[lll, crossing over]\arrow{ddd}\arrow{dr} &  & \\
{} & & (k-1,j-1,i+1)\arrow{ddd} & & & (k,j-1,i+1) \arrow{ddd}\arrow[lll, crossing over]&{}\\ 
(k-1,j,i-1)\arrow[ddd, crossing over]\arrow{dr} & &  & (k,j,i-1)  \arrow{lll}\arrow{ddd}\arrow{dr} & &  & \\
{} & (k-1,j,i)\arrow{ddd}\arrow{dr}&  & & (k,j,i) \arrow[lll, crossing over]\arrow{ddd}\arrow{dr}&  & \\
{} & & (k-1,j,i+1)\arrow{ddd} & & & (k,j,i+1) \arrow{lll}\arrow{ddd} &{}\\ 
(k-1,j+1,i-1)\arrow{dr} & &  & (k,j+1,i-1) \arrow{lll}\arrow{dr} & &  & \\
{} & (k-1,j+1,i)\arrow{dr}&  & & (k,j+1,i)\arrow{dr} \arrow{lll} &  & \\
{} & & (k-1,j+1,i+1) & & & (k,j+1,i+1) \arrow{lll} &{}
\end{tikzcd}

\end{document}

As you can see, the arrow from (k,j,i) to (k-1,j,i) should be UNDER the vertical arrow starting at (k-1,j-1,i+1) but I don't know how to control it. Is there some ready-made 3x3x3 diagram or some resources where I can learn how to code these kind of big diagrams with the correct over and underlapping?

I found an "isometric" way to draw diagrams in tikz-cd which might improve readability by a lot (https://tex.stackexchange.com/a/234151/47869) but I'm not sure how this \isofactor and \perspective commands work. IS there any resource for understanding how to design an isometric 3x3x3 diagram in tikz-cd?

Best Answer

Build your diagram from "back" to "front", crossing over when necessary. One way to make this easier to write and edit is to draw all your arrows at the end using the syntax \arrow[from=r1-c1,to=r2-c2] (row and column numbers).

enter image description here

\documentclass{article}
\usepackage{tikz-cd}

\begin{document}
\begin{tikzcd}[row sep=1.5em, column sep =.1]
 (k-1,j-1,i-1) & &  & (k,j-1,i-1) & & \\
 & (k-1,j-1,i) &  &  & (k,j-1,i) &  & \\
 & & (k-1,j-1,i+1) & & & (k,j-1,i+1) & \\ 
 (k-1,j,i-1) & & & (k,j,i-1) & & \\
 & (k-1,j,i) & & & (k,j,i) &  \\
 & & (k-1,j,i+1) & & & (k,j,i+1) \\ 
 (k-1,j+1,i-1) & &  & (k,j+1,i-1) & &   \\
 & (k-1,j+1,i) &  & & (k,j+1,i) &  \\
 & & (k-1,j+1,i+1) & & & (k,j+1,i+1)
 \arrow[from=1-1,to=4-1]\arrow[from=4-1,to=7-1]
 \arrow[from=1-4,to=4-4]\arrow[from=4-4,to=7-4]
 \arrow[from=1-4,to=1-1]\arrow[from=7-4,to=7-1]
 \arrow[from=4-4,to=4-1]
 \arrow[from=2-2,to=5-2, crossing over]\arrow[from=5-2,to=8-2, crossing over]
 \arrow[from=2-5,to=5-5]\arrow[from=5-5,to=8-5]
 \arrow[from=2-5,to=2-2, crossing over]\arrow[from=8-5,to=8-2] 
 \arrow[from=5-5,to=5-2, crossing over] 
 \arrow[from=3-3,to=6-3, crossing over]\arrow[from=6-3,to=9-3, crossing over]
 \arrow[from=3-6,to=6-6]\arrow[from=6-6,to=9-6]
 \arrow[from=3-6,to=3-3, crossing over]\arrow[from=9-6,to=9-3] 
 \arrow[from=6-6,to=6-3, crossing over] 
 \arrow[from=1-1,to=2-2]\arrow[from=2-2,to=3-3]
 \arrow[from=4-1,to=5-2]\arrow[from=5-2,to=6-3]
 \arrow[from=7-1,to=8-2]\arrow[from=8-2,to=9-3]
 \arrow[from=1-4,to=2-5]\arrow[from=2-5,to=3-6]
 \arrow[from=4-4,to=5-5]\arrow[from=5-5,to=6-6]
 \arrow[from=7-4,to=8-5]\arrow[from=8-5,to=9-6]
\end{tikzcd}

\end{document}
Related Question