他们是如何在本文第 219、222、223 等页的方程式中制作出“数学立方体”图像的?
https://annals.math.princeton.edu/wp-content/uploads/annals-v159-n1-p03.pdf
答案1
我首先定义一个crossingover
带有 5 个参数的简单命令:#2-#5 是 2 个段的节点/坐标,#1 是交叉的厚度。
\documentclass[tikz]{standalone}
\def\crossingover[#1](#2,#3,#4,#5){%
\path (intersection of #2--#3 and #4--#5) coordinate (#2#3#4#5);
\draw (#2)--(#3);
\draw[shorten >=#1] (#4)--(#2#3#4#5);
\draw[shorten >=#1] (#5)--(#2#3#4#5);
}%
\begin{document}
\begin{tikzpicture}
\path
(0,0) coordinate (A) node[left]{A}
(2,2) coordinate (B) node[right]{B}
(2,0) coordinate (C) node[right]{C}
(0,2) coordinate (D) node[left]{D};
\crossingover[2mm](A,B,C,D)
\end{tikzpicture}
\end{document}
那么事情就变得简单了。
\documentclass{article}
\usepackage{tikz}
\def\crossingover[#1](#2,#3,#4,#5){
\path (intersection of #2--#3 and #4--#5) coordinate (#2#3#4#5);
\draw (#2)--(#3);
\draw[shorten >=#1] (#4)--(#2#3#4#5);
\draw[shorten >=#1] (#5)--(#2#3#4#5);
}
\def\a{2} % length of a side of the cube
\begin{document}
$$ A_{{\rm id},D}=
\begin{tikzpicture}[baseline=1cm]
\path
(0,0) node (A) {$1$} +(90:\a) node (A') {$0$}
(\a,0) node (B) {$0$} +(90:\a) node (B') {$1$}
(.8,.8) node (D) {$0$} +(90:\a) node (D') {$1$}
++(0:\a) node (C) {} +(90:\a) node (C') {$0$};
\foreach \p/\q in {A/B,A/D,A/A',B/C,A'/D',B'/C',C/C',C'/D'}
\draw (\p)--(\q);
\crossingover[1mm](B,B',C,D)
\crossingover[1mm](A',B',D,D')
% small tranlating the label to the right
\path (C) node[right=-1.5mm,fill=white,inner sep=2pt]{$D/4$};
\end{tikzpicture}
\quad \mbox{or} \quad
A_{{\rm id},D}=
\begin{tikzpicture}[baseline=1cm]
\path
(0,0) node (A) {$1$} +(90:\a) node (A') {$0$}
(\a,0) node (B) {$1$} +(90:\a) node (B') {$1$}
(.8,.8) node (D) {$1$} +(90:\a) node (D') {$1$}
++(0:\a) node (C) {} +(90:\a) node (C') {$1$};
\foreach \p/\q in {A/B,A/D,A/A',B/C,A'/D',B'/C',C/C',C'/D'}
\draw (\p)--(\q);
\crossingover[1mm](B,B',C,D)
\crossingover[1mm](A',B',D,D')
% small tranlating the label to the right
\path (C) node[right=-3mm,fill=white,inner sep=2pt]{$(D+3)/4$};
\end{tikzpicture}
$$
\end{document}
更新我猜楼主想让数学课文穿过立方体的中心。为了做到这一点,我删除了该[baseline]
选项,并加入了
\path (intersection of A--D' and D--A')
+(-.5,0) node[left]{$A_{{\rm id},D}=$};
具有较小边的立方体的新代码a=1.6
:
\documentclass{article}
\usepackage{tikz}
\usepackage{lipsum} %<<< for dummy text only
\def\crossingover[#1](#2,#3,#4,#5){%
\path (intersection of #2--#3 and #4--#5) coordinate (#2#3#4#5);
\draw (#2)--(#3);
\draw[shorten >=#1] (#4)--(#2#3#4#5);
\draw[shorten >=#1] (#5)--(#2#3#4#5);
}%
\def\a{1.6} % length of a side of the cube
\begin{document}
\lipsum[1]
\begin{equation}
\begin{tikzpicture}
\path
(0,0) node (A) {$1$} +(90:\a) node (A') {$0$}
(\a,0) node (B) {$0$} +(90:\a) node (B') {$1$}
(.8,.8) node (D) {$0$} +(90:\a) node (D') {$1$}
++(0:\a) node (C) {} +(90:\a) node (C') {$0$};
\foreach \p/\q in {A/B,A/D,A/A',B/C,A'/D',B'/C',C/C',C'/D'}
\draw (\p)--(\q);
\crossingover[1mm](B,B',C,D)
\crossingover[1mm](A',B',D,D')
% small tranlating the label to the right
\path (C) node[right=-1.5mm,fill=white,inner sep=2pt]{$D/4$};
\path (intersection of A--D' and D--A')
+(-.5,0) node[left]{$A_{{\rm id},D}=$};
\end{tikzpicture}
\begin{tikzpicture}
\path
(0,0) node (A) {$1$} +(90:\a) node (A') {$0$}
(\a,0) node (B) {$1$} +(90:\a) node (B') {$1$}
(.8,.8) node (D) {$1$} +(90:\a) node (D') {$1$}
++(0:\a) node (C) {} +(90:\a) node (C') {$1$};
\foreach \p/\q in {A/B,A/D,A/A',B/C,A'/D',B'/C',C/C',C'/D'}
\draw (\p)--(\q);
\crossingover[1mm](B,B',C,D)
\crossingover[1mm](A',B',D,D')
% small tranlating the label to the right
\path (C) node[right=-3mm,fill=white,inner sep=2pt]{$(D+3)/4$};
\path (intersection of A--D' and D--A')
+(-.5,0) node[left]{or \quad $A_{{\rm id},D}=$};
\end{tikzpicture}
\end{equation}
\lipsum[1]
\end{document}
答案2
tikz-cd
允许您执行此操作,请参阅2.6 三维图手册。crossing over
关键是使边缘看起来位于前景中。
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}
\begin{document}
\[
A_{\mathrm{kl},D}=
\begin{tikzcd}[column sep=0.5em,/tikz/column 2/.style={column sep=1.5em},
row sep=0.5em,/tikz/row 2/.style={row sep=1.5em},
/tikz/nodes={text width={width("1")}},
every arrow/.append style={dash}]
& 1\arrow[rr]\arrow[dd] \arrow[dl] & & 0 \arrow[dd]\arrow[ld]\\
0\arrow[rr,crossing over]\arrow[dd] & & 1 & \\
& 1 \arrow[rr]& &\! D/4 \\
1 \arrow[ur]\arrow[rr]& & 0\arrow[uu,crossing over] \arrow[ur]& \\
\end{tikzcd}\qquad\text{or}\quad
A_{\mathrm{kl},D}=
\begin{tikzcd}[column sep=0.5em,/tikz/column 2/.style={column sep=1.5em},
row sep=0.5em,/tikz/row 2/.style={row sep=1.5em},
/tikz/nodes={text width={width("1")}},
every arrow/.append style={dash}]
& 1\arrow[rr]\arrow[dd] \arrow[dl] & & 0 \arrow[dd]\arrow[ld]\\
0\arrow[rr,crossing over]\arrow[dd] & & 1 & \\
& 1 \arrow[rr]& &\! (D+3)/4 \\
1 \arrow[ur]\arrow[rr]& & 1 \arrow[uu,crossing over] \arrow[ur]& \\
\end{tikzcd}\]
\end{document}
您可能希望以一种样式来存储密钥。
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}
\tikzcdset{3d matrix/.style={column sep=0.75em,
row sep=0.75em,/tikz/row 2/.style={row sep=2em},
/tikz/nodes={outer sep=0pt,inner sep=3pt},
every arrow/.append style={dash}},
extra/.style={execute at end picture={#1}}}
\begin{document}
\[
A_{\mathrm{id},D}=
\begin{tikzcd}[3d matrix,extra={\node[anchor=west,inner sep=1pt]
at (\tikzcdmatrixname-3-4.west){$D/4$};}]
& 1\arrow[rr]\arrow[dd] \arrow[dl] & & 0 \arrow[dd]\arrow[ld]\\
0\arrow[rr,crossing over]\arrow[dd] & & 1 & \\
& 1 \arrow[rr]& & \phantom{0} \\
1 \arrow[ur]\arrow[rr]& & 0\arrow[uu,crossing over] \arrow[ur]& \\
\end{tikzcd}\quad\text{or}\quad
A_{\mathrm{id},D}=
\begin{tikzcd}[3d matrix,extra={\node[anchor=west,inner sep=1pt]
at (\tikzcdmatrixname-3-4.west){$(D+3)/4$};}]
& 1\arrow[rr]\arrow[dd] \arrow[dl] & & 0 \arrow[dd]\arrow[ld]\\
0\arrow[rr,crossing over]\arrow[dd] & & 1 & \\
& 1 \arrow[rr]& &\phantom{0} \\
1 \arrow[ur]\arrow[rr]& & 1 \arrow[uu,crossing over] \arrow[ur]& \\
\end{tikzcd}\]
\end{document}