我正在寻找一个包,在其中我可以绘制这个顶点和边标记的交换立方体图,该立方体图具有彩色(和标记)的底部(灰色)和顶部(条纹灰色)面,并且右上角有一个小的 xyz 轴,类似于这样(请原谅我的图像如此糟糕):
以下是迄今为止我尝试过的软件包:
Paul Taylor 的
diagrams
软件包。我一直用它来绘制更简单的交换图。但是,这个软件包似乎没有提供太多灵活性或高级功能。特别是,我无法用它们给面着色,也无法像我的图片那样使右上角 xyz 轴的箭头变小。tikz-cd
。我在这个包上取得了一些进展(请参阅下面我以前的尝试和 Sebastiano 的出色回答)。但是,正如 Sebastiano 在他的回答的评论中所说,这个包似乎也无法在右上角的 xyz 轴上绘制小箭头。
问题:
有没有一个包可以让我绘制这个图表(带有小的右上角 xyz 箭头,就像上图一样?)
也许可以使用tikz
? 来完成此操作?但我对此完全不熟悉。:(
任何帮助都将非常感激。
我的 TikZ-cd 尝试:所以我找到了这个线程tikz-cd:交换立方体的阴影面这很有帮助。但是,到目前为止,我只能使用 为没有 xyz 轴的交换立方体的顶面和底面着色tikz-cd
,如下所示
使用代码:
\documentclass{article}
\usepackage{tikz-cd}
\definecolor{grey1}{RGB}{71,71,71}
\definecolor{grey2}{RGB}{100,100,100}
\begin{document}
\begin{tikzcd}[execute at end picture={
\foreach \Valor/\Nombre in
{
tikz@f@1-1-1/a,tikz@f@1-2-2/b,tikz@f@1-1-3/c,tikz@f@1-2-4/d,
tikz@f@1-3-1/e,tikz@f@1-4-2/f,tikz@f@1-3-3/g,tikz@f@1-4-4/h
}
{
\coordinate (\Nombre) at (\Valor);
}
\fill[grey1,opacity=0.3]
(b) -- (a) -- (c) -- (d) -- cycle;
\fill[grey2,opacity=0.3]
(f) -- (e) -- (g) -- (h) -- cycle;
}
]
A \arrow[rr,"f"] \arrow[dr,swap,"a"] \arrow[dd,swap,"h"] &&
B \arrow[dd,swap,"h'" near start] \arrow[dr,"b"] \\
& A' \arrow[rr,crossing over,"f'" near start] &&
B' \arrow[dd,"k'"] \\
C \arrow[rr,"g" near end] \arrow[dr,swap,"c"] && D \arrow[dr,swap,"d"] \\
& C' \arrow[rr,"g'"] \arrow[uu,<-,crossing over,"k" near end]&& D'
\end{tikzcd}
\end{document}
但我似乎找不到办法
- 用条纹灰色为顶面着色。
- 绘制右角小 xyz 轴。
有没有办法完成这个图表?
答案1
一次“纯粹”的tikz-cd
尝试:
\documentclass{article}
\usepackage{tikz-cd}
\usetikzlibrary{patterns}
\definecolor{grey1}{RGB}{71,71,71}
\definecolor{grey2}{RGB}{100,100,100}
\begin{document}
\begin{tikzcd}[arrows=dash,execute at end picture={
\foreach \Valor/\Nombre in
{
tikz@f@1-1-4/a,tikz@f@1-2-5/b,tikz@f@1-1-6/c,tikz@f@1-2-7/d,
tikz@f@1-3-4/e,tikz@f@1-4-5/f,tikz@f@1-3-6/g,tikz@f@1-4-7/h%
}
{
\coordinate (\Nombre) at (\Valor);
}
\fill[pattern=north east lines,pattern color=grey1,opacity=0.3]
(b) -- (a) -- (c) -- (d) -- cycle;
\fill[grey2,opacity=0.3]
(f) -- (e) -- (g) -- (h) -- cycle;
}
]
{} \arrow[r,-latex,start anchor=center] \arrow[dr,-latex,start anchor=center] \arrow[d,-latex,start anchor=center] & x &&
A \arrow[rr,"f"] \arrow[dr,swap,"a"] \arrow[dd,swap,"h"] &&
B \arrow[dd,swap,"h'" near start] \arrow[dr,"b"] \\
y & z &&
& A' \arrow[rr,crossing over,"f'" near start] &&
B' \arrow[dd,"k'"] \\
&&& C \arrow[rr,"g" near end] \arrow[dr,swap,"c"] && D \arrow[dr,swap,"d"] \\
&&& & C' \arrow[rr,"g'"] \arrow[uu,crossing over,"k" near end]&& D'
\end{tikzcd}
\end{document}
用条纹灰色为顶面着色。
为此,我加载了
patterns
库并使用\fill[pattern=north east lines,pattern color=grey1,opacity=0.3]
绘制右角小 xyz 轴。
为此,我使用了一个空节点
{}
并添加了start anchor=center
箭头,如下所示\arrow[r,-latex,start anchor=center]
如果你想隐藏箭头之间不可见的部分B
,D
你可以使用类似
\arrow[dd,swap,start anchor={[yshift=-25pt]},"h'"]
获得
编辑
如果您想要立方体中的箭头,只需删除环境arrows=dash
中的选项tikzcd
(或将其替换arrows=-latex
为):
\documentclass{article}
\usepackage{tikz-cd}
\usetikzlibrary{patterns}
\definecolor{grey1}{RGB}{71,71,71}
\definecolor{grey2}{RGB}{100,100,100}
\begin{document}
\begin{tikzcd}[execute at end picture={
\foreach \Valor/\Nombre in
{
tikz@f@1-1-4/a,tikz@f@1-2-5/b,tikz@f@1-1-6/c,tikz@f@1-2-7/d,
tikz@f@1-3-4/e,tikz@f@1-4-5/f,tikz@f@1-3-6/g,tikz@f@1-4-7/h%
}
{
\coordinate (\Nombre) at (\Valor);
}
\fill[pattern=north east lines,pattern color=grey1,opacity=0.3]
(b) -- (a) -- (c) -- (d) -- cycle;
\fill[grey2,opacity=0.3]
(f) -- (e) -- (g) -- (h) -- cycle;
}
]
{} \arrow[r,-latex,start anchor=center] \arrow[dr,-latex,start anchor=center] \arrow[d,-latex,start anchor=center] & x &&
A \arrow[rr,"f"] \arrow[dr,swap,"a"] \arrow[dd,swap,"h"] &&
B \arrow[dd,swap,"h'" near start] \arrow[dr,"b"] \\
y & z &&
& A' \arrow[rr,crossing over,"f'" near start] &&
B' \arrow[dd,"k'"] \\
&&& C \arrow[rr,"g" near end] \arrow[dr,swap,"c"] && D \arrow[dr,swap,"d"] \\
&&& & C' \arrow[rr,"g'"] \arrow[uu,<-,crossing over,"k" near end]&& D'
\end{tikzcd}
\end{document}
答案2
作为记录,有可能的使用这种方法缩短 xyz 轴:
shorten >= ...pt
基于karlkoeller 的回答,我们只需要使用
\documentclass{article}
\usepackage{tikz-cd}
\usetikzlibrary{patterns}
\definecolor{grey1}{RGB}{71,71,71}
\definecolor{grey2}{RGB}{100,100,100}
\begin{document}
\begin{tikzcd}[execute at end picture={
\foreach \Valor/\Nombre in
{
tikz@f@1-1-4/a,tikz@f@1-2-5/b,tikz@f@1-1-6/c,tikz@f@1-2-7/d,
tikz@f@1-3-4/e,tikz@f@1-4-5/f,tikz@f@1-3-6/g,tikz@f@1-4-7/h%
}
{
\coordinate (\Nombre) at (\Valor);
}
\fill[pattern=north east lines,pattern color=grey1,opacity=0.3]
(b) -- (a) -- (c) -- (d) -- cycle;
\fill[grey2,opacity=0.3]
(f) -- (e) -- (g) -- (h) -- cycle;
}
]
{} \arrow[r,shorten >= 10pt,-latex,start anchor=center] \arrow[dr,shorten >= 20pt,-latex,start anchor=center] \arrow[d,shorten >= 12pt,-latex,start anchor=center] & x &&
A \arrow[rr,"f"] \arrow[dr,swap,"a"] \arrow[dd,swap,"h"] &&
B \arrow[dd,swap,"h'" near start] \arrow[dr,"b"] \\
y & z
&&
& A' \arrow[rr,crossing over,"f'" near start] &&
B' \arrow[dd,"k'"] \\
&&& C \arrow[rr,"g" near end] \arrow[dr,swap,"c"] && D \arrow[dr,swap,"d"] \\
&&& & C' \arrow[rr,"g'"] \arrow[uu,<-,crossing over,"k" near end]&& D'
\end{tikzcd}
\end{document}