![使用 TikZ-cd 绘制立方体](https://linux22.com/image/307800/%E4%BD%BF%E7%94%A8%20TikZ-cd%20%E7%BB%98%E5%88%B6%E7%AB%8B%E6%96%B9%E4%BD%93.png)
我想用 TikZ-cd 画一个立方体。条目大小不同,这会导致与我的相同的问题前一个问题,因为我希望箭头平行。
\[\begin{tikzcd}[row sep=25,column sep=0,nodes={inner sep=2pt},
cells={nodes={align=center,text width=\widthof{$X_2 \times_{S_2} Y_2$}}}]
& X_1 \times_{S_1} Y_1 \ar{rr} \ar{dd} \ar{dl} & & Y_1 \ar{dd} \ar{dl} \\
X_1 \ar[crossing over]{rr} \ar{dd} & & S_1 \\
& X_2 \times_{S_2} Y_2 \ar{rr} \ar{dl} & & Y_2 \ar{dl} \\
X_2 \ar{rr} && S_2 \ar[from=uu,crossing over]
\end{tikzcd}\]
如何实现箭头真正在节点处结束和开始?当然,它们在形式上确实在节点处开始和结束,但我的意思是,例如上箭头实际上在 Y_1 附近结束。
答案1
如果您不是使用边框之间的特定宽度来分隔列,而是使用原点(节点中心)之间的宽度来分隔列,那么看起来会更好。
% arara: lualatex
\documentclass{article}
\usepackage{tikz-cd}
\usepackage{lua-visual-debug} % just for proove of symmetry. Without that, you may compile with pdfLaTeX
\begin{document}
\[\begin{tikzcd}[row sep={40,between origins}, column sep={40,between origins}]
& X_1 \times_{S_1} Y_1 \ar{rr}\ar{dd}\ar{dl} & & Y_1\vphantom{\times_{S_1}} \ar{dd}\ar{dl} \\
X_1 \ar[crossing over]{rr} \ar{dd} & & S_1 \\
& X_2 \times_{S_2} Y_2 \ar{rr} \ar{dl} & & Y_2\vphantom{\times_{S_1}} \ar{dl} \\
X_2 \ar{rr} && S_2 \ar[from=uu,crossing over]
\end{tikzcd}\]
\end{document}
如果你想让它真正逼真,我建议添加一些透视调整:
% arara: pdflatex
\documentclass{article}
\usepackage{tikz-cd}
\newlength{\perspective}
\begin{document}
\setlength{\perspective}{2pt}
\[\begin{tikzcd}[row sep={40,between origins}, column sep={40,between origins}]
&[-\perspective] X_1 \times_{S_1} Y_1 \ar{rr}\ar{dd}\ar{dl} &[\perspective] &[-\perspective] Y_1\vphantom{\times_{S_1}} \ar{dd}\ar{dl} \\[-\perspective]
X_1 \ar[crossing over]{rr} \ar{dd} & & S_1 \\[\perspective]
& X_2 \times_{S_2} Y_2 \ar{rr} \ar{dl} & & Y_2\vphantom{\times_{S_1}} \ar{dl} \\[-\perspective]
X_2 \ar{rr} && S_2 \ar[from=uu,crossing over]
\end{tikzcd}\]
\setlength{\perspective}{5pt}
\[\begin{tikzcd}[row sep={40,between origins}, column sep={40,between origins}]
&[-\perspective] X_1 \times_{S_1} Y_1 \ar{rr}\ar{dd}\ar{dl} &[\perspective] &[-\perspective] Y_1\vphantom{\times_{S_1}} \ar{dd}\ar{dl} \\[-\perspective]
X_1 \ar[crossing over]{rr} \ar{dd} & & S_1 \\[\perspective]
& X_2 \times_{S_2} Y_2 \ar{rr} \ar{dl} & & Y_2\vphantom{\times_{S_1}} \ar{dl} \\[-\perspective]
X_2 \ar{rr} && S_2 \ar[from=uu,crossing over]
\end{tikzcd}\]
\setlength{\perspective}{8pt}
\[\begin{tikzcd}[row sep={40,between origins}, column sep={40,between origins}]
&[-\perspective] X_1 \times_{S_1} Y_1 \ar{rr}\ar{dd}\ar{dl} &[\perspective] &[-\perspective] Y_1\vphantom{\times_{S_1}} \ar{dd}\ar{dl} \\[-\perspective]
X_1 \ar[crossing over]{rr} \ar{dd} & & S_1 \\[\perspective]
& X_2 \times_{S_2} Y_2 \ar{rr} \ar{dl} & & Y_2\vphantom{\times_{S_1}} \ar{dl} \\[-\perspective]
X_2 \ar{rr} && S_2 \ar[from=uu,crossing over]
\end{tikzcd}\]
\setlength{\perspective}{11pt}
\[\begin{tikzcd}[row sep={40,between origins}, column sep={40,between origins}]
&[-\perspective] X_1 \times_{S_1} Y_1 \ar{rr}\ar{dd}\ar{dl} &[\perspective] &[-\perspective] Y_1\vphantom{\times_{S_1}} \ar{dd}\ar{dl} \\[-\perspective]
X_1 \ar[crossing over]{rr} \ar{dd} & & S_1 \\[\perspective]
& X_2 \times_{S_2} Y_2 \ar{rr} \ar{dl} & & Y_2\vphantom{\times_{S_1}} \ar{dl} \\[-\perspective]
X_2 \ar{rr} && S_2 \ar[from=uu,crossing over]
\end{tikzcd}\]
\end{document}
实际上,你甚至应该将它稍微旋转到等距视图中。我猜,Ti 还有其他解决方案钾Z 周围。但为了完整起见:
% arara: pdflatex
\documentclass[twocolumn]{article}
\usepackage{tikz-cd}
\newlength{\perspective}
\begin{document}
\setlength{\perspective}{12pt}
\def\isofactor{0.5}
\[\begin{tikzcd}[row sep={38,between origins}, column sep={38,between origins}]
&[-\perspective] X_1 \times_{S_1} Y_1 \ar{rrd}\ar{dddd}\ar{ddl} &[\perspective] &[-\perspective] \\[-38+\isofactor\perspective]
& & & Y_1\vphantom{\times_{S_1}} \ar{dddd}\ar{ddl} & \\[-\perspective-\isofactor\perspective]
X_1 \ar[crossing over]{rrd} \ar{dddd} & & & \\[-38+\isofactor\perspective]
& & S_1 \\[\perspective-\isofactor\perspective]
& X_2 \times_{S_2} Y_2 \ar{rrd} \ar{ddl} & & \\[-38+\isofactor\perspective]
& & & Y_2\vphantom{\times_{S_1}} \ar{ddl} \\[-\perspective-\isofactor\perspective]
X_2 \ar{rrd} & & \\[-38+\isofactor\perspective]
& & S_2 \ar[from=uuuu,crossing over] &
\end{tikzcd}\]
\setlength{\perspective}{10pt}
\def\isofactor{1}
\[\begin{tikzcd}[row sep={38,between origins}, column sep={38,between origins}]
&[-\perspective] X_1 \times_{S_1} Y_1 \ar{rrd}\ar{dddd}\ar{ddl} &[\perspective] &[-\perspective] \\[-38+\isofactor\perspective]
& & & Y_1\vphantom{\times_{S_1}} \ar{dddd}\ar{ddl} & \\[-\perspective-\isofactor\perspective]
X_1 \ar[crossing over]{rrd} \ar{dddd} & & & \\[-38+\isofactor\perspective]
& & S_1 \\[\perspective-\isofactor\perspective]
& X_2 \times_{S_2} Y_2 \ar{rrd} \ar{ddl} & & \\[-38+\isofactor\perspective]
& & & Y_2\vphantom{\times_{S_1}} \ar{ddl} \\[-\perspective-\isofactor\perspective]
X_2 \ar{rrd} & & \\[-38+\isofactor\perspective]
& & S_2 \ar[from=uuuu,crossing over] &
\end{tikzcd}\]
\vfill\break
\setlength{\perspective}{8pt}
\def\isofactor{1.5}
\[\begin{tikzcd}[row sep={38,between origins}, column sep={38,between origins}]
&[-\perspective] X_1 \times_{S_1} Y_1 \ar{rrd}\ar{dddd}\ar{ddl} &[\perspective] &[-\perspective] \\[-38+\isofactor\perspective]
& & & Y_1\vphantom{\times_{S_1}} \ar{dddd}\ar{ddl} & \\[-\perspective-\isofactor\perspective]
X_1 \ar[crossing over]{rrd} \ar{dddd} & & & \\[-38+\isofactor\perspective]
& & S_1 \\[\perspective-\isofactor\perspective]
& X_2 \times_{S_2} Y_2 \ar{rrd} \ar{ddl} & & \\[-38+\isofactor\perspective]
& & & Y_2\vphantom{\times_{S_1}} \ar{ddl} \\[-\perspective-\isofactor\perspective]
X_2 \ar{rrd} & & \\[-38+\isofactor\perspective]
& & S_2 \ar[from=uuuu,crossing over] &
\end{tikzcd}\]
\setlength{\perspective}{6pt}
\def\isofactor{2}
\[\begin{tikzcd}[row sep={38,between origins}, column sep={38,between origins}]
&[-\perspective] X_1 \times_{S_1} Y_1 \ar{rrd}\ar{dddd}\ar{ddl} &[\perspective] &[-\perspective] \\[-38+\isofactor\perspective]
& & & Y_1\vphantom{\times_{S_1}} \ar{dddd}\ar{ddl} & \\[-\perspective-\isofactor\perspective]
X_1 \ar[crossing over]{rrd} \ar{dddd} & & & \\[-38+\isofactor\perspective]
& & S_1 \\[\perspective-\isofactor\perspective]
& X_2 \times_{S_2} Y_2 \ar{rrd} \ar{ddl} & & \\[-38+\isofactor\perspective]
& & & Y_2\vphantom{\times_{S_1}} \ar{ddl} \\[-\perspective-\isofactor\perspective]
X_2 \ar{rrd} & & \\[-40+\isofactor\perspective]
& & S_2 \ar[from=uuuu,crossing over] &
\end{tikzcd}\]
\end{document}
答案2
您可以玩start anchor
和end anchor
。
梅威瑟:
\documentclass{article}
\usepackage{tikz-cd}
\begin{document}
\[\begin{tikzcd}[row sep=25,column sep=0,nodes={inner sep=2pt},
cells={nodes={align=center,text width=\widthof{$X_2 \times_{S_2} Y_2$}}}]
& X_1 \times_{S_1} Y_1 \ar[end anchor={[xshift=15pt]}]{rr} \ar{dd} \ar{dl} & & Y_1 \ar{dd} \ar{dl} \\
X_1 \ar[crossing over,start anchor={[xshift=-15pt]},end anchor={[xshift=15pt]}]{rr} \ar{dd} & & S_1 \\
& X_2 \times_{S_2} Y_2 \ar[end anchor={[xshift=15pt]}]{rr} \ar{dl} & & Y_2 \ar{dl} \\
X_2 \ar[start anchor={[xshift=-15pt]},end anchor={[xshift=15pt]}]{rr} && S_2 \ar[from=uu,crossing over]
\end{tikzcd}\]
\end{document}