I want to draw a cube within a cube using tikz, so that the inner cube is a an inner corner, like the drawing below. enter image description here I'd like the inner cube to be shaded and for its size to be adjustable, but generally small. In addition, I'd like for space to label all axes, this is a conceptual drawing so no need for tick marks.

  • 2
    what's stopping you ?
    – percusse
    Aug 30 '16 at 15:15

from the solution



\coordinate (O) at (#1);
\coordinate (A) at (0,#2,0);
\coordinate (B) at (0,#2,#3);
\coordinate (C) at (0,0,#3);
\coordinate (D) at (#4,0,0);
\coordinate (E) at (#4,#2,0);
\coordinate (F) at (#4,#2,#3);
\coordinate (G) at (#4,0,#3);

\draw[blue,fill=yellow!30,opacity=#5] (O) -- (C.center) -- (G) -- (D) -- cycle;% Bottom Face
\draw[blue,fill=blue!30,opacity=#5] (O) -- (A) -- (E) -- (D) -- cycle;% Back Face
\draw[blue,fill=red!10,opacity=#5] (O) -- (A) -- (B) -- (C) -- cycle;% Left Face
\draw[blue,fill=red!20,opacity=#5] (D) -- (E) -- (F) -- (G) -- cycle;% Right Face
\draw[blue,fill=red!20,opacity=#5] (C) -- (B) -- (F) -- (G) -- cycle;% Front Face
\draw[blue,fill=red!20,opacity=#5] (A) -- (B) -- (F) -- (E) -- cycle;% Top Face}


\coordinate(O) at (0,0,0);


\draw ($(C) +(0,-0.5)$) -- node[below,sloped]{label 1} ($(O)+(0,-0.5)$);
\draw ($(C) +(0,-0.5)$) -- node[below,sloped]{label 2} ($(G)+(0,-0.5)$);
\draw ($(A) +(0.5,0)$) -- node[sloped,above]{label 3} ($(O)+(0.5,0)$);
%% Following is for debugging purposes so you can see where the points are
%% These are last so that they show up on top
\foreach \xy in {O, A, B, C, D, E, F, G}{
    \node at (\xy) {\xy};

enter image description here


run with xelatex:

\psset{lightsrc=viewpoint,viewpoint=50 60 25 rtp2xyz,Decran=50}


enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.