How to draw a sliced cube shape?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
3
down vote

favorite












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
usepackagetikz

begindocument
begintikzpicture
foreach x in0,...,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 );

endtikzpicture

enddocument


Below is what Id like (edited from paint)



enter image description here







share|improve this question
























    up vote
    3
    down vote

    favorite












    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
    usepackagetikz

    begindocument
    begintikzpicture
    foreach x in0,...,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 );

    endtikzpicture

    enddocument


    Below is what Id like (edited from paint)



    enter image description here







    share|improve this question






















      up vote
      3
      down vote

      favorite









      up vote
      3
      down vote

      favorite











      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
      usepackagetikz

      begindocument
      begintikzpicture
      foreach x in0,...,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 );

      endtikzpicture

      enddocument


      Below is what Id like (edited from paint)



      enter image description here







      share|improve this question












      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
      usepackagetikz

      begindocument
      begintikzpicture
      foreach x in0,...,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 );

      endtikzpicture

      enddocument


      Below is what Id like (edited from paint)



      enter image description here









      share|improve this question











      share|improve this question




      share|improve this question










      asked Aug 27 at 5:08









      kong

      4871517




      4871517




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          5
          down vote



          accepted










          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
          usepackagetikz

          begindocument
          begintikzpicture
          foreach x in0,...,4
          draw (0,x ,4) -- (4,x ,4);
          ifnumx=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);
          ifnumx=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 );

          endtikzpicture
          enddocument


          enter image description here






          share|improve this answer




















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "85"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f447906%2fhow-to-draw-a-sliced-cube-shape%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            5
            down vote



            accepted










            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
            usepackagetikz

            begindocument
            begintikzpicture
            foreach x in0,...,4
            draw (0,x ,4) -- (4,x ,4);
            ifnumx=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);
            ifnumx=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 );

            endtikzpicture
            enddocument


            enter image description here






            share|improve this answer
























              up vote
              5
              down vote



              accepted










              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
              usepackagetikz

              begindocument
              begintikzpicture
              foreach x in0,...,4
              draw (0,x ,4) -- (4,x ,4);
              ifnumx=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);
              ifnumx=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 );

              endtikzpicture
              enddocument


              enter image description here






              share|improve this answer






















                up vote
                5
                down vote



                accepted







                up vote
                5
                down vote



                accepted






                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
                usepackagetikz

                begindocument
                begintikzpicture
                foreach x in0,...,4
                draw (0,x ,4) -- (4,x ,4);
                ifnumx=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);
                ifnumx=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 );

                endtikzpicture
                enddocument


                enter image description here






                share|improve this answer












                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
                usepackagetikz

                begindocument
                begintikzpicture
                foreach x in0,...,4
                draw (0,x ,4) -- (4,x ,4);
                ifnumx=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);
                ifnumx=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 );

                endtikzpicture
                enddocument


                enter image description here







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Aug 27 at 5:22









                marmot

                55.8k461121




                55.8k461121



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f447906%2fhow-to-draw-a-sliced-cube-shape%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    What does second last employer means? [closed]

                    List of Gilmore Girls characters

                    Confectionery