\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{cubedraw}
\usepackage{booktabs}
\usepackage{hyperref}

\title{The \textsf{cubedraw} package\\[2pt]
  \large Pictures of the Rubik's Cube in which every piece is
  drawn whole}
\author{Luís M. S. Russo}
\date{Version 1.0, 2026/12/03}

\newcommand{\pkg}[1]{\textsf{#1}}
\newcommand{\cs}[1]{\texttt{\textbackslash#1}}

\begin{document}
\maketitle

\section{Introduction}

The \pkg{cubedraw} package draws a whole Rubik's Cube, all 54
stickers, in one flat picture, with one command:
\begin{center}
  \cubelabelstrue\cubearrowstrue
  \cubeflat[scale=2.5]{%
    WWGWWGWWGOOOOOOOOOGGYGGYGGYRRRRRRRRRWBBWBBWBBYYBYYBYYB}
\end{center}
This is the cube after the move R.  The four side faces L, F, R
and B are drawn as in the usual net, except that the last column
of B comes first, next to L.  The U face is a strip above them:
its centre is the long sticker, and its other eight stickers lie
in a row, each next to the side faces it touches.  The D face is
drawn the same way below.

So the stickers of every piece touch, with one outline around the
piece, and each type of piece has its own shape: a corner is a
square made of its three stickers, an edge is a superellipse cut
into its two colours, and a centre is a squircle.  Since a move
never changes the type of a piece, the shapes never move: a move
only recolours them.  The usual net, by contrast, splits 7 of the
12 edges and some corners between faces far apart.

Other packages on CTAN, such as \pkg{rubikcube},
\pkg{rubikrotation} and \pkg{rubiktwocube}, draw the cube as a
net, in perspective or from the top, and process sequences of
moves.  \pkg{cubedraw} only draws: it takes the colours of the 54
stickers, as computed by hand or by any other program.

The package was written for a survey of human methods for the
Rubik's Cube, whose programs generate its pictures; the source
of the coordinates, a Python script, is in
\begin{center}
  \url{https://github.com/LuisRusso-INESC-ID/Rubicks-Count}.
\end{center}

\section{Usage}

Load the package with \verb|\usepackage{cubedraw}|; it loads
\pkg{tikz}.  Then
\begin{center}
  \verb|\cubeflat[|\textit{options}\verb|]{|\textit{state}\verb|}|
\end{center}
draws the cube.  The \textit{state} is 54 letters, one for each
sticker, and the \textit{options} are passed to the
\verb|tikzpicture|; the most useful is \verb|scale|, which
multiplies the default size.  Use \verb|baseline| to align the
picture with text.

\subsection{The state}

Each letter is the colour of a sticker:
\begin{center}
  \begin{tabular}{cl@{\qquad}cl@{\qquad}cl}
    \toprule
    W & white  & O & orange & G & green \\
    R & red    & B & blue   & Y & yellow \\
    X & grey   &   &        &   &        \\
    \bottomrule
  \end{tabular}
\end{center}
Grey marks stickers that do not matter, for instance in the goal
of a step of a solving method.

The stickers come face by face in the order U, L, F, R, B, D, and
each face row by row, as it is drawn in the usual net below: U
with its back edge at the top, the side faces upright, and D with
its front edge at the top.
\begin{center}
  \begin{tikzpicture}[x=7mm,y=7mm,font=\scriptsize]
    \foreach \f/\x/\y [count=\k from 0] in
        {U/3/9,L/0/6,F/3/6,R/6/6,B/9/6,D/3/3} {
      \foreach \i in {0,...,8} {
        \pgfmathtruncatemacro\n{9*\k+\i+1}
        \pgfmathtruncatemacro\c{mod(\i,3)}
        \pgfmathtruncatemacro\r{div(\i,3)}
        \draw (\x+\c,\y-\r) rectangle +(1,-1);
        \ifnum\i=4
          \node[align=center,inner sep=0pt]
            at (\x+\c+.5,\y-\r-.5) {\textbf{\f}\\\n};
        \else
          \node at (\x+\c+.5,\y-\r-.5) {\n};
        \fi
      }
    }
  \end{tikzpicture}
\end{center}
So the solved cube, with white on U and green on F, is
\begin{center}
\small\verb|WWWWWWWWWOOOOOOOOOGGGGGGGGGRRRRRRRRRBBBBBBBBBYYYYYYYYY|
\end{center}
Within each face this is the order of Kociemba's facelet
strings, which list the faces as U, R, F, D, L, B.  Spaces and
line breaks in the state are ignored, so it can be written one
face at a time:
\begin{verbatim}
\cubeflat{WWWWWWWWW OOOOOOOOO GGGGGGGGG
          RRRRRRRRR BBBBBBBBB YYYYYYYYY}
\end{verbatim}

\subsection{Labels and arrows}

Two switches add the names of the faces on their centres and
dashed arrows that show the clockwise turn of each face:
\begin{verbatim}
\cubelabelstrue  \cubelabelsfalse
\cubearrowstrue  \cubearrowsfalse
\end{verbatim}
Both are off by default; set them inside a group to affect only
one picture, as in the introduction.

\subsection{Colours}

The colours are the \pkg{xcolor} colours \verb|cubeW|,
\verb|cubeO|, \verb|cubeG|, \verb|cubeR|, \verb|cubeB|,
\verb|cubeY| and \verb|cubeX|.  Redefine them to change the
scheme, for instance
\begin{verbatim}
\definecolor{cubeX}{gray}{0.85}
\end{verbatim}

\section{Examples}

The goals of the four steps of the CFOP method, with the cube
solved with yellow at the bottom: the cross, the first two layers,
the last layer oriented (only the white stickers matter) and the
solved cube.
\begin{center}
  \cubeflat[scale=1.1]{%
    XXXXWXXXXXXXXOXXOXXXXXGXXGXXXXXRXXRXXXXXBXXBXXYXYYYXYX}\hfill
  \cubeflat[scale=1.1]{%
    XXXXWXXXXXXXOOOOOOXXXGGGGGGXXXRRRRRRXXXBBBBBBYYYYYYYYY}\hfill
  \cubeflat[scale=1.1]{%
    WWWWWWWWWXXXOOOOOOXXXGGGGGGXXXRRRRRRXXXBBBBBBYYYYYYYYY}\hfill
  \cubeflat[scale=1.1]{%
    WWWWWWWWWOOOOOOOOOGGGGGGGGGRRRRRRRRRBBBBBBBBBYYYYYYYYY}
\end{center}
The first of them is
\begin{verbatim}
\cubeflat[scale=1.1]{%
  XXXXWXXXXXXXXOXXOXXXXXGXXGXXXXXRXXRXXXXXBXXBXXYXYYYXYX}
\end{verbatim}
A small picture can also sit in a line of text, like
\cubeflat[scale=.5,baseline=-3pt]{%
  WWGWWGWWGOOOOOOOOOGGYGGYGGYRRRRRRRRRWBBWBBWBBYYBYYBYYB}, with
the options \verb|scale=.5,baseline=-3pt|.

\section{Licence}

Copyright (c) 2026 Luís M. S. Russo.  The package is released
under the MIT License; see the file \texttt{LICENSE}.

The package was written with the help of Claude, an AI
assistant, and reviewed by the author.

\end{document}
