This question already has an answer here:

enter image description here

I'd like to draw a cube in a cube using TikZ as the above. I know how to draw a 3-dimensional vector space, with a line. But, I don't know how to draw a cube in TikZ. What code should I use for it?

\draw %?

marked as duplicate by Andrew, Romain Picot, Maarten Dhondt, egreg tikz-pgf Apr 11 '16 at 10:34

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • You can highlight code in your post using back-ticks. For code-blocks indent them by four spaces or use the {} on the gui. Btw, some people take exception to questions of the form "Please draw this for me". You will get more help if you post some code showing what you have tried and give a minimal working example. – Andrew Apr 11 '16 at 8:35
  • @Andrew What does "gui" mean? – buzzee Apr 11 '16 at 8:37
  • @buzzee - Graphical User Interface, in this case your LaTeX editor. – Karlo Apr 11 '16 at 8:44
  • @buzzee By the gui I mean the (graphical user) web interface that you used to write your question. One of the editor buttons at the top of the screen looks like {} this is can be used to highlight blocks of code. – Andrew Apr 11 '16 at 8:47
  • Do you need a perspective projection like in your example images (note how no two lines are actually parallel) or would an isometric projection (where all parallel lines in 3D space would also be parallel in the 2D image) be acceptable. The latter is a lot easier to do with TikZ. – wrtlprnft Apr 11 '16 at 9:22

Here is a solution using tikz. The "viewing angle" that tikz uses is a little different to that in the question.

enter image description here

Here is the code:



    \begin{tikzpicture}[inside/.style={fill=cyan!80,draw opacity=0.5,thick},
                        every node/.style={font=\tiny}]
        %% inside frame - this shouldn't be necessary...
        \foreach \x in {-1,0,1} {


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