4

I am trying to draw a box, sliced into rectangles. I followed the code from here Need help creating a 3D cube from a 2D set of nodes in TikZ but latex is too difficult so i dont know how to edit the code from there

\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\foreach \x in{0,...,4}
{   \draw (0,\x ,4) -- (4,\x ,4);
    \draw (\x ,0,4) -- (\x ,4,4);
    \draw (4,\x ,4) -- (4,\x ,0);
    \draw (\x ,4,4) -- (\x ,4,0);
    \draw (4,0,\x ) -- (4,4,\x );
    \draw (0,4,\x ) -- (4,4,\x );
}
\end{tikzpicture}

\end{document}

Below is what Id like (edited from paint)

enter image description here

5

This is a version which is very close to your MWE. There are arguably more elegant ways of doing this with the 3d library and/or tikz-3dplot.

\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\foreach \x in{0,...,4}
{   \draw (0,\x ,4) -- (4,\x ,4);
    \ifnum\x=0
    \draw (\x ,0,4) -- (\x ,4,4);
    \else
    \draw (\x ,0,4) -- (\x ,0.1,4)  (\x ,0.9,4) -- (\x ,1.1,4)
    (\x ,1.9,4) -- (\x ,2.1,4) (\x ,2.9,4) -- (\x ,3.1,4)
    (\x ,3.9,4) -- (\x ,4,4);
    \fi
    \draw (4,\x ,4) -- (4,\x ,0);
    \ifnum\x=0
    \draw (\x ,4,4) -- (\x ,4,0);
    \else
    \draw (\x,4,0) -- (\x,4,0.1)  (\x,4,0.9) -- (\x,4,1.1)
    (\x,4,1.9) -- (\x,4,2.1) (\x,4,2.9) -- (\x,4,3.1)
    (\x,4,3.9) -- (\x,4,4);
    \fi
    \draw (4,0,\x ) -- (4,4,\x );
    \draw (0,4,\x ) -- (4,4,\x );
}
\end{tikzpicture}
\end{document}

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.