Easy way to generate Rubik's cube diagrams










17














Taking inspiration from Playing around with a Rubik's Cube in TikZ, I want to generate diagrams of Rubik's cubes that look like this



enter image description hereenter image description hereenter image description hereenter image description here



Using a solution from Playing around with a Rubik's Cube in TikZ, I was able to generate this diagram



enter image description here



My question is what is the best way to modify the code so I can quickly generate the diagrams in the above graphic? Something like a command cube....? But even I am not sure how you can specify the colour info in this manner. Use a symbol for each colour? G - green, B - blue etc. So there are 27 square faces in this diagram, so does that mean you need 27 arguments? And if you leave it blank then it will display a gray tile? I would appreciate any advice the best way to code this in LaTeX. My ultimate goal is to make over 100 diagrams like the ones above. So if it was possible to make a really efficient code to generate the diagrams that would be amazing.



MWE



documentclassarticle
usepackagetikz
usepackagetikz-3dplot
usetikzlibrary3d
begindocument
pgfmathsetmacroradius0.1
newcommandfrontcolorred
newcommandsidecolorblue
tdplotsetmaincoords55135
begintikzpicture
clip (-3,-2.5) rectangle (3,2.5);
beginscope[tdplot_main_coords]
filldraw [canvas is yz plane at x=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
filldraw [canvas is xz plane at y=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
filldraw [canvas is yx plane at z=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
foreach X in -1.5,-0.5,0.5
foreach Y in -1.5,-0.5,0.5
draw [thick,canvas is yz plane at x=1.5,shift=(X,Y),fill=sidecolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
draw [thick,canvas is xz plane at y=1.5,shift=(X,Y),fill=frontcolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
draw [thick,canvas is yx plane at z=1.5,shift=(X,Y),fill=yellow] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;


endscope
endtikzpicture
enddocument









share|improve this question




























    17














    Taking inspiration from Playing around with a Rubik's Cube in TikZ, I want to generate diagrams of Rubik's cubes that look like this



    enter image description hereenter image description hereenter image description hereenter image description here



    Using a solution from Playing around with a Rubik's Cube in TikZ, I was able to generate this diagram



    enter image description here



    My question is what is the best way to modify the code so I can quickly generate the diagrams in the above graphic? Something like a command cube....? But even I am not sure how you can specify the colour info in this manner. Use a symbol for each colour? G - green, B - blue etc. So there are 27 square faces in this diagram, so does that mean you need 27 arguments? And if you leave it blank then it will display a gray tile? I would appreciate any advice the best way to code this in LaTeX. My ultimate goal is to make over 100 diagrams like the ones above. So if it was possible to make a really efficient code to generate the diagrams that would be amazing.



    MWE



    documentclassarticle
    usepackagetikz
    usepackagetikz-3dplot
    usetikzlibrary3d
    begindocument
    pgfmathsetmacroradius0.1
    newcommandfrontcolorred
    newcommandsidecolorblue
    tdplotsetmaincoords55135
    begintikzpicture
    clip (-3,-2.5) rectangle (3,2.5);
    beginscope[tdplot_main_coords]
    filldraw [canvas is yz plane at x=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
    filldraw [canvas is xz plane at y=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
    filldraw [canvas is yx plane at z=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
    foreach X in -1.5,-0.5,0.5
    foreach Y in -1.5,-0.5,0.5
    draw [thick,canvas is yz plane at x=1.5,shift=(X,Y),fill=sidecolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
    draw [thick,canvas is xz plane at y=1.5,shift=(X,Y),fill=frontcolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
    draw [thick,canvas is yx plane at z=1.5,shift=(X,Y),fill=yellow] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;


    endscope
    endtikzpicture
    enddocument









    share|improve this question


























      17












      17








      17


      3





      Taking inspiration from Playing around with a Rubik's Cube in TikZ, I want to generate diagrams of Rubik's cubes that look like this



      enter image description hereenter image description hereenter image description hereenter image description here



      Using a solution from Playing around with a Rubik's Cube in TikZ, I was able to generate this diagram



      enter image description here



      My question is what is the best way to modify the code so I can quickly generate the diagrams in the above graphic? Something like a command cube....? But even I am not sure how you can specify the colour info in this manner. Use a symbol for each colour? G - green, B - blue etc. So there are 27 square faces in this diagram, so does that mean you need 27 arguments? And if you leave it blank then it will display a gray tile? I would appreciate any advice the best way to code this in LaTeX. My ultimate goal is to make over 100 diagrams like the ones above. So if it was possible to make a really efficient code to generate the diagrams that would be amazing.



      MWE



      documentclassarticle
      usepackagetikz
      usepackagetikz-3dplot
      usetikzlibrary3d
      begindocument
      pgfmathsetmacroradius0.1
      newcommandfrontcolorred
      newcommandsidecolorblue
      tdplotsetmaincoords55135
      begintikzpicture
      clip (-3,-2.5) rectangle (3,2.5);
      beginscope[tdplot_main_coords]
      filldraw [canvas is yz plane at x=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
      filldraw [canvas is xz plane at y=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
      filldraw [canvas is yx plane at z=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
      foreach X in -1.5,-0.5,0.5
      foreach Y in -1.5,-0.5,0.5
      draw [thick,canvas is yz plane at x=1.5,shift=(X,Y),fill=sidecolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
      draw [thick,canvas is xz plane at y=1.5,shift=(X,Y),fill=frontcolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
      draw [thick,canvas is yx plane at z=1.5,shift=(X,Y),fill=yellow] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;


      endscope
      endtikzpicture
      enddocument









      share|improve this question















      Taking inspiration from Playing around with a Rubik's Cube in TikZ, I want to generate diagrams of Rubik's cubes that look like this



      enter image description hereenter image description hereenter image description hereenter image description here



      Using a solution from Playing around with a Rubik's Cube in TikZ, I was able to generate this diagram



      enter image description here



      My question is what is the best way to modify the code so I can quickly generate the diagrams in the above graphic? Something like a command cube....? But even I am not sure how you can specify the colour info in this manner. Use a symbol for each colour? G - green, B - blue etc. So there are 27 square faces in this diagram, so does that mean you need 27 arguments? And if you leave it blank then it will display a gray tile? I would appreciate any advice the best way to code this in LaTeX. My ultimate goal is to make over 100 diagrams like the ones above. So if it was possible to make a really efficient code to generate the diagrams that would be amazing.



      MWE



      documentclassarticle
      usepackagetikz
      usepackagetikz-3dplot
      usetikzlibrary3d
      begindocument
      pgfmathsetmacroradius0.1
      newcommandfrontcolorred
      newcommandsidecolorblue
      tdplotsetmaincoords55135
      begintikzpicture
      clip (-3,-2.5) rectangle (3,2.5);
      beginscope[tdplot_main_coords]
      filldraw [canvas is yz plane at x=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
      filldraw [canvas is xz plane at y=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
      filldraw [canvas is yx plane at z=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
      foreach X in -1.5,-0.5,0.5
      foreach Y in -1.5,-0.5,0.5
      draw [thick,canvas is yz plane at x=1.5,shift=(X,Y),fill=sidecolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
      draw [thick,canvas is xz plane at y=1.5,shift=(X,Y),fill=frontcolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
      draw [thick,canvas is yx plane at z=1.5,shift=(X,Y),fill=yellow] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;


      endscope
      endtikzpicture
      enddocument






      tikz-pgf






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 10 at 3:30

























      asked Nov 10 at 3:12









      Sam

      1087




      1087




















          2 Answers
          2






          active

          oldest

          votes


















          26














          That's a neat question, and here is a proposal for an answer. The colors are stored in an array called myarray, which determines the colors of the cells. The relation between entry (the index starts at 0) and cell is illustrated by this example



          documentclassarticle
          usepackagetikz
          usepackagetikz-3dplot
          usetikzlibrary3d
          newififshowcellnumber
          showcellnumbertrue
          begindocument
          definecolorRRGB202,65,55
          definecolorGRGB151,216,56
          definecolorBRGB51,72,237
          definecolorWRGB255,255,255
          definecolorXRGB65,65,65

          newcommandTikZRubikFaceLeft[9]defmyarrayL#1,#2,#3,#4,#5,#6,#7,#8,#9
          newcommandTikZRubikFaceRight[9]defmyarrayR#1,#2,#3,#4,#5,#6,#7,#8,#9
          newcommandTikZRubikFaceTop[9]defmyarrayT#1,#2,#3,#4,#5,#6,#7,#8,#9
          newcommandBuildArrayforeach X [count=Y] in myarrayL%
          ifnumY=1%
          xdefmyarray"X"%
          else%
          xdefmyarraymyarray,"X"%
          fi%
          foreach X in myarrayR%
          xdefmyarraymyarray,"X"%
          foreach X in myarrayT%
          xdefmyarraymyarray,"X"%
          xdefmyarraymyarray%

          TikZRubikFaceLeft
          XXX
          XXX
          XXG
          TikZRubikFaceRight
          WXX
          RGG
          XGG
          TikZRubikFaceTop
          XXR
          RRG
          RRX
          BuildArray
          %defmyarray"X","X","B","X","G","X","R","R","X","X","X","X","G","X","B","B","X","X","G","B","R","X","R","B","X","X","X"
          pgfmathsetmacroradius0.1
          tdplotsetmaincoords55135
          begintikzpicture
          clip (-3,-2.5) rectangle (3,2.5);
          beginscope[tdplot_main_coords]
          filldraw [canvas is yz plane at x=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          filldraw [canvas is xz plane at y=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          filldraw [canvas is yx plane at z=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          foreach X [count=XX starting from 0] in -1.5,-0.5,0.5
          foreach Y [count=YY starting from 0] in -1.5,-0.5,0.5
          pgfmathtruncatemacroZXX+3*(2-YY)
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is yz plane at x=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is yz plane at x=1.5,shift=(X+0.5,Y+0.5)] Z;
          fi
          pgfmathtruncatemacroZ2-XX+3*(2-YY)+9
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is xz plane at y=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is xz plane at y=1.5,shift=(X+0.5,Y+0.5),xscale=-1] Z;
          fi
          pgfmathtruncatemacroZ2-YY+3*XX+18
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is yx plane at z=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is yx plane at z=1.5,shift=(X+0.5,Y+0.5),xscale=-1,rotate=-90] Z;
          fi


          endscope
          endtikzpicture

          TikZRubikFaceLeft
          XXX
          XXX
          XGX
          TikZRubikFaceRight
          XXX
          XBX
          WBX
          TikZRubikFaceTop
          XRX
          XWX
          XWG
          BuildArray
          showcellnumberfalse
          begintikzpicture
          clip (-3,-2.5) rectangle (3,2.5);
          beginscope[tdplot_main_coords]
          filldraw [canvas is yz plane at x=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          filldraw [canvas is xz plane at y=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          filldraw [canvas is yx plane at z=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          foreach X [count=XX starting from 0] in -1.5,-0.5,0.5
          foreach Y [count=YY starting from 0] in -1.5,-0.5,0.5
          pgfmathtruncatemacroZXX+3*(2-YY)
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is yz plane at x=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is yz plane at x=1.5,shift=(X+0.5,Y+0.5)] Z;
          fi
          pgfmathtruncatemacroZ2-XX+3*(2-YY)+9
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is xz plane at y=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is xz plane at y=1.5,shift=(X+0.5,Y+0.5),xscale=-1] Z;
          fi
          pgfmathtruncatemacroZ2-YY+3*XX+18
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is yx plane at z=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is yx plane at z=1.5,shift=(X+0.5,Y+0.5),xscale=-1,rotate=-90] Z;
          fi


          endscope
          endtikzpicture
          enddocument


          enter image description here



          As you can see, if you replace showcellnumbertrue by showcellnumberfalse, the numbers are suppressed.



          EDITs: Illustrated the relation between array index and cell (which is almost redundant now) and adjusted the color (big thanks to @manooooh!). I also used now the conventions of the rubik package, which I did not really know before seeing Peter Grill's nice answer. The conventions are still slightly different since I refer to the faces as left, right and top. This is because this thingy can be rotated in some range, but left will always be left in that range. I also added some %, which were added in first in this answer.



          ADDENDUM: Encouraged by @LoopSpace's comment:



          documentclass[tikz,border=3.14mm]standalone
          usepackagetikz-3dplot
          usetikzlibrary3d
          newififshowcellnumber
          showcellnumberfalse
          begindocument
          definecolorRRGB202,65,55
          definecolorGRGB151,216,56
          definecolorBRGB51,72,237
          %definecolorWRGB255,255,255
          definecolorWRGB65,65,65

          defmyarray"W","W","B","W","G","W","R","R","W","W","W","W","G","W","B","B","W","W","G","B","R","W","R","B","W","W","W"
          pgfmathsetmacroradius0.1
          newcommandfrontcolorred
          newcommandsidecolorblue
          foreach X in 95,100,...,175
          tdplotsetmaincoords55X
          begintikzpicture
          clip (-3,-2.5) rectangle (3,2.5);
          beginscope[tdplot_main_coords]
          filldraw [canvas is yz plane at x=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          filldraw [canvas is xz plane at y=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          filldraw [canvas is yx plane at z=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          foreach X [count=XX starting from 0] in -1.5,-0.5,0.5
          foreach Y [count=YY starting from 0] in -1.5,-0.5,0.5
          pgfmathtruncatemacroZXX+3*(2-YY)
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is yz plane at
          x=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc
          (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc
          (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is yz plane at x=1.5,shift=(X+0.5,Y+0.5)] Z;
          fi
          pgfmathtruncatemacroZ2-XX+3*(2-YY)+9
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is xz plane at
          y=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc
          (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc
          (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is xz plane at y=1.5,shift=(X+0.5,Y+0.5),xscale=-1] Z;
          fi
          pgfmathtruncatemacroZ2-YY+3*XX+18
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is yx plane at
          z=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc
          (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc
          (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is yx plane at z=1.5,shift=(X+0.5,Y+0.5),xscale=-1,rotate=-90] Z;
          fi


          endscope
          endtikzpicture
          enddocument


          enter image description here






          share|improve this answer






















          • According to the first image of OP the white cubes should be black.
            – manooooh
            Nov 10 at 4:18







          • 1




            @manooooh You're right, thanks a lot!
            – marmot
            Nov 10 at 4:29










          • Lovely, as always. Can we tweak the cube to add perspective? There's a question here somewhere about it.
            – Loop Space
            Nov 10 at 6:56






          • 1




            @LoopSpace Yes. That is what tdplotsetmaincoords55135 does. And the question is most likely where the answer that the OP and I build on is from.
            – marmot
            Nov 10 at 14:33











          • Thank you @marmot this is really excellent. The package rubik has a really nice format for specifying the colours of the faces and generating the diagram of the cube. I was wondering if it is possible to get that sort of functionality with your TikZ method? The reason why your TikZ method is superior to the package rubik is because here we have full control over the viewing angle (I really need an isometric viewing angle). There seems to be no way to adjust the angle using rubik so your code is much better.
            – Sam
            Nov 10 at 18:08


















          23














          There is also a rubik package designed specifically for this. The MWE below generates the four cube positions shown in the question.



          enter image description here



          Code:



          documentclassarticle
          usepackagetikz%% load tikz BEFORE rubikcube
          usepackagerubikcube
          %usepackagerubikrotation,rubikpatterns,rubiktwocube% Related packages

          begindocument
          noindent
          beginminipage0.4linewidth
          RubikFaceUp
          XXX
          XXX
          XXG
          RubikFaceRight
          WXX
          RGG
          XGG
          RubikFaceFront
          XXR
          RRG
          RRX
          ShowCube7cm0.7DrawRubikCube
          endminipage
          beginminipage0.4linewidth
          RubikFaceUp
          XXX
          XXX
          XGX
          RubikFaceRight
          XXX
          XBX
          WBX
          RubikFaceFront
          XRX
          XOX
          XOG
          ShowCube7cm0.7DrawRubikCube
          endminipage

          parmedskip
          noindent
          beginminipage0.4linewidth
          RubikFaceRight
          XXX
          GBX
          GBX
          RubikFaceFront
          XXX
          XOR
          XOR
          ShowCube7cm0.7DrawRubikCube
          endminipage
          beginminipage0.4linewidth
          RubikFaceUp
          XXX
          GXX
          XXG
          RubikFaceRight
          WXX
          XGG
          XGG
          RubikFaceFront
          XXX
          RRX
          RRX
          ShowCube7cm0.7DrawRubikCubeRU
          endminipage
          enddocument





          share|improve this answer




















          • Thank you this is really interesting, I did not know of this package. I've had a look at the documentation and it seems there is no way to adjust the viewing angle so that it is 'isometric' like in my example? This is quite crucial to my use as the focus is on the edge between the front and right faces. This is for doing F2L diagrams. Don't know if anyone knows a way to adapt this package to making the viewing angle isometric?
            – Sam
            Nov 10 at 18:04











          • @Sam: Try emailing the package authors. Might make sense to add that feature directly to the package.
            – Peter Grill
            Nov 10 at 18:30










          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',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          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%2f459254%2feasy-way-to-generate-rubiks-cube-diagrams%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          26














          That's a neat question, and here is a proposal for an answer. The colors are stored in an array called myarray, which determines the colors of the cells. The relation between entry (the index starts at 0) and cell is illustrated by this example



          documentclassarticle
          usepackagetikz
          usepackagetikz-3dplot
          usetikzlibrary3d
          newififshowcellnumber
          showcellnumbertrue
          begindocument
          definecolorRRGB202,65,55
          definecolorGRGB151,216,56
          definecolorBRGB51,72,237
          definecolorWRGB255,255,255
          definecolorXRGB65,65,65

          newcommandTikZRubikFaceLeft[9]defmyarrayL#1,#2,#3,#4,#5,#6,#7,#8,#9
          newcommandTikZRubikFaceRight[9]defmyarrayR#1,#2,#3,#4,#5,#6,#7,#8,#9
          newcommandTikZRubikFaceTop[9]defmyarrayT#1,#2,#3,#4,#5,#6,#7,#8,#9
          newcommandBuildArrayforeach X [count=Y] in myarrayL%
          ifnumY=1%
          xdefmyarray"X"%
          else%
          xdefmyarraymyarray,"X"%
          fi%
          foreach X in myarrayR%
          xdefmyarraymyarray,"X"%
          foreach X in myarrayT%
          xdefmyarraymyarray,"X"%
          xdefmyarraymyarray%

          TikZRubikFaceLeft
          XXX
          XXX
          XXG
          TikZRubikFaceRight
          WXX
          RGG
          XGG
          TikZRubikFaceTop
          XXR
          RRG
          RRX
          BuildArray
          %defmyarray"X","X","B","X","G","X","R","R","X","X","X","X","G","X","B","B","X","X","G","B","R","X","R","B","X","X","X"
          pgfmathsetmacroradius0.1
          tdplotsetmaincoords55135
          begintikzpicture
          clip (-3,-2.5) rectangle (3,2.5);
          beginscope[tdplot_main_coords]
          filldraw [canvas is yz plane at x=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          filldraw [canvas is xz plane at y=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          filldraw [canvas is yx plane at z=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          foreach X [count=XX starting from 0] in -1.5,-0.5,0.5
          foreach Y [count=YY starting from 0] in -1.5,-0.5,0.5
          pgfmathtruncatemacroZXX+3*(2-YY)
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is yz plane at x=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is yz plane at x=1.5,shift=(X+0.5,Y+0.5)] Z;
          fi
          pgfmathtruncatemacroZ2-XX+3*(2-YY)+9
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is xz plane at y=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is xz plane at y=1.5,shift=(X+0.5,Y+0.5),xscale=-1] Z;
          fi
          pgfmathtruncatemacroZ2-YY+3*XX+18
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is yx plane at z=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is yx plane at z=1.5,shift=(X+0.5,Y+0.5),xscale=-1,rotate=-90] Z;
          fi


          endscope
          endtikzpicture

          TikZRubikFaceLeft
          XXX
          XXX
          XGX
          TikZRubikFaceRight
          XXX
          XBX
          WBX
          TikZRubikFaceTop
          XRX
          XWX
          XWG
          BuildArray
          showcellnumberfalse
          begintikzpicture
          clip (-3,-2.5) rectangle (3,2.5);
          beginscope[tdplot_main_coords]
          filldraw [canvas is yz plane at x=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          filldraw [canvas is xz plane at y=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          filldraw [canvas is yx plane at z=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          foreach X [count=XX starting from 0] in -1.5,-0.5,0.5
          foreach Y [count=YY starting from 0] in -1.5,-0.5,0.5
          pgfmathtruncatemacroZXX+3*(2-YY)
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is yz plane at x=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is yz plane at x=1.5,shift=(X+0.5,Y+0.5)] Z;
          fi
          pgfmathtruncatemacroZ2-XX+3*(2-YY)+9
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is xz plane at y=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is xz plane at y=1.5,shift=(X+0.5,Y+0.5),xscale=-1] Z;
          fi
          pgfmathtruncatemacroZ2-YY+3*XX+18
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is yx plane at z=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is yx plane at z=1.5,shift=(X+0.5,Y+0.5),xscale=-1,rotate=-90] Z;
          fi


          endscope
          endtikzpicture
          enddocument


          enter image description here



          As you can see, if you replace showcellnumbertrue by showcellnumberfalse, the numbers are suppressed.



          EDITs: Illustrated the relation between array index and cell (which is almost redundant now) and adjusted the color (big thanks to @manooooh!). I also used now the conventions of the rubik package, which I did not really know before seeing Peter Grill's nice answer. The conventions are still slightly different since I refer to the faces as left, right and top. This is because this thingy can be rotated in some range, but left will always be left in that range. I also added some %, which were added in first in this answer.



          ADDENDUM: Encouraged by @LoopSpace's comment:



          documentclass[tikz,border=3.14mm]standalone
          usepackagetikz-3dplot
          usetikzlibrary3d
          newififshowcellnumber
          showcellnumberfalse
          begindocument
          definecolorRRGB202,65,55
          definecolorGRGB151,216,56
          definecolorBRGB51,72,237
          %definecolorWRGB255,255,255
          definecolorWRGB65,65,65

          defmyarray"W","W","B","W","G","W","R","R","W","W","W","W","G","W","B","B","W","W","G","B","R","W","R","B","W","W","W"
          pgfmathsetmacroradius0.1
          newcommandfrontcolorred
          newcommandsidecolorblue
          foreach X in 95,100,...,175
          tdplotsetmaincoords55X
          begintikzpicture
          clip (-3,-2.5) rectangle (3,2.5);
          beginscope[tdplot_main_coords]
          filldraw [canvas is yz plane at x=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          filldraw [canvas is xz plane at y=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          filldraw [canvas is yx plane at z=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          foreach X [count=XX starting from 0] in -1.5,-0.5,0.5
          foreach Y [count=YY starting from 0] in -1.5,-0.5,0.5
          pgfmathtruncatemacroZXX+3*(2-YY)
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is yz plane at
          x=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc
          (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc
          (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is yz plane at x=1.5,shift=(X+0.5,Y+0.5)] Z;
          fi
          pgfmathtruncatemacroZ2-XX+3*(2-YY)+9
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is xz plane at
          y=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc
          (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc
          (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is xz plane at y=1.5,shift=(X+0.5,Y+0.5),xscale=-1] Z;
          fi
          pgfmathtruncatemacroZ2-YY+3*XX+18
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is yx plane at
          z=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc
          (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc
          (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is yx plane at z=1.5,shift=(X+0.5,Y+0.5),xscale=-1,rotate=-90] Z;
          fi


          endscope
          endtikzpicture
          enddocument


          enter image description here






          share|improve this answer






















          • According to the first image of OP the white cubes should be black.
            – manooooh
            Nov 10 at 4:18







          • 1




            @manooooh You're right, thanks a lot!
            – marmot
            Nov 10 at 4:29










          • Lovely, as always. Can we tweak the cube to add perspective? There's a question here somewhere about it.
            – Loop Space
            Nov 10 at 6:56






          • 1




            @LoopSpace Yes. That is what tdplotsetmaincoords55135 does. And the question is most likely where the answer that the OP and I build on is from.
            – marmot
            Nov 10 at 14:33











          • Thank you @marmot this is really excellent. The package rubik has a really nice format for specifying the colours of the faces and generating the diagram of the cube. I was wondering if it is possible to get that sort of functionality with your TikZ method? The reason why your TikZ method is superior to the package rubik is because here we have full control over the viewing angle (I really need an isometric viewing angle). There seems to be no way to adjust the angle using rubik so your code is much better.
            – Sam
            Nov 10 at 18:08















          26














          That's a neat question, and here is a proposal for an answer. The colors are stored in an array called myarray, which determines the colors of the cells. The relation between entry (the index starts at 0) and cell is illustrated by this example



          documentclassarticle
          usepackagetikz
          usepackagetikz-3dplot
          usetikzlibrary3d
          newififshowcellnumber
          showcellnumbertrue
          begindocument
          definecolorRRGB202,65,55
          definecolorGRGB151,216,56
          definecolorBRGB51,72,237
          definecolorWRGB255,255,255
          definecolorXRGB65,65,65

          newcommandTikZRubikFaceLeft[9]defmyarrayL#1,#2,#3,#4,#5,#6,#7,#8,#9
          newcommandTikZRubikFaceRight[9]defmyarrayR#1,#2,#3,#4,#5,#6,#7,#8,#9
          newcommandTikZRubikFaceTop[9]defmyarrayT#1,#2,#3,#4,#5,#6,#7,#8,#9
          newcommandBuildArrayforeach X [count=Y] in myarrayL%
          ifnumY=1%
          xdefmyarray"X"%
          else%
          xdefmyarraymyarray,"X"%
          fi%
          foreach X in myarrayR%
          xdefmyarraymyarray,"X"%
          foreach X in myarrayT%
          xdefmyarraymyarray,"X"%
          xdefmyarraymyarray%

          TikZRubikFaceLeft
          XXX
          XXX
          XXG
          TikZRubikFaceRight
          WXX
          RGG
          XGG
          TikZRubikFaceTop
          XXR
          RRG
          RRX
          BuildArray
          %defmyarray"X","X","B","X","G","X","R","R","X","X","X","X","G","X","B","B","X","X","G","B","R","X","R","B","X","X","X"
          pgfmathsetmacroradius0.1
          tdplotsetmaincoords55135
          begintikzpicture
          clip (-3,-2.5) rectangle (3,2.5);
          beginscope[tdplot_main_coords]
          filldraw [canvas is yz plane at x=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          filldraw [canvas is xz plane at y=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          filldraw [canvas is yx plane at z=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          foreach X [count=XX starting from 0] in -1.5,-0.5,0.5
          foreach Y [count=YY starting from 0] in -1.5,-0.5,0.5
          pgfmathtruncatemacroZXX+3*(2-YY)
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is yz plane at x=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is yz plane at x=1.5,shift=(X+0.5,Y+0.5)] Z;
          fi
          pgfmathtruncatemacroZ2-XX+3*(2-YY)+9
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is xz plane at y=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is xz plane at y=1.5,shift=(X+0.5,Y+0.5),xscale=-1] Z;
          fi
          pgfmathtruncatemacroZ2-YY+3*XX+18
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is yx plane at z=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is yx plane at z=1.5,shift=(X+0.5,Y+0.5),xscale=-1,rotate=-90] Z;
          fi


          endscope
          endtikzpicture

          TikZRubikFaceLeft
          XXX
          XXX
          XGX
          TikZRubikFaceRight
          XXX
          XBX
          WBX
          TikZRubikFaceTop
          XRX
          XWX
          XWG
          BuildArray
          showcellnumberfalse
          begintikzpicture
          clip (-3,-2.5) rectangle (3,2.5);
          beginscope[tdplot_main_coords]
          filldraw [canvas is yz plane at x=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          filldraw [canvas is xz plane at y=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          filldraw [canvas is yx plane at z=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          foreach X [count=XX starting from 0] in -1.5,-0.5,0.5
          foreach Y [count=YY starting from 0] in -1.5,-0.5,0.5
          pgfmathtruncatemacroZXX+3*(2-YY)
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is yz plane at x=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is yz plane at x=1.5,shift=(X+0.5,Y+0.5)] Z;
          fi
          pgfmathtruncatemacroZ2-XX+3*(2-YY)+9
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is xz plane at y=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is xz plane at y=1.5,shift=(X+0.5,Y+0.5),xscale=-1] Z;
          fi
          pgfmathtruncatemacroZ2-YY+3*XX+18
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is yx plane at z=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is yx plane at z=1.5,shift=(X+0.5,Y+0.5),xscale=-1,rotate=-90] Z;
          fi


          endscope
          endtikzpicture
          enddocument


          enter image description here



          As you can see, if you replace showcellnumbertrue by showcellnumberfalse, the numbers are suppressed.



          EDITs: Illustrated the relation between array index and cell (which is almost redundant now) and adjusted the color (big thanks to @manooooh!). I also used now the conventions of the rubik package, which I did not really know before seeing Peter Grill's nice answer. The conventions are still slightly different since I refer to the faces as left, right and top. This is because this thingy can be rotated in some range, but left will always be left in that range. I also added some %, which were added in first in this answer.



          ADDENDUM: Encouraged by @LoopSpace's comment:



          documentclass[tikz,border=3.14mm]standalone
          usepackagetikz-3dplot
          usetikzlibrary3d
          newififshowcellnumber
          showcellnumberfalse
          begindocument
          definecolorRRGB202,65,55
          definecolorGRGB151,216,56
          definecolorBRGB51,72,237
          %definecolorWRGB255,255,255
          definecolorWRGB65,65,65

          defmyarray"W","W","B","W","G","W","R","R","W","W","W","W","G","W","B","B","W","W","G","B","R","W","R","B","W","W","W"
          pgfmathsetmacroradius0.1
          newcommandfrontcolorred
          newcommandsidecolorblue
          foreach X in 95,100,...,175
          tdplotsetmaincoords55X
          begintikzpicture
          clip (-3,-2.5) rectangle (3,2.5);
          beginscope[tdplot_main_coords]
          filldraw [canvas is yz plane at x=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          filldraw [canvas is xz plane at y=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          filldraw [canvas is yx plane at z=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          foreach X [count=XX starting from 0] in -1.5,-0.5,0.5
          foreach Y [count=YY starting from 0] in -1.5,-0.5,0.5
          pgfmathtruncatemacroZXX+3*(2-YY)
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is yz plane at
          x=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc
          (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc
          (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is yz plane at x=1.5,shift=(X+0.5,Y+0.5)] Z;
          fi
          pgfmathtruncatemacroZ2-XX+3*(2-YY)+9
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is xz plane at
          y=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc
          (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc
          (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is xz plane at y=1.5,shift=(X+0.5,Y+0.5),xscale=-1] Z;
          fi
          pgfmathtruncatemacroZ2-YY+3*XX+18
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is yx plane at
          z=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc
          (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc
          (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is yx plane at z=1.5,shift=(X+0.5,Y+0.5),xscale=-1,rotate=-90] Z;
          fi


          endscope
          endtikzpicture
          enddocument


          enter image description here






          share|improve this answer






















          • According to the first image of OP the white cubes should be black.
            – manooooh
            Nov 10 at 4:18







          • 1




            @manooooh You're right, thanks a lot!
            – marmot
            Nov 10 at 4:29










          • Lovely, as always. Can we tweak the cube to add perspective? There's a question here somewhere about it.
            – Loop Space
            Nov 10 at 6:56






          • 1




            @LoopSpace Yes. That is what tdplotsetmaincoords55135 does. And the question is most likely where the answer that the OP and I build on is from.
            – marmot
            Nov 10 at 14:33











          • Thank you @marmot this is really excellent. The package rubik has a really nice format for specifying the colours of the faces and generating the diagram of the cube. I was wondering if it is possible to get that sort of functionality with your TikZ method? The reason why your TikZ method is superior to the package rubik is because here we have full control over the viewing angle (I really need an isometric viewing angle). There seems to be no way to adjust the angle using rubik so your code is much better.
            – Sam
            Nov 10 at 18:08













          26












          26








          26






          That's a neat question, and here is a proposal for an answer. The colors are stored in an array called myarray, which determines the colors of the cells. The relation between entry (the index starts at 0) and cell is illustrated by this example



          documentclassarticle
          usepackagetikz
          usepackagetikz-3dplot
          usetikzlibrary3d
          newififshowcellnumber
          showcellnumbertrue
          begindocument
          definecolorRRGB202,65,55
          definecolorGRGB151,216,56
          definecolorBRGB51,72,237
          definecolorWRGB255,255,255
          definecolorXRGB65,65,65

          newcommandTikZRubikFaceLeft[9]defmyarrayL#1,#2,#3,#4,#5,#6,#7,#8,#9
          newcommandTikZRubikFaceRight[9]defmyarrayR#1,#2,#3,#4,#5,#6,#7,#8,#9
          newcommandTikZRubikFaceTop[9]defmyarrayT#1,#2,#3,#4,#5,#6,#7,#8,#9
          newcommandBuildArrayforeach X [count=Y] in myarrayL%
          ifnumY=1%
          xdefmyarray"X"%
          else%
          xdefmyarraymyarray,"X"%
          fi%
          foreach X in myarrayR%
          xdefmyarraymyarray,"X"%
          foreach X in myarrayT%
          xdefmyarraymyarray,"X"%
          xdefmyarraymyarray%

          TikZRubikFaceLeft
          XXX
          XXX
          XXG
          TikZRubikFaceRight
          WXX
          RGG
          XGG
          TikZRubikFaceTop
          XXR
          RRG
          RRX
          BuildArray
          %defmyarray"X","X","B","X","G","X","R","R","X","X","X","X","G","X","B","B","X","X","G","B","R","X","R","B","X","X","X"
          pgfmathsetmacroradius0.1
          tdplotsetmaincoords55135
          begintikzpicture
          clip (-3,-2.5) rectangle (3,2.5);
          beginscope[tdplot_main_coords]
          filldraw [canvas is yz plane at x=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          filldraw [canvas is xz plane at y=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          filldraw [canvas is yx plane at z=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          foreach X [count=XX starting from 0] in -1.5,-0.5,0.5
          foreach Y [count=YY starting from 0] in -1.5,-0.5,0.5
          pgfmathtruncatemacroZXX+3*(2-YY)
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is yz plane at x=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is yz plane at x=1.5,shift=(X+0.5,Y+0.5)] Z;
          fi
          pgfmathtruncatemacroZ2-XX+3*(2-YY)+9
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is xz plane at y=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is xz plane at y=1.5,shift=(X+0.5,Y+0.5),xscale=-1] Z;
          fi
          pgfmathtruncatemacroZ2-YY+3*XX+18
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is yx plane at z=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is yx plane at z=1.5,shift=(X+0.5,Y+0.5),xscale=-1,rotate=-90] Z;
          fi


          endscope
          endtikzpicture

          TikZRubikFaceLeft
          XXX
          XXX
          XGX
          TikZRubikFaceRight
          XXX
          XBX
          WBX
          TikZRubikFaceTop
          XRX
          XWX
          XWG
          BuildArray
          showcellnumberfalse
          begintikzpicture
          clip (-3,-2.5) rectangle (3,2.5);
          beginscope[tdplot_main_coords]
          filldraw [canvas is yz plane at x=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          filldraw [canvas is xz plane at y=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          filldraw [canvas is yx plane at z=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          foreach X [count=XX starting from 0] in -1.5,-0.5,0.5
          foreach Y [count=YY starting from 0] in -1.5,-0.5,0.5
          pgfmathtruncatemacroZXX+3*(2-YY)
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is yz plane at x=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is yz plane at x=1.5,shift=(X+0.5,Y+0.5)] Z;
          fi
          pgfmathtruncatemacroZ2-XX+3*(2-YY)+9
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is xz plane at y=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is xz plane at y=1.5,shift=(X+0.5,Y+0.5),xscale=-1] Z;
          fi
          pgfmathtruncatemacroZ2-YY+3*XX+18
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is yx plane at z=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is yx plane at z=1.5,shift=(X+0.5,Y+0.5),xscale=-1,rotate=-90] Z;
          fi


          endscope
          endtikzpicture
          enddocument


          enter image description here



          As you can see, if you replace showcellnumbertrue by showcellnumberfalse, the numbers are suppressed.



          EDITs: Illustrated the relation between array index and cell (which is almost redundant now) and adjusted the color (big thanks to @manooooh!). I also used now the conventions of the rubik package, which I did not really know before seeing Peter Grill's nice answer. The conventions are still slightly different since I refer to the faces as left, right and top. This is because this thingy can be rotated in some range, but left will always be left in that range. I also added some %, which were added in first in this answer.



          ADDENDUM: Encouraged by @LoopSpace's comment:



          documentclass[tikz,border=3.14mm]standalone
          usepackagetikz-3dplot
          usetikzlibrary3d
          newififshowcellnumber
          showcellnumberfalse
          begindocument
          definecolorRRGB202,65,55
          definecolorGRGB151,216,56
          definecolorBRGB51,72,237
          %definecolorWRGB255,255,255
          definecolorWRGB65,65,65

          defmyarray"W","W","B","W","G","W","R","R","W","W","W","W","G","W","B","B","W","W","G","B","R","W","R","B","W","W","W"
          pgfmathsetmacroradius0.1
          newcommandfrontcolorred
          newcommandsidecolorblue
          foreach X in 95,100,...,175
          tdplotsetmaincoords55X
          begintikzpicture
          clip (-3,-2.5) rectangle (3,2.5);
          beginscope[tdplot_main_coords]
          filldraw [canvas is yz plane at x=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          filldraw [canvas is xz plane at y=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          filldraw [canvas is yx plane at z=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          foreach X [count=XX starting from 0] in -1.5,-0.5,0.5
          foreach Y [count=YY starting from 0] in -1.5,-0.5,0.5
          pgfmathtruncatemacroZXX+3*(2-YY)
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is yz plane at
          x=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc
          (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc
          (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is yz plane at x=1.5,shift=(X+0.5,Y+0.5)] Z;
          fi
          pgfmathtruncatemacroZ2-XX+3*(2-YY)+9
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is xz plane at
          y=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc
          (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc
          (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is xz plane at y=1.5,shift=(X+0.5,Y+0.5),xscale=-1] Z;
          fi
          pgfmathtruncatemacroZ2-YY+3*XX+18
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is yx plane at
          z=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc
          (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc
          (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is yx plane at z=1.5,shift=(X+0.5,Y+0.5),xscale=-1,rotate=-90] Z;
          fi


          endscope
          endtikzpicture
          enddocument


          enter image description here






          share|improve this answer














          That's a neat question, and here is a proposal for an answer. The colors are stored in an array called myarray, which determines the colors of the cells. The relation between entry (the index starts at 0) and cell is illustrated by this example



          documentclassarticle
          usepackagetikz
          usepackagetikz-3dplot
          usetikzlibrary3d
          newififshowcellnumber
          showcellnumbertrue
          begindocument
          definecolorRRGB202,65,55
          definecolorGRGB151,216,56
          definecolorBRGB51,72,237
          definecolorWRGB255,255,255
          definecolorXRGB65,65,65

          newcommandTikZRubikFaceLeft[9]defmyarrayL#1,#2,#3,#4,#5,#6,#7,#8,#9
          newcommandTikZRubikFaceRight[9]defmyarrayR#1,#2,#3,#4,#5,#6,#7,#8,#9
          newcommandTikZRubikFaceTop[9]defmyarrayT#1,#2,#3,#4,#5,#6,#7,#8,#9
          newcommandBuildArrayforeach X [count=Y] in myarrayL%
          ifnumY=1%
          xdefmyarray"X"%
          else%
          xdefmyarraymyarray,"X"%
          fi%
          foreach X in myarrayR%
          xdefmyarraymyarray,"X"%
          foreach X in myarrayT%
          xdefmyarraymyarray,"X"%
          xdefmyarraymyarray%

          TikZRubikFaceLeft
          XXX
          XXX
          XXG
          TikZRubikFaceRight
          WXX
          RGG
          XGG
          TikZRubikFaceTop
          XXR
          RRG
          RRX
          BuildArray
          %defmyarray"X","X","B","X","G","X","R","R","X","X","X","X","G","X","B","B","X","X","G","B","R","X","R","B","X","X","X"
          pgfmathsetmacroradius0.1
          tdplotsetmaincoords55135
          begintikzpicture
          clip (-3,-2.5) rectangle (3,2.5);
          beginscope[tdplot_main_coords]
          filldraw [canvas is yz plane at x=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          filldraw [canvas is xz plane at y=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          filldraw [canvas is yx plane at z=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          foreach X [count=XX starting from 0] in -1.5,-0.5,0.5
          foreach Y [count=YY starting from 0] in -1.5,-0.5,0.5
          pgfmathtruncatemacroZXX+3*(2-YY)
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is yz plane at x=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is yz plane at x=1.5,shift=(X+0.5,Y+0.5)] Z;
          fi
          pgfmathtruncatemacroZ2-XX+3*(2-YY)+9
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is xz plane at y=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is xz plane at y=1.5,shift=(X+0.5,Y+0.5),xscale=-1] Z;
          fi
          pgfmathtruncatemacroZ2-YY+3*XX+18
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is yx plane at z=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is yx plane at z=1.5,shift=(X+0.5,Y+0.5),xscale=-1,rotate=-90] Z;
          fi


          endscope
          endtikzpicture

          TikZRubikFaceLeft
          XXX
          XXX
          XGX
          TikZRubikFaceRight
          XXX
          XBX
          WBX
          TikZRubikFaceTop
          XRX
          XWX
          XWG
          BuildArray
          showcellnumberfalse
          begintikzpicture
          clip (-3,-2.5) rectangle (3,2.5);
          beginscope[tdplot_main_coords]
          filldraw [canvas is yz plane at x=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          filldraw [canvas is xz plane at y=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          filldraw [canvas is yx plane at z=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          foreach X [count=XX starting from 0] in -1.5,-0.5,0.5
          foreach Y [count=YY starting from 0] in -1.5,-0.5,0.5
          pgfmathtruncatemacroZXX+3*(2-YY)
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is yz plane at x=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is yz plane at x=1.5,shift=(X+0.5,Y+0.5)] Z;
          fi
          pgfmathtruncatemacroZ2-XX+3*(2-YY)+9
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is xz plane at y=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is xz plane at y=1.5,shift=(X+0.5,Y+0.5),xscale=-1] Z;
          fi
          pgfmathtruncatemacroZ2-YY+3*XX+18
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is yx plane at z=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is yx plane at z=1.5,shift=(X+0.5,Y+0.5),xscale=-1,rotate=-90] Z;
          fi


          endscope
          endtikzpicture
          enddocument


          enter image description here



          As you can see, if you replace showcellnumbertrue by showcellnumberfalse, the numbers are suppressed.



          EDITs: Illustrated the relation between array index and cell (which is almost redundant now) and adjusted the color (big thanks to @manooooh!). I also used now the conventions of the rubik package, which I did not really know before seeing Peter Grill's nice answer. The conventions are still slightly different since I refer to the faces as left, right and top. This is because this thingy can be rotated in some range, but left will always be left in that range. I also added some %, which were added in first in this answer.



          ADDENDUM: Encouraged by @LoopSpace's comment:



          documentclass[tikz,border=3.14mm]standalone
          usepackagetikz-3dplot
          usetikzlibrary3d
          newififshowcellnumber
          showcellnumberfalse
          begindocument
          definecolorRRGB202,65,55
          definecolorGRGB151,216,56
          definecolorBRGB51,72,237
          %definecolorWRGB255,255,255
          definecolorWRGB65,65,65

          defmyarray"W","W","B","W","G","W","R","R","W","W","W","W","G","W","B","B","W","W","G","B","R","W","R","B","W","W","W"
          pgfmathsetmacroradius0.1
          newcommandfrontcolorred
          newcommandsidecolorblue
          foreach X in 95,100,...,175
          tdplotsetmaincoords55X
          begintikzpicture
          clip (-3,-2.5) rectangle (3,2.5);
          beginscope[tdplot_main_coords]
          filldraw [canvas is yz plane at x=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          filldraw [canvas is xz plane at y=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          filldraw [canvas is yx plane at z=1.5] (-1.5,-1.5) rectangle (1.5,1.5);
          foreach X [count=XX starting from 0] in -1.5,-0.5,0.5
          foreach Y [count=YY starting from 0] in -1.5,-0.5,0.5
          pgfmathtruncatemacroZXX+3*(2-YY)
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is yz plane at
          x=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc
          (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc
          (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is yz plane at x=1.5,shift=(X+0.5,Y+0.5)] Z;
          fi
          pgfmathtruncatemacroZ2-XX+3*(2-YY)+9
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is xz plane at
          y=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc
          (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc
          (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is xz plane at y=1.5,shift=(X+0.5,Y+0.5),xscale=-1] Z;
          fi
          pgfmathtruncatemacroZ2-YY+3*XX+18
          pgfmathsetmacromycolormyarray[Z]
          draw [thick,canvas is yx plane at
          z=1.5,shift=(X,Y),fill=mycolor] (0.5,0) -- (1-radius,0) arc
          (-90:0:radius) -- (1,1-radius) arc (0:90:radius) -- (radius,1) arc
          (90:180:radius) -- (0,radius) arc (180:270:radius) -- cycle;
          ifshowcellnumber
          node[canvas is yx plane at z=1.5,shift=(X+0.5,Y+0.5),xscale=-1,rotate=-90] Z;
          fi


          endscope
          endtikzpicture
          enddocument


          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 11 at 2:36

























          answered Nov 10 at 3:36









          marmot

          87k499185




          87k499185











          • According to the first image of OP the white cubes should be black.
            – manooooh
            Nov 10 at 4:18







          • 1




            @manooooh You're right, thanks a lot!
            – marmot
            Nov 10 at 4:29










          • Lovely, as always. Can we tweak the cube to add perspective? There's a question here somewhere about it.
            – Loop Space
            Nov 10 at 6:56






          • 1




            @LoopSpace Yes. That is what tdplotsetmaincoords55135 does. And the question is most likely where the answer that the OP and I build on is from.
            – marmot
            Nov 10 at 14:33











          • Thank you @marmot this is really excellent. The package rubik has a really nice format for specifying the colours of the faces and generating the diagram of the cube. I was wondering if it is possible to get that sort of functionality with your TikZ method? The reason why your TikZ method is superior to the package rubik is because here we have full control over the viewing angle (I really need an isometric viewing angle). There seems to be no way to adjust the angle using rubik so your code is much better.
            – Sam
            Nov 10 at 18:08
















          • According to the first image of OP the white cubes should be black.
            – manooooh
            Nov 10 at 4:18







          • 1




            @manooooh You're right, thanks a lot!
            – marmot
            Nov 10 at 4:29










          • Lovely, as always. Can we tweak the cube to add perspective? There's a question here somewhere about it.
            – Loop Space
            Nov 10 at 6:56






          • 1




            @LoopSpace Yes. That is what tdplotsetmaincoords55135 does. And the question is most likely where the answer that the OP and I build on is from.
            – marmot
            Nov 10 at 14:33











          • Thank you @marmot this is really excellent. The package rubik has a really nice format for specifying the colours of the faces and generating the diagram of the cube. I was wondering if it is possible to get that sort of functionality with your TikZ method? The reason why your TikZ method is superior to the package rubik is because here we have full control over the viewing angle (I really need an isometric viewing angle). There seems to be no way to adjust the angle using rubik so your code is much better.
            – Sam
            Nov 10 at 18:08















          According to the first image of OP the white cubes should be black.
          – manooooh
          Nov 10 at 4:18





          According to the first image of OP the white cubes should be black.
          – manooooh
          Nov 10 at 4:18





          1




          1




          @manooooh You're right, thanks a lot!
          – marmot
          Nov 10 at 4:29




          @manooooh You're right, thanks a lot!
          – marmot
          Nov 10 at 4:29












          Lovely, as always. Can we tweak the cube to add perspective? There's a question here somewhere about it.
          – Loop Space
          Nov 10 at 6:56




          Lovely, as always. Can we tweak the cube to add perspective? There's a question here somewhere about it.
          – Loop Space
          Nov 10 at 6:56




          1




          1




          @LoopSpace Yes. That is what tdplotsetmaincoords55135 does. And the question is most likely where the answer that the OP and I build on is from.
          – marmot
          Nov 10 at 14:33





          @LoopSpace Yes. That is what tdplotsetmaincoords55135 does. And the question is most likely where the answer that the OP and I build on is from.
          – marmot
          Nov 10 at 14:33













          Thank you @marmot this is really excellent. The package rubik has a really nice format for specifying the colours of the faces and generating the diagram of the cube. I was wondering if it is possible to get that sort of functionality with your TikZ method? The reason why your TikZ method is superior to the package rubik is because here we have full control over the viewing angle (I really need an isometric viewing angle). There seems to be no way to adjust the angle using rubik so your code is much better.
          – Sam
          Nov 10 at 18:08




          Thank you @marmot this is really excellent. The package rubik has a really nice format for specifying the colours of the faces and generating the diagram of the cube. I was wondering if it is possible to get that sort of functionality with your TikZ method? The reason why your TikZ method is superior to the package rubik is because here we have full control over the viewing angle (I really need an isometric viewing angle). There seems to be no way to adjust the angle using rubik so your code is much better.
          – Sam
          Nov 10 at 18:08











          23














          There is also a rubik package designed specifically for this. The MWE below generates the four cube positions shown in the question.



          enter image description here



          Code:



          documentclassarticle
          usepackagetikz%% load tikz BEFORE rubikcube
          usepackagerubikcube
          %usepackagerubikrotation,rubikpatterns,rubiktwocube% Related packages

          begindocument
          noindent
          beginminipage0.4linewidth
          RubikFaceUp
          XXX
          XXX
          XXG
          RubikFaceRight
          WXX
          RGG
          XGG
          RubikFaceFront
          XXR
          RRG
          RRX
          ShowCube7cm0.7DrawRubikCube
          endminipage
          beginminipage0.4linewidth
          RubikFaceUp
          XXX
          XXX
          XGX
          RubikFaceRight
          XXX
          XBX
          WBX
          RubikFaceFront
          XRX
          XOX
          XOG
          ShowCube7cm0.7DrawRubikCube
          endminipage

          parmedskip
          noindent
          beginminipage0.4linewidth
          RubikFaceRight
          XXX
          GBX
          GBX
          RubikFaceFront
          XXX
          XOR
          XOR
          ShowCube7cm0.7DrawRubikCube
          endminipage
          beginminipage0.4linewidth
          RubikFaceUp
          XXX
          GXX
          XXG
          RubikFaceRight
          WXX
          XGG
          XGG
          RubikFaceFront
          XXX
          RRX
          RRX
          ShowCube7cm0.7DrawRubikCubeRU
          endminipage
          enddocument





          share|improve this answer




















          • Thank you this is really interesting, I did not know of this package. I've had a look at the documentation and it seems there is no way to adjust the viewing angle so that it is 'isometric' like in my example? This is quite crucial to my use as the focus is on the edge between the front and right faces. This is for doing F2L diagrams. Don't know if anyone knows a way to adapt this package to making the viewing angle isometric?
            – Sam
            Nov 10 at 18:04











          • @Sam: Try emailing the package authors. Might make sense to add that feature directly to the package.
            – Peter Grill
            Nov 10 at 18:30















          23














          There is also a rubik package designed specifically for this. The MWE below generates the four cube positions shown in the question.



          enter image description here



          Code:



          documentclassarticle
          usepackagetikz%% load tikz BEFORE rubikcube
          usepackagerubikcube
          %usepackagerubikrotation,rubikpatterns,rubiktwocube% Related packages

          begindocument
          noindent
          beginminipage0.4linewidth
          RubikFaceUp
          XXX
          XXX
          XXG
          RubikFaceRight
          WXX
          RGG
          XGG
          RubikFaceFront
          XXR
          RRG
          RRX
          ShowCube7cm0.7DrawRubikCube
          endminipage
          beginminipage0.4linewidth
          RubikFaceUp
          XXX
          XXX
          XGX
          RubikFaceRight
          XXX
          XBX
          WBX
          RubikFaceFront
          XRX
          XOX
          XOG
          ShowCube7cm0.7DrawRubikCube
          endminipage

          parmedskip
          noindent
          beginminipage0.4linewidth
          RubikFaceRight
          XXX
          GBX
          GBX
          RubikFaceFront
          XXX
          XOR
          XOR
          ShowCube7cm0.7DrawRubikCube
          endminipage
          beginminipage0.4linewidth
          RubikFaceUp
          XXX
          GXX
          XXG
          RubikFaceRight
          WXX
          XGG
          XGG
          RubikFaceFront
          XXX
          RRX
          RRX
          ShowCube7cm0.7DrawRubikCubeRU
          endminipage
          enddocument





          share|improve this answer




















          • Thank you this is really interesting, I did not know of this package. I've had a look at the documentation and it seems there is no way to adjust the viewing angle so that it is 'isometric' like in my example? This is quite crucial to my use as the focus is on the edge between the front and right faces. This is for doing F2L diagrams. Don't know if anyone knows a way to adapt this package to making the viewing angle isometric?
            – Sam
            Nov 10 at 18:04











          • @Sam: Try emailing the package authors. Might make sense to add that feature directly to the package.
            – Peter Grill
            Nov 10 at 18:30













          23












          23








          23






          There is also a rubik package designed specifically for this. The MWE below generates the four cube positions shown in the question.



          enter image description here



          Code:



          documentclassarticle
          usepackagetikz%% load tikz BEFORE rubikcube
          usepackagerubikcube
          %usepackagerubikrotation,rubikpatterns,rubiktwocube% Related packages

          begindocument
          noindent
          beginminipage0.4linewidth
          RubikFaceUp
          XXX
          XXX
          XXG
          RubikFaceRight
          WXX
          RGG
          XGG
          RubikFaceFront
          XXR
          RRG
          RRX
          ShowCube7cm0.7DrawRubikCube
          endminipage
          beginminipage0.4linewidth
          RubikFaceUp
          XXX
          XXX
          XGX
          RubikFaceRight
          XXX
          XBX
          WBX
          RubikFaceFront
          XRX
          XOX
          XOG
          ShowCube7cm0.7DrawRubikCube
          endminipage

          parmedskip
          noindent
          beginminipage0.4linewidth
          RubikFaceRight
          XXX
          GBX
          GBX
          RubikFaceFront
          XXX
          XOR
          XOR
          ShowCube7cm0.7DrawRubikCube
          endminipage
          beginminipage0.4linewidth
          RubikFaceUp
          XXX
          GXX
          XXG
          RubikFaceRight
          WXX
          XGG
          XGG
          RubikFaceFront
          XXX
          RRX
          RRX
          ShowCube7cm0.7DrawRubikCubeRU
          endminipage
          enddocument





          share|improve this answer












          There is also a rubik package designed specifically for this. The MWE below generates the four cube positions shown in the question.



          enter image description here



          Code:



          documentclassarticle
          usepackagetikz%% load tikz BEFORE rubikcube
          usepackagerubikcube
          %usepackagerubikrotation,rubikpatterns,rubiktwocube% Related packages

          begindocument
          noindent
          beginminipage0.4linewidth
          RubikFaceUp
          XXX
          XXX
          XXG
          RubikFaceRight
          WXX
          RGG
          XGG
          RubikFaceFront
          XXR
          RRG
          RRX
          ShowCube7cm0.7DrawRubikCube
          endminipage
          beginminipage0.4linewidth
          RubikFaceUp
          XXX
          XXX
          XGX
          RubikFaceRight
          XXX
          XBX
          WBX
          RubikFaceFront
          XRX
          XOX
          XOG
          ShowCube7cm0.7DrawRubikCube
          endminipage

          parmedskip
          noindent
          beginminipage0.4linewidth
          RubikFaceRight
          XXX
          GBX
          GBX
          RubikFaceFront
          XXX
          XOR
          XOR
          ShowCube7cm0.7DrawRubikCube
          endminipage
          beginminipage0.4linewidth
          RubikFaceUp
          XXX
          GXX
          XXG
          RubikFaceRight
          WXX
          XGG
          XGG
          RubikFaceFront
          XXX
          RRX
          RRX
          ShowCube7cm0.7DrawRubikCubeRU
          endminipage
          enddocument






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 10 at 7:59









          Peter Grill

          164k25435746




          164k25435746











          • Thank you this is really interesting, I did not know of this package. I've had a look at the documentation and it seems there is no way to adjust the viewing angle so that it is 'isometric' like in my example? This is quite crucial to my use as the focus is on the edge between the front and right faces. This is for doing F2L diagrams. Don't know if anyone knows a way to adapt this package to making the viewing angle isometric?
            – Sam
            Nov 10 at 18:04











          • @Sam: Try emailing the package authors. Might make sense to add that feature directly to the package.
            – Peter Grill
            Nov 10 at 18:30
















          • Thank you this is really interesting, I did not know of this package. I've had a look at the documentation and it seems there is no way to adjust the viewing angle so that it is 'isometric' like in my example? This is quite crucial to my use as the focus is on the edge between the front and right faces. This is for doing F2L diagrams. Don't know if anyone knows a way to adapt this package to making the viewing angle isometric?
            – Sam
            Nov 10 at 18:04











          • @Sam: Try emailing the package authors. Might make sense to add that feature directly to the package.
            – Peter Grill
            Nov 10 at 18:30















          Thank you this is really interesting, I did not know of this package. I've had a look at the documentation and it seems there is no way to adjust the viewing angle so that it is 'isometric' like in my example? This is quite crucial to my use as the focus is on the edge between the front and right faces. This is for doing F2L diagrams. Don't know if anyone knows a way to adapt this package to making the viewing angle isometric?
          – Sam
          Nov 10 at 18:04





          Thank you this is really interesting, I did not know of this package. I've had a look at the documentation and it seems there is no way to adjust the viewing angle so that it is 'isometric' like in my example? This is quite crucial to my use as the focus is on the edge between the front and right faces. This is for doing F2L diagrams. Don't know if anyone knows a way to adapt this package to making the viewing angle isometric?
          – Sam
          Nov 10 at 18:04













          @Sam: Try emailing the package authors. Might make sense to add that feature directly to the package.
          – Peter Grill
          Nov 10 at 18:30




          @Sam: Try emailing the package authors. Might make sense to add that feature directly to the package.
          – Peter Grill
          Nov 10 at 18:30

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f459254%2feasy-way-to-generate-rubiks-cube-diagrams%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

          Crossroads (UK TV series)

          ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế