# Drawing a Cube Using Tikz

I'm trying to simply use the example of a cube provided here

    \begin{tikzpicture}[
back line/.style={densely dotted},
cross line/.style={preaction={draw=white, -,
line width=6pt}}]
\matrix (m) [matrix of math nodes,
row sep=3em, column sep=3em,
text height=1.5ex,
text depth=0.25ex]{
& f^\ast E_V & & E_V \\
f^\ast E & & E \\
& U & & V \\
M & & N \\
};
\path[->]
(m-1-2) edge (m-1-4)
edge (m-2-1)
edge [back line] (m-3-2)
(m-1-4) edge (m-3-4)
edge (m-2-3)
(m-2-1) edge [cross line] (m-2-3)
edge (m-4-1)
(m-3-2) edge [back line] (m-3-4)
edge [back line] (m-4-1)
(m-4-1) edge (m-4-3)
(m-3-4) edge (m-4-3)
(m-2-3) edge [cross line] (m-4-3);
\end{tikzpicture}


(originally from here).

I can't seem to get it to work for whatever reason. It's throwing an error about

l.382 text depth=0.25ex]


For some reason. Anybody have any insight into this? Thanks.

-
Are you including \usetikzlibrary{matrix}? Instead of code snippets, it is always best to compose a MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. –  Peter Grill Nov 18 '11 at 17:34
Can you add your packages etc. to the code above? If you make it a minimal working example then we'll have better information to help you. –  qubyte Nov 18 '11 at 17:35
Oops. Weird when that happens. –  qubyte Nov 18 '11 at 17:36

Simply including \usepackage{tikz} and \usetikzlibrary{matrix} in the preamble, and wrapping your code within the LaTeX wrapper seems to work fine:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
% The tikz code goes here
\end{document}


\documentclass{article}
\begin{document}
\begin{tikzpicture}[
back line/.style={densely dotted},
cross line/.style={preaction={draw=white, -,
line width=6pt}}]
\matrix (m) [matrix of math nodes,
row sep=3em, column sep=3em,
text height=1.5ex,
text depth=0.25ex]{
& f^\ast E_V & & E_V \\
f^\ast E & & E \\
& U & & V \\
M & & N \\
};
\path[->]
(m-1-2) edge (m-1-4)
edge (m-2-1)
edge [back line] (m-3-2)
(m-1-4) edge (m-3-4)
edge (m-2-3)
(m-2-1) edge [cross line] (m-2-3)
edge (m-4-1)
(m-3-2) edge [back line] (m-3-4)
edge [back line] (m-4-1)
(m-4-1) edge (m-4-3)
(m-3-4) edge (m-4-3)
(m-2-3) edge [cross line] (m-4-3);
\end{tikzpicture}
\end{document}

-
That \usetikzlibrary{matrix} was the kicker. Thanks Peter. –  Vincent Russo Nov 18 '11 at 17:44
That's why I try to insist that people not post code snippets and include the \documentclass and all the packages they are using as then it would have been more obvious. –  Peter Grill Nov 18 '11 at 17:52