5

I am trying to draw the following picture but I have some difficulties. I just started learning LaTeX a few weeks ago. I code the following:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\cubex}{2}
\pgfmathsetmacro{\cubey}{2}
\pgfmathsetmacro{\cubez}{2}
\draw[red] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
\draw[red] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
\draw[red] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;
\end{tikzpicture}
\end{document}

Many thanks.

4

You can start with

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}

\begin{document}
\begin{tikzpicture}[z={(3.85mm, -3.85mm)}]


%\draw (0,0,0) -- (1,0,0) node {x};
%\draw (0,0,0) -- (0,1,0) node {y};
%\draw (0,0,0) -- (0,0,1) node {z};

\pgfmathsetmacro{\cubex}{2}
\pgfmathsetmacro{\cubey}{2}
\pgfmathsetmacro{\cubez}{2}
\foreach \x/\j in {0/red,2/green,3/purple,4/orange,5/brown,7/red} 
\draw[\j] (\x,0,0) -- ++(0,\cubey,0) -- ++(0,0,\cubez) -- ++(0,-\cubey,0) -- cycle;

\foreach \i in {(0,0,0),(0,\cubey,0), (0,0,\cubez), (0,\cubey,\cubez)}
\draw[red] \i -- ++(7,0,0);

\draw[decorate, decoration={brace, raise=5pt}] (2,\cubey,0) -- (5,\cubey,0) node[midway,above=3mm]{A};
\end{tikzpicture}
\end{document}

enter image description here

  • Many thanks Ignasi, I really appraciate your help, I learn a lot from you. – Kim Apr 17 '15 at 15:37

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.