# How to draw a commutative cube diagram with colored faces with a small upper-right corner x-y-z axis

I am looking for a package where I can draw this vertix-and-edge-labelled commutative cube diagram with colored (and labelled) bottom (grey) and top (striped grey) faces with a small upper-right corner x-y-z axis, something like this (forgive me for such a poor image):

Here are the packages I've tried so far:

• Paul Taylor's diagrams package. I've always used it to draw my simpler commutative diagrams. However, it seems that this package does not allow much flexibility or advanced features. In particular, I can't color faces with them and I can't make the arrows from the upper-right corner x-y-z axis smaller, as in my picture.

• tikz-cd. I had some progress with this package (see my old attempt bellow and Sebastiano's excellent answer). However, as Sebastiano remarked in the comments to his answer, it seems that this package can't draw small arrows in the upper-right corner x-y-z axis either.

Question:

Is there a package I can draw this diagram (with small upper-right corner x-y-z arrows just like in the above picture?)

Maybe this can be done using tikz? But I am totally unfamiliar with it. :(

Any help would be highly appreciated.

My TikZ-cd attempt: So I found this thread tikz-cd: Shade faces of commutative cube which was very helpful. However, So far I can only color the top and bottom faces of the commutative cube without the x-y-z axis using tikz-cd, as in

using the code:

\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}


But I can't seem to find a way to

1. Color the top face with a stripped grey.
2. Draw the small right-corner x-y-z axis.

Is there a way to complete this diagram?

A "pure" tikz-cd attempt:

\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}


1. Color the top face with a stripped grey.

To do this I've loaded the patterns library and used

\fill[pattern=north east lines,pattern color=grey1,opacity=0.3]

2. Draw the small right-corner x-y-z axis.

To do this I've used an empty node {} and added start anchor=center to the arrows as in

\arrow[r,-latex,start anchor=center]


If you want to hide the unseen part of the arrow between B and D you can shift down the arrow with something like

\arrow[dd,swap,start anchor={[yshift=-25pt]},"h'"]


to obtain

## EDIT

If you want the arrows in the cube, simply delete delete the arrows=dash option in the tikzcd environment (or replace it with arrows=-latex for example):

\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}


• +1 my compliments for your fine work. I also live in an island :))) Commented May 13, 2017 at 8:45
• @Sebastiano Grazie mille :-) Commented May 13, 2017 at 8:46
• @Sebastiano Which island? Sicilia? Commented May 13, 2017 at 8:56
• Yes. I've been working for two years in your beautiful island and I still have a lot of friends' Gallura. Commented May 13, 2017 at 8:58
• @StudentType not with this type of approach. It could probably be done with some TikZ code, but I'm not a TikZ expert... Commented May 13, 2017 at 9:55

For the record, it is possible to shorten the x-y-z axis using this approach:

Building on karlkoeller's answer, we just need to use shorten >= ...pt as in

\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}

• I was aware of the shorten option, but the result is quite ugly... Commented May 14, 2017 at 7:37