summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/rubik/rubikexamples.tex
blob: 053efe2e17ef06a43f18613ee8b6a7dcf5da3342 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
%%
%% rubikexamples.tex 
%% March 03, 2017
%% Requires  rubik bundle v4.0 and also the tikz package
%% Part of the Rubik bundle (www.ctan.org/pkg/rubik)
%% authors: RWD Nickalls & A Syropoulos
%%--------NOTE-------------------------------------------
%% USAGE:   (pdf)latex  --shell-escape   rubikexamples.tex
%% run three times to get all labels and fig nos correct
%%-------------------------------------------------------
\documentclass[a4paper]{article}
%------rubik----------
\usepackage{tikz}   %% load tikz BEFORE rubikcube
\usepackage{rubikcube}
\usepackage{rubikrotation} 
\usepackage{rubikpatterns} 
%------LUA-----------
% LuaTeX is  a Unicode engine (as is XeTeX)
\usepackage{ifluatex}
\ifluatex
  \usepackage{fontspec}
\fi
%--------------------
\usepackage{url}
\usepackage{ifpdf}
\usepackage{lmodern}
%---------------------
\ifpdf
  \usepackage[verbose]{microtype}
  \usepackage{cmap}
  \usepackage[pdfencoding=auto]{hyperref}

  \hypersetup{%
     pdftitle={rubikexamples.pdf},
     pdfsubject={Rubik cube, Rubik bundle},
     pdfkeywords={Rubik cube LaTeX}
     }
\fi
%%-------------------


%-------------
\pagestyle{myheadings}
\markright{\texttt{rubikexamples.pdf} \ \ 
(Rubik bundle v4.0,  March 03, 2017) \hspace{0.5cm}\texttt{www.ctan.org/pkg/rubik}}
%-----------
%% brace and bracket 
\newcommand{\Rubikbracket}[1]{$\left(\mbox{#1}\right)$}
\newcommand{\Rubikbrace}[1]{$\left\{\mbox{#1}\right\}$}
\newcommand{\cubenumber}[1]{\strut\raisebox{1cm}{#1}}
\newcommand{\leftface}{\textsc{left}\ face}
\newcommand{\rightface}{\textsc{right}\ face}
\newcommand{\upface}{\textsc{up}\ face}
\newcommand{\downface}{\textsc{down}\ face}
\newcommand{\frontface}{\textsc{front}\ face}
\newcommand{\backface}{\textsc{back}\ face}
%---------------------------------
%% increase text height and width  
\addtolength{\oddsidemargin}{-1.5cm}
\addtolength{\textwidth}{3cm}
\addtolength{\textheight}{1cm}
%----------------------
\begin{document}

\ifpdf\pdfbookmark[1]{Title}{Title}\fi
\title{Rubik examples\\ 
\smallskip\normalsize\texttt{www.ctan.org/tex-archives/macros/latex/contrib/rubik/rubikexamples.pdf}
\,\footnote{This file is part of the Rubik bundle. To generate this file, 
use the following command: \newline \texttt{\$ pdflatex --shell-escape  rubikexamples.tex}}}
\author{RWD Nickalls\,\footnote{email: \textsf{dick@nickalls.org}}%
  \ \ \& A Syropoulos\,\footnote{email: \textsf{asyropoulos@yahoo.com}}}
\date{03 March 2017 (v4.0)}
\maketitle


%%------------------
\section{Preliminaries}


These  examples  were generated using  the \TeX\ 
Rubik bundle\,\footnote{\url{http://www.ctan.org/pkg/rubik}} v4.0. They assume some  
familiarity with the three complementary packages \textsc{rubikcube}, 
\textsc{rubikrotation} and \textsc{rubikpatterns}. For~documentation see the files:

\begin{quote}
\begin{verbatim}
rubikcube.pdf
rubikrotation.pdf
rubikpatterns.pdf
rubikpatternsLIST.pdf
\end{verbatim}
\end{quote}


This file requires the following packages: \texttt{tikz, rubikcube, rubikrotation,
rubikpatterns}; note that the \texttt{tikz} package must be loaded \textit{before} 
the \texttt{rubikcube} package.

This file needs to be run using  the \verb!--shell-escape! command-line option; 
for example:
\begin{quote}
\begin{verbatim}
pdflatex  --shell-escape  rubikexample.tex
\end{verbatim}
\end{quote}
This is because nearly all the examples  make use of the  \verb!\RubikRotation! 
command, which  calls the Perl script  \texttt{rubikrotation.pl}.  
If you do forget to use the command-line switch, the file will still run, but 
all the cubes will remain in the initial unprocessed configuration. 


\subsection{Environments}

When using the Rubik bundle one sometimes needs to be mindful of the various 
\LaTeX\ environments in which Rubik commands are placed (e.g.,~the figure, 
minipage and TikZ picture environments), since these environments restrict 
the actions of commands they contain to the particular environment. 
The \verb!\ShowCube! command is also relevant here, since it is a 
minipage-wrapper for the TikZ picture environment. Only Rubik  \verb!\Draw..! 
commands actually need to be inside a TikZ picture environment.

This issue arises because the Rubik bundle allows you to create figures 
showing different stages  during a sequence of rotations. Consequently 
the effects of  commands executed inside an environment (especially 
commands which determine the colour-state or rotations), may not  be 
apparent to subsequent commands outside that particular environment. 
See Example~3  for an illustration of how to handle environments.

\pagebreak

%%------------------
\section{Examples}

\subsection{Sixspot}
\typeout{---Example (sixspot)}

In Figure~\ref{fig:cubeincube} we show  the so-called ``sixspot'' configuration,
 generated from a solved cube using the rotation sequence 
\rr{U}, \rr{Dp}, \rr{R}, \rr{Lp}, \rr{F}, \rr{Bp}, \rr{U}, \rr{Dp}.

%%--------FIGURE 1 -----------
\begin{figure}[hbt]
\centering
\RubikCubeSolved
\RubikRotation{\sixspot}
\ShowCube{7cm}{0.7}{\DrawRubikCubeSF}
\caption{\label{fig:cubeincube}The `sixspot' configuration.}
\end{figure}
%----------------

{\noindent}Creating a macro to hold  a rotation sequence greatly facilitates 
their use, as follows:
\begin{quote}
\begin{verbatim}
\newcommand{\sixspot}{[sixspot],U,Dp,R,Lp,F,Bp,U,Dp}
\end{verbatim}
\end{quote}
We can now process this sequence  using its macro name as an argument for the 
\verb!\RubikRotation! command. The code used for the above Figure  uses the 
\verb!\ShowCube{}{}{}! command for which \verb!#1! is the minipage width, \verb!#2! 
is the tikzpicture scale factor (0--1), and \verb!#3!  can include  \textsc{rubikcube}
package  \verb!\Draw..! commands,  and any commands which are valid for use in a 
TikZ \texttt{tikzpicture} environment. The code for the above figure is as follows:
\begin{quote}
\begin{verbatim}
\begin{figure}[hbt]
   \centering
   \RubikCubeSolved
   \RubikRotation{\sixspot}
   \ShowCube{7cm}{0.7}{\DrawRubikCubeSF}
\caption{...}
\end{figure}
\end{verbatim}
\end{quote}

Note that the sixspot sequence is a so-called `order~3' sequence, which means that 
running the `sixspot' sequence 3 times returns the cube to its original `solved' 
state. The~command for processing it three times is  \verb!\RubikRotation[3]{\sixspot}!.

Note that the semi-flat form of the cube here is generated by the
 \verb!\DrawRubikCubeSF! command, where the terminal SF denotes the Semi-Flat form.



\subsubsection{Log-file extract}

Users may find it instructive to inspect the the log-file and follow the dynamic 
interaction between \LaTeX\  and the Perl script. 
This is easy to follow, since output by \texttt{rubikrotation.sty} is prefixed 
by 3 dashes (\verb!---!), while output by the Perl script is prefixed by 
3 dots (\verb!...!). Search for the keyword `Example', as this is written to 
the log-file at the start of each example. 

The following is the log-file extract associated with Example~1 (from the 
author's Debian Linux platform).

\begin{quote}
\begin{verbatim} 
---Example (sixspot)
LaTeX Font Info:    Try loading font information for T1+cmss on input line 134.

(/usr/local/texlive/2016/texmf-dist/tex/latex/base/t1cmss.fd
File: t1cmss.fd 2014/09/29 v2.5h Standard LaTeX font definitions
)
---TeX process (rubikrotation.sty)-------
---NEW rotation command------------------
---command = RubikRotation[1]{[SixSpot],U,Dp,R,Lp,F,Bp,U,Dp,<(8q*, 8f*)>}
---writing current Rubik state to file rubikstate.dat
\openout7 = `rubikstate.dat'.

\ourRRcounter=\count121
---CALLing Perl script (rubikrotation.pl)
runsystem(perl rubikrotation.pl -i rubikstate.dat -o rubikstateNEW.dat)...execu
ted.

---inputting NEW datafile (data written by Perl script)
(./rubikstateNEW.dat

...PERL process..................................
...script = rubikrotation.pl v4.0 (03 March 2017)
...reading the current rubik state (from File: rubikstate.dat)
...up,W,W,W,W,W,W,W,W,W
...down,Y,Y,Y,Y,Y,Y,Y,Y,Y
...left,B,B,B,B,B,B,B,B,B
...right,G,G,G,G,G,G,G,G,G
...front,O,O,O,O,O,O,O,O,O
...back,R,R,R,R,R,R,R,R,R
...
...command=checkstate
...checking state of cube
...cubiesum = 54 (Red=9, Or=9, Ye=9, Gr=9, Bl=9, Wh=9, X=0)
...
...command=rotation,[SixSpot],U,Dp,R,Lp,F,Bp,U,Dp,<(8q*, 8f*)>
...dataline = rotation,[SixSpot],U,Dp,R,Lp,F,Bp,U,Dp,<(8q*; 8f*)>
...[SixSpot] is a label OK
...rotation U, OK
...rotation Dp, OK 
...rotation R, OK
...rotation Lp, OK
...rotation F, OK
...rotation Bp, OK
...rotation U, OK
...rotation Dp, OK 
...writing new Rubik state to file rubikstateNEW.dat
...SequenceName = SixSpot
...SequenceInfo = (8q*; 8f*)
...SequenceShort = [SixSpot],U,Dp,R,Lp,F,Bp,U,Dp
...SequenceLong = U,Dp,R,Lp,F,Bp,U,Dp
)
\end{verbatim}
\end{quote}



\pagebreak
%%-------------------------

\subsection{ShowRubikErrors}
\typeout{---Example (ShowRubikErrors)}


 In this example we demonstrate  the use of the  \verb!\ShowRubikErrors! command, 
 which  places a copy of  the Perl output file \verb!rubikstateERRORS.dat! 
 underneath the graphic so you can see a list of all the  errors, if any. 
 Note that this example is similar to the previous one except that we have  
 introduced several  errors---e.g.,~bad minipage width,  typos, as well as 
 some animals---into  the rotation sequence). 
 It is important to note that  the  \verb!\ShowRubikErrors! command must be 
 placed \textit{after}  the TikZ picture environment (i.e.,~in this case after 
the \verb!\ShowCube! command), or even at the end of the document. 
Note that full details of all errors are also included in the .log file. 

%%--------FIGURE 2 -----------

\RubikCubeSolved
\RubikRotation{[sixspot],U,Dp,R,Lp,F,Bp,U,Dpppp,cat,dog}

\begin{figure}[hbt]
  \centering
  \ShowCubeF{4.5cm}{0.5}{\DrawRubikCubeF}
  \ShowRubikErrors
\parbox{0.8\textwidth}{%
\caption{\label{fig:cubeincubeE}The same `sixspot' sequence of rotations as shown 
in Example~1,  but now with some   errors (wrong minipage width, typos and some 
animals\,!) in the rotation sequence (it \textit{should} be just 
\texttt{U,Dp,R,Lp,F,Bp,U,Dp}).}}
\end{figure}

{\noindent}In this example we have used the F version of the \verb!\ShowCube! 
command (\verb!\ShowCubeF!)  which places an fbox around the image so you can see the 
extent of any white space etc. This reveals that the set minipage-width ($4.5$cm) in 
the \verb!\ShowCubeF! command---see code below---is too narrow: it should be 
5cm ($10 \times 0.5$) to just include the whole image (i.e.,~$10 \times$ the TikZ 
scale-factor in this case). 
Once fixed, we can remove the F from the \verb!\ShowCubeF! command.
Note also  that only `\verb!\Draw...!' commands really need to be inside the TikZ 
picture environment (i.e.,~inside the \verb!\ShowCube! command). The above figure 
was generated by the following code.
%-----------------
\begin{quote}
\begin{verbatim}
\RubikCubeSolved
\RubikRotation{[sixspot],U,Dp,R,Lp,F,Bp,U,Dpppp,cat,dog}
\begin{figure}[hbt]
  \centering
  \ShowCubeF{4.5cm}{0.7}{\DrawRubikCubeF}
  \ShowRubikErrors
\caption{....}
\end{figure}
\end{verbatim}
\end{quote}
Even if the \verb!\ShowRubikErrors! command is not used, it is always a good idea 
to check the file \verb!rubikstateERRORS.dat! after a \LaTeX\ run, since this 
file will also reveal any  errors.

Note that the completely flat form of the cube here is generated by the
 \verb!\DrawRubikCubeF! command, where the terminal F denotes the Flat form.



\pagebreak
%----------------------

\subsection{Environments}
\typeout{---Example (Environments)}


In this example we highlight the fact that Rubik commands used inside a \LaTeX\ 
environment remain local to that environment, and how this can sometimes  be 
problematic.  Commands whose reach is meant to be  more global need to be 
executed outside such environments, where they can implement  global colour 
settings, which will then be accessible to Rubik \verb!\Draw..! commands inside 
subsequent environments.

Since we are drawing images, this is primarily an issue 
with the   the \verb!\minipage!, \verb!\figure!, and TikZ picture environments.
Consequently, it is generally best when drawing a sequence of  cubes  to reserve 
the TikZ picture environment  only  for Rubik \verb!\Draw..! commands and TikZ 
commands. Importantly, this  also applies to the commonly used  \verb!\ShowCube! 
command, since this is a minipage-wrapper for the TikZ  picture environment 
(see the \textsc{rubikcube} package documentation).

In this example the first cube (9a) uses a \verb!\RubikCubeSolved! command 
\textit{inside} a \verb!\ShowCube! environment. However, if we now perform the 
rotation  \textRubik{R}\ (using the command \verb!\RubikRotation{R}!) this results 
in  a quite unexpected effect on cube (9b) (and obviously not correct). This is because 
 the effect of the initial \verb!\RubikCubeSolved! command 
 (setting a new colour-state) is not  visible outside its \verb!\ShowCube! 
 environment, and hence the subsequent \verb!\RubikRotation{R}! command is unaware 
 of this recent attempt to update  the global colour-state information. 
 It turns out that this was actually last updated following the action of the \textbackslash\texttt{RubikRotation\{[sixspot],....\}} command used in 
Example~2, being the last colour-state command executed \textit{outside} an 
environment (a \texttt{figure}  environment in that example). Consequently, 
the strange form of cube (9b) is not what we expected.


\medskip
\noindent%
\cubenumber{9a}%
\ShowCube{2cm}{0.5}{%
    \RubikCubeSolved%
    \DrawRubikCubeRU}%
\quad\Rubik{R}%    
\RubikRotation{R}%
\cubenumber{9b}%
\ShowCube{2cm}{0.5}{\DrawRubikCubeRU}%
%---------------
\hspace{5mm}
\begin{minipage}{0.5\textwidth}
\begin{verbatim}
\usepackage{tikz,rubikcube,rubikrotation}
\newcommand{\cubenumber}[1]{\strut\raisebox{1cm}{#1}}
...
\cubenumber{9a}%
\ShowCube{2cm}{0.5}{%
    \RubikCubeSolved%
    \DrawRubikCubeRU%
     }%
\quad\Rubik{R}%
\RubikRotation{R}%
\cubenumber{9b}%
\ShowCube{2cm}{0.5}{\DrawRubikCubeRU}%
\end{verbatim}
\end{minipage}

\bigskip

If we now bring the \verb!\RubikCubeSolved! command out and place it before 
the \verb!\ShowCube! command then its  `state' information  becomes globally 
accessible (i.e.,~colour-state gets updated), and  therefore  gets used by the  
\verb!\RubikRotation{R}! command, and  hence cube (9d)  is rendered correctly.

\bigskip

\noindent%
\RubikCubeSolved%
\cubenumber{9c}%
\ShowCube{2cm}{0.5}{\DrawRubikCubeRU}%
\quad\Rubik{R}%
\RubikRotation{R}%
\cubenumber{9d}%
\ShowCube{2cm}{0.5}{\DrawRubikCubeRU}%
%---------------
\hspace{5mm}
\begin{minipage}{0.5\textwidth}
\begin{verbatim}
\RubikCubeSolved%
\cubenumber{9c}%
\ShowCube{2cm}{0.5}{\DrawRubikCubeRU}%
\quad\Rubik{R}%
\RubikRotation{R}%
\cubenumber{9d}%
\ShowCube{2cm}{0.5}{\DrawRubikCubeRU}%
\end{minipage}
\end{verbatim}
\end{minipage}




\pagebreak
%----------------------
\subsection{Coordinates}
\typeout{---Example (coordinates)}


For all cubes the origin of coordinates is defined as the bottom left corner of 
the \frontface. Consequently, it is easy to determine the coordinates of points 
and hence draw lines, circles, and place lettering or other objects using the 
standard TikZ \verb!\draw..! and \verb!\node..! commands. Note that for 
convenience  point $P$ is designed to be $(-1,-1)$ on the 2D view.
(The~following diagram  is Fig~1 from the \textsc{rubikcube} package documentation).


\begin{figure}[hbt]
\centering
\RubikFaceFrontAll{X}   % X = default = grey
\ShowCube{5.6cm}{0.7}{%
  \DrawFlatFront

\draw[line join=round,line cap=round,ultra thick] (0,0) -- (0,4); % Y
\draw[line join=round,line cap=round,ultra thick] (0,0) -- (4,0); % X

%draw labels
\node (Ylabel) at (-0.35,  3.8)  {$Y$};
\node (Xlabel) at ( 3.8,  -0.4)  {$X$};


%%----------draw the Rubik faces--------
%% outline Front face
\draw[line join=round,line cap=round,ultra thick]%
     (0,3) -- (-1,2) -- (-1,-1) -- (2,-1) -- (3,0);
%%
%% outline  Down face
\draw[line join=round,line cap=round,ultra thick]%
     (-1,-1) -- (0, 0);
%%
%%
%% draw labels
\node (Y0) at (-0.4, 0)  [blue]{$0$};
\node (Y1) at (-0.4, 1)  [blue]{$1$};
\node (Y2) at (-0.4, 2)  [blue]{$2$};
\node (Y3) at (-0.4, 3)  [blue]{$3$};
%%
\node (X0) at (0, -0.5)  [blue]{$0$};
\node (X1) at (1, -0.5)  [blue]{$1$};
\node (X2) at (2, -0.5)  [blue]{$2$};
\node (X3) at (3, -0.5)  [blue]{$3$};
%%
\node (P) at (-2.4, -1)  [blue]{$P\,(-1,-1)$};
}
\end{figure}



{\noindent}The code for the figure is given below.

We  draw everything in the  \verb!\ShowCube! environment; the \frontface\  
in grey (colour code = \texttt{X}) using the Rubik command 
\verb!\DrawFlatFront{X}!, and then draw all the lines and text using standard 
TikZ commands. The correct  minipage-width argument (5.6cm) for the 
\verb!\ShowCube! command is determined by trial-and-error, using the `fbox' 
form of the command (\verb!\ShowCubeF!), and then the `F' is removed 
($\rightarrow$ \verb!\ShowCube!). In order to avoid confusion, all Rubik commands 
start with a capital letter (e.g.,~\verb!\Draw..!), while all TikZ commands 
start with a lower-case letter (e.g.,~\verb!\draw..!).

\begin{quote}
\begin{verbatim}
\begin{figure}[hbt]
\centering
\RubikFaceFrontAll{X}% X = default non-colour (grey)
\ShowCube{5.6cm}{0.7}{%
   \DrawFlatFront
   \draw[line join=round,line cap=round,ultra thick] (0,0) -- (0,4);% Yaxis
   \draw[line join=round,line cap=round,ultra thick] (0,0) -- (4,0);% Xaxis
   \node (Ylabel) at (-0.35,  3.8)  {$Y$};
   \node (Xlabel) at ( 3.8,  -0.4)  {$X$};
   %% outline Left and Down faces
   \draw[line join=round,line cap=round,ultra thick]%
        (0,3) -- (-1,2) -- (-1,-1) -- (2,-1) -- (3,0);
   \draw[line join=round,line cap=round,ultra thick]%
        (-1,-1) -- (0, 0);
   \node (Y0) at (-0.4, 0)  [blue]{$0$};
   \node (Y1) at (-0.4, 1)  [blue]{$1$};
   \node (Y2) at (-0.4, 2)  [blue]{$2$};
   \node (Y3) at (-0.4, 3)  [blue]{$3$};
   \node (X0) at (0, -0.5)  [blue]{$0$};
   \node (X1) at (1, -0.5)  [blue]{$1$};
   \node (X2) at (2, -0.5)  [blue]{$2$};
   \node (X3) at (3, -0.5)  [blue]{$3$};
   \node (P) at (-2.4, -1)  [blue]{$P\,(-1,-1)$};
   }
\end{figure}
\end{verbatim} 
\end{quote}




\pagebreak
%----------------------
\subsection{Face notation}
\typeout{---Example (face notation)}


%% = my Fig A (rubikcube.dtx)

The following diagram  is Fig~2 from the \textsc{rubikcube} package documentation.

\begin{figure}[htb]
\centering%
\RubikFaceUpAll{Y}
\RubikFaceFrontAll{G}
\RubikFaceRightAll{O}
\ShowCubeF{5cm}{0.6}{%
\DrawRubikCubeRU%
%%-----------------

%% Right
\draw[line width=2pt,color=blue,->] (3.5,2) -- (5.3, 2);
\node (R) at (4.6, 2.5)  [blue]{\textbf{\textsf{R}}};
\node (x) at (5.8, 2)  [blue]{\textbf{\textsf{x}}};

%%Left
\draw[line width=2pt,color=blue] (-0.2,2) -- (-1.5, 2);
\node (L) at (-1.1, 2.5)  [blue]{\textbf{\textsf{L}}};

%%Up
\draw[line width=2pt,color=blue,->] (2, 3.5) -- (2, 5.5);
\node (U) at (1.4, 4.7)  [blue]{\textbf{\textsf{U}}};
\node (y) at (2, 6.1)  [blue]{\textbf{\textsf{y}}};

%%Down
\draw[line width=2pt,color=blue] (2, -0.2) -- (2, -1.5);
\node (D) at (2.6, -1.1)  [blue]{\textbf{\textsf{D}}};


%%Front
\draw[line width=2pt,color=blue,->] (1.5, 1.5) -- (0, -1);
\node (F) at (0.7, -0.7)  [blue]{\textbf{\textsf{F}}};
\node (z) at (-0.3, -1.4)  [blue]{\textbf{\textsf{z}}};

%%Back
\draw[line width=2pt,color=blue] (3.2, 4.2) -- (4, 5.5);
\node (B) at (4.4, 5)  [blue]{\textbf{\textsf{B}}};
%%
}
\end{figure}

{\noindent}The code for the figure is as follows 
(the origin $(0,0)$ is at the bottom left corner of the \frontface).


\begin{quote}
\begin{verbatim}
\begin{figure}[htb]
\centering%
\RubikFaceUpAll{Y}
\RubikFaceFrontAll{G}
\RubikFaceRightAll{O}
\ShowCubeF{5cm}{0.6}{%
  \DrawRubikCubeRU%
  %% Right
  \draw[line width=2pt,color=blue,->] (3.5,2) -- (5.3, 2);
  \node (R) at (4.6, 2.5)  [blue]{\textbf{\textsf{R}}};
  \node (x) at (5.8, 2)  [blue]{\textbf{\textsf{x}}};
  %%Left
  \draw[line width=2pt,color=blue] (-0.2,2) -- (-1.5, 2);
  \node (L) at (-1.1, 2.5)  [blue]{\textbf{\textsf{L}}};
  %%Up
  \draw[line width=2pt,color=blue,->] (2, 3.5) -- (2, 5.5);
  \node (U) at (1.4, 4.7)  [blue]{\textbf{\textsf{U}}};
  \node (y) at (2, 6.1)  [blue]{\textbf{\textsf{y}}};
  %%Down
  \draw[line width=2pt,color=blue] (2, -0.2) -- (2, -1.5);
  \node (D) at (2.6, -1.1)  [blue]{\textbf{\textsf{D}}};
  %%Front
  \draw[line width=2pt,color=blue,->] (1.5, 1.5) -- (0, -1);
  \node (F) at (0.7, -0.7)  [blue]{\textbf{\textsf{F}}};
  \node (z) at (-0.3, -1.4)  [blue]{\textbf{\textsf{z}}};
  %%Back
  \draw[line width=2pt,color=blue] (3.2, 4.2) -- (4, 5.5);
  \node (B) at (4.4, 5)  [blue]{\textbf{\textsf{B}}};
  }
\end{figure} 
\end{verbatim}
\end{quote}





\pagebreak
%----------------------
\subsection{Grey cube}
\label{sec:greycube}
\typeout{---Example (grey cube)}


When explaining elementary layer~1 moves, it can be useful to use the `grey cube' 
(\verb!\RubikCubeGrey!), as this  sets up only the central cubie on each face; 
we have shown the first cube in Semi-Flat (SF) mode simply to show  how the grey 
cube is configured  (note that an `all-grey' cube is also available: 
\verb!\RubikCubeAllGrey!). Both of these grey cube commands will also  accept 
the word `gray' (to be consistent with TikZ).

In this  example, we show how to position a single  `flipped'  white/orange edge 
cubie in the top  layer. 
  

\begin{figure}[hbt]

\centering%
\RubikCubeGrey%
\RubikFaceUp{X}{X}{X}%
            {X}{W}{O}%
            {X}{X}{X}%
               
\RubikFaceRight{X}{W}{X}
               {X}{G}{X}
               {X}{X}{X}
%
\cubenumber{1}%
\ShowCube{5cm}{0.5}{\DrawRubikCubeSF}%
%------------------
\quad\Rubik{Rp}\RubikRotation{Rp}
\cubenumber{2}%
\ShowCube{2cm}{0.5}{\DrawRubikCube}%
%-----------------------
\quad\Rubik{Fp}\RubikRotation{Fp}
\cubenumber{3}%
\ShowCube{2cm}{0.5}{\DrawRubikCube}%
%-----------------------
\end{figure}



{\noindent}The code for the figure is given below. 
After setting up the first cube, we then just use the \verb!\RubikRotation! 
command to generate the  remaining cubes.
The colours are coded as follows:  R~(red), O~(orange), Y~(yellow), 
G~(green), B~(blue),  W~(white),  and   X~(grey).

\begin{quote}
\begin{verbatim}
\usepackage{tikz,rubikcube,rubikrotation}
\newcommand{\cubenumber}[1]{\strut\raisebox{1cm}{#1}}
...
\begin{figure}[hbt]
\centering
% set up the first cube
\RubikCubeGrey%
\RubikFaceUp{X}{X}{X}%
            {X}{W}{O}%
            {X}{X}{X}%

\RubikFaceRight{X}{W}{X}
               {X}{G}{X}
               {X}{X}{X}
\cubenumber{1}%
\ShowCube{5cm}{0.5}{\DrawRubikCubeSF}%
%
\quad\Rubik{Rp}\RubikRotation{Rp}
\cubenumber{2}%
\ShowCube{2cm}{0.5}{\DrawRubikCube}%
%
\quad\Rubik{Fp}\RubikRotation{Fp}
\cubenumber{3}%
\ShowCube{2cm}{0.5}{\DrawRubikCube}%
\end{figure} 
\end{verbatim}
\end{quote}




\pagebreak

%-------------------------------
\subsection{Scramble a cube}
\label{sec:scrambleacube}
\typeout{---Example (scramble a cube)}


In this example we use the \verb!\RubikRotation! command to scramble a `solved' 
Rubik cube via  a sequence of 120 random rotations, using the following  command 
(the details of the process can be seen in the \texttt{.log} file):
\begin{quote}
\begin{verbatim}
\RubikRotation{random,120}
\end{verbatim}
\end{quote}
On this occasion we draw the cube Flat (F) using the command \verb!\DrawRubikCubeF!.
In this example, we also make use of the \verb!\SaveRubikState{}! command to  save 
the final  configuration (state) to a file (\texttt{rubikexampfig4.tex}) using 
\verb!\SaveRubikState{rubikexampfig4.tex}!,
so we can  display the  same cube configuration later  but in  a different format
(we show it again in the following example (Example~\ref{sec:saverubikstate}).
Note that since we are using a random sequence, it follows that each 
time this file is run not only will a visually different  cube  be generated,  
but the same state  will be shown in both 
here and in Example~\ref{sec:saverubikstate}.
%%--------FIGURE 3 -----------
\begin{figure}[hbt]
  \centering
  \RubikCubeSolved
  \RubikRotation{random,120}
  \SaveRubikState{rubikexampfig4.tex}  
  \ShowCubeF{6cm}{0.5}{\DrawRubikCubeF}
\parbox{0.7\textwidth}{%
\caption{\label{fig:randomone}This shows a cube  generated by 120 random rotations}}
\end{figure}
%----------------
\begin{quote}
\begin{verbatim}
\usepackage{tikz,rubikcube,rubikrotation}
...
\begin{figure}[hbt]
  \centering
  \RubikCubeSolved
  \RubikRotation{random,120}
  \SaveRubikState{rubikexampfig4.tex}  
  \ShowCubeF{6cm}{0.5}{\DrawRubikCubeF}
\caption{....}
\end{figure}
\end{verbatim}
\end{quote}

{\noindent}Q: How do we determine the minipage-width ($7.2$cm) in the 
\verb!\ShowCube! command?

\smallskip

{\noindent}A: The object is 12~cubie squares  wide. Since the TikZ scale-factor 
argument of the  \verb!\ShowCube! command (cms/unit length; default = 1) in this 
case is set to~$0.5$, then the true width of  the image will 
be $12 \times 0.5 = 6$\,cm. Note that here we have used the \verb!\ShowCubeF!
command and so we can see that this is correct. Changing the scale-factor will 
change the image size and hence a new width argument will be required to just fit 
the image.  

Note that in this particular case (where there is only a single image in the 
`figure' environment), since the \verb!\ShowCube! command places the image 
(in a TikZ picture environment) centrally  inside a minipage, the image will 
in fact be centrally placed in  the \verb!\textwidth! provided the image 
is \textit{smaller} than the fbox---i.e.,~if we used instead a minipage-width of, 
say, 12\,cm  the image would still  appear centred in the \verb!\textwidth! in 
this case. However, when there are several images in the `figure', then the spacing 
may appear strange unless each image closely fits its own minipage-width etc.
It is often useful, therefore, to check the size of the fbox (using the 
\verb!\ShowCubeF! command) as we have done here.
   
  
 
\pagebreak

%----------------------
\subsection{SaveRubikState}
\label{sec:saverubikstate}
\typeout{---Example (SaveRubikState)}

In this example we display a cube having the same state as that shown in 
the previous example (Example~\ref{sec:scrambleacube}). The configuration state 
was saved from Figure~\ref{fig:randomone} using the  command 
\verb!\SaveRubikState{rubikexampfig4.tex}!, and then input here  
using \verb!\input{rubikexampfig4.tex}!. These commands therefore allow  the 
state of a previous cube to be saved to a file, and then  displayed again 
later in  a different format.
%%-----------FIGURE 4 -----------
\begin{figure}[hbt]
  \centering
  \input{rubikexampfig4.tex}
  \ShowCube{4cm}{0.8}{\DrawRubikCubeLD}
\parbox{0.7\textwidth}{%
\caption{\label{fig:randomtwo}This shows a Rubik cube in exactly the  same 
state as  the one shown in Figure~\ref{fig:randomone}} }
\end{figure}
%%---------------------------------
\begin{quote}
\begin{verbatim}
\usepackage{tikz,rubikcube,rubikrotation}
...
\begin{figure}[hbt]
  \centering
  \input{rubikexampfig4.tex}
  \Showcube{4cm}{0.8}{\DrawRubikCubeLD}
\caption{....} 
\end{figure}
\end{verbatim}
\end{quote}




\pagebreak
%----------------------
\subsection{Series of cubes}
\typeout{---Example (series of cubes)}

Here we show a convenient way of displaying a series of small cubes showing 
a sequence of rotations (\rr{U}, \rr{R}, \rr{F}). 


\begin{figure}[hbt]
\centering
\RubikCubeSolved 
\ShowCube{2cm}{0.5}{\DrawRubikCubeRU}%
\quad\Rubik{U}\quad%
\RubikRotation{U}\ShowCube{2cm}{0.5}{\DrawRubikCubeRU}%
\quad\Rubik{R}\quad%
\RubikRotation{R}\ShowCube{2cm}{0.5}{\DrawRubikCubeRU}%
\quad\Rubik{F}\quad%
\RubikRotation{F}\ShowCube{2cm}{0.5}{\DrawRubikCubeRU}%
\caption{The rotations \rr{U}, \rr{R}, \rr{F}\ on a solved cube.} 
\end{figure}

{\noindent}The code for the above sequence is as follows:
\begin{quote}
\begin{verbatim}
\usepackage{tikz,rubikcube,rubikrotation}
...
\begin{figure}[hbt]
  \centering%
  \RubikCubeSolved%
  \ShowCube{2cm}{0.5}{\DrawRubikCubeRU}%
  \quad\Rubik{U}\quad%
  \RubikRotation{U}\ShowCube{2cm}{0.5}{\DrawRubikCubeRU}% 
  \quad\Rubik{R}\quad%
  \RubikRotation{R}\ShowCube{2cm}{0.5}{\DrawRubikCubeRU}%
  \quad\Rubik{F}\quad%
  \RubikRotation{F}\ShowCube{2cm}{0.5}{\DrawRubikCubeRU}%
\caption{The rotations \rr{U}, \rr{R}, \rr{F}\ on a solved cube.} 
\end{figure}
\end{verbatim}
\end{quote}

{\noindent}Note that we are starting with the default white-opposite-yellow (WY) 
solved cube, using the command  \verb!\RubikCubeSolved!, which is functionally  
the same as the more explicit \verb!\RubikCubeSolvedWY! (if you forget the 
terminal two letters then at least you will get a `solved' cube). 
A white-opposite-blue (WB) solved cube is available as \verb!\RubikCubeSolvedWB!.




\pagebreak
%----------------------
\subsection{Rotation sequence}
\typeout{---Example (rotation sequence)}

We now explore using the named Rubik cube rotation sequences and associated 
patterns available in the  \textsc{rubikpatterns} package---a small macro database 
(see the \textsc{rubikpatterns} documentation, and also its companion file \texttt{rubikpatternsLIST.pdf}). Having  the sequences available as  macros is 
very convenient since (a)~it avoids making errors when typing them out, 
and (b)~allows the easy application of software tools.
 
 A Rubik pattern  is the configuration generated  by a sequence of rotations 
 (or `moves') from some initial starting configuration  (typically a `solved' 
 configuration).  For example, FourSpot is a well known pattern which we can  
 generate  from a solved Rubik cube  using the macro \verb!\FourSpot!;  it is 
 defined as follows:
\begin{quote}
\begin{verbatim}
\newcommand{\FourSpot}{[FourSpot],F2,B2,U,Dp,R2,L2,U,Dp,<(12q*, 8f*)>}
\newcommand{\fourspot}{\FourSpot}
\end{verbatim}
\end{quote}
 Note that for convenience the macros names in the \textsc{rubikpatterns} package 
 are defined in  both upper and lower-case (i.e.,~the macros \verb!\FourSpot! 
 and \verb!\fourspot! are identical).  The following figure shows the FourSpot 
 sequence and pattern. 

\bigskip

\noindent%
\RubikCubeSolvedWY
\ShowCube{2cm}{0.5}{\DrawRubikCubeRD}
\RubikRotation{\FourSpot}
\quad\SequenceBraceA{FourSpot}{%
                     \ShowSequence{}{\Rubik}{\SequenceLong}%
                     }
\quad\ShowCube{2cm}{0.5}{\DrawRubikCubeSF}

\bigskip

{\noindent}The code for the above figure is as follows:


\begin{quote}
\begin{verbatim}
\usepackage{tikz,rubikcube,rubikrotation,rubikpatterns}
...
\noindent%
\RubikCubeSolvedWY
\ShowCube{2cm}{0.5}{\DrawRubikCubeRD}
\RubikRotation{\FourSpot}
\quad
\SequenceBraceA{FourSpot}{%
                         \ShowSequence{}{\Rubik}{\SequenceLong}%
                        }
\quad
\ShowCube{2cm}{0.5}{\DrawRubikCubeSF}
\end{verbatim} 
\end{quote}
Note that we have spread  the code slightly here in order to emphasise that 
the \verb!\ShowSequence! command is being used as an argument for the 
\verb!\SequenceBraceA! command (the `A' in the command \verb!\SequenceBraceA! 
denotes that the annotation is placed Above the sequence.)
We have used a solved cube with the WY (White opposite Yellow) 
configuration (\verb!\RubikCubeSolvedWY!).
The first cube is drawn from the  RD (Right-Down) viewpoint (\verb!\DrawRubikCubeRD!).
The second cube is drawn from the SF (Semi-Flat)  viewpoint (\verb!\DrawRubikCubeSF!) 
so we can see all the faces.

\pagebreak 

%----------------------
\subsection{SixTs}
\typeout{---Example (SixTs)}

A  more interesting cube pattern  is the SixTs configuration (from the 
\textsc{rubikpatterns} package),  which we  now show in a slightly 
different way (adding an extra face), as follows:

\bigskip

\noindent\hfil%
\RubikCubeSolvedWB%
\ShowCube{1.6cm}{0.4}{\DrawRubikCubeRU\DrawFlatDown{0}{-3.3}}%
\RubikRotation{\sixts}
\quad\SequenceBraceA{SixTs}{\ShowSequence{,\ }{\texttt}{\SequenceLong}}
\quad\ShowCube{2cm}{0.5}{\DrawRubikCubeRU}%
\quad\ShowCube{2cm}{0.5}{\DrawFaceFrontSide}%
\hfil

\bigskip

This time we have started with a solved cube having the WB  configuration 
(White opposite Blue), which is generated  using the command  
\verb!\RubikCubeSolvedWB! 
(we have added the \downface\ (blue) below to reveal the colour of this 
face---see note below). 

The rotation  sequence is   in `long-format' (expanded into 
separate rotations), comma-separated and space,  typewriter font,  
using the command \verb!\ShowSequence{,\ }{\texttt}{\SequenceLong}!.

The final image shows just the \frontface\  together with all the 
side-bars indicating the colours of the  adjacent facelets, 
using the \verb!\DrawFaceFrontSide! command. The images are 
separated using \verb!\quad!.
The code for the above figure is as follows:

\begin{quote}
\begin{verbatim}
\usepackage{tikz,rubikcube,rubikrotation,rubikpatterns}
...
\noindent\hfil
\RubikCubeSolvedWB
\ShowCube{1.6cm}{0.4}{%
                      \DrawRubikCubeRU%
                      \DrawFlatDown{0}{-3.3}%
                      }
\RubikRotation{\SixTs}
\quad\SequenceBraceA{SixTs}{%
                      \ShowSequence{,\ }{\texttt}{\SequenceLong}%
                      }
\quad\ShowCube{2cm}{0.5}{\DrawRubikCubeRU}
\quad\ShowCube{2cm}{0.5}{\DrawFaceFrontSide}
\hfil
\end{verbatim} 
\end{quote}



\subsubsection*{Notes}

\begin{enumerate} 

 \item   We have drawn the  \downface\ of the first cube using the command
\verb!\DrawFlatDown{0}{-3.3}! where the two arguments are  the $x$ and 
$y$ coordinates of the \textit{bottom left} corner of the \downface\  (blue). 
Note that the grid origin of  all cube images  coincides with the 
\textit{bottom left} corner of the \frontface\ (green in this case).

\item   The first image is really just 4 units wide. This is because the 2D width 
of the  \textit{side}  face (red) is designed to measure  1~unit wide in the 
oblique view (similarly, the 2D height of the  \textit{top} face also measures 
just 1~unit). Consequently, since the TikZ scale factor used is $0.4$, then 
the (minimum) width argument for its \verb!\ShowCube{}{}{}! command is 
$4\times 0.4 = 1.6$cm., hence we have \verb!\ShowCube{1.6cm}{0.4}{...}!.

\end{enumerate}



\pagebreak
%----------------------
\subsection{Three-edge cycle}
\typeout{---Example (three-edge cycle)}


The following example shows a sequence often used in solving the final layer.
 The black (no flip) and magenta (flip) arrows indicate  the \upface\  
cubie movement associated with the `three-edge cycle sequence 
\ShowSequence{,}{\rr}{F,R,U,Rp,Up,Fp}. The blue arrows indicate so-called 
collateral damage (two pairs of corner cubies swap positions) which can be fixed 
at a later stage. (This diagram  is from Section~13 in the 
\textsc{rubikcube} package documentation).

 \bigskip%
 \noindent\hfil%
 \RubikCubeSolved%
 \ShowCube{1.6cm}{0.4}{\DrawRubikCubeRU}%
 \quad\ShowCube{1.6cm}{0.4}{%
    \DrawFlatUpSide%
    \draw[thick,->,color=magenta] (1.5,0.5) -- (2.4, 1.4);
    \draw[thick,->] (2.5,1.5) -- (1.6, 2.4);
    \draw[thick,->,color=magenta] (1.3, 2.3) -- (1.3, 0.5);
    \draw[thick,<->,  color=blue] (0.5,2.6) -- (2.5, 2.6);
    \draw[thick,<->,  color=blue] (0.5,0.3) -- (2.5, 0.3);
    }%
 \RubikRotation{F,R,U,Rp,Up,Fp}%
 \quad\ShowSequence{}{\Rubik}{\SequenceLong}\quad$\longrightarrow$\quad%
 \ShowCube{1.6cm}{0.4}{\DrawFlatUpSide}%
 \hfil%
 
 \bigskip%


{\noindent}The code for the figure is as follows 


\begin{verbatim}
 \bigskip%
 \noindent\hfil%
 \RubikCubeSolved%
 \ShowCube{1.6cm}{0.4}{\DrawRubikCubeRU}%
 \quad\ShowCube{1.6cm}{0.4}{%
    \DrawFlatUpSide%
    \draw[thick,->,color=magenta] (1.5,0.5) -- (2.4, 1.4);
    \draw[thick,->] (2.5,1.5) -- (1.6, 2.4);
    \draw[thick,->,color=magenta] (1.3, 2.3) -- (1.3, 0.5);
    \draw[thick,<->,  color=blue] (0.5,2.6) -- (2.5, 2.6);
    \draw[thick,<->,  color=blue] (0.5,0.3) -- (2.5, 0.3);
    }%
 \RubikRotation{F,R,U,Rp,Up,Fp}%
 \quad\ShowSequence{}{\Rubik}{\SequenceLong}\quad$\longrightarrow$\quad%
 \ShowCube{1.6cm}{0.4}{\DrawFlatUpSide}%
 \hfil%
 
 \bigskip
\end{verbatim}





\pagebreak
%----------------------
\subsection{Superflip}
\typeout{---Example (subperflip)}


Once you can solve Rubik's cube, then an interesting exercise  is to generate  
the so-called `superflip' configuration, in which all the 
corners are correctly solved, while all the edges are 
flipped\,\footnote{See the `superflip' entry in \textit{Wikipedia}, and also 
the Kociemba website (\url{www.kociemba.org/cube.htm}); particularly the page 
\url{http://kociemba.org/math/oh.htm}}.

%--------draw the images-------------
\begin{figure}[hbt]
  \centering
  \RubikCubeSolved
  \ShowCube{2cm}{0.5}{\DrawRubikCubeRU}
  \quad$\longrightarrow$\quad%
  \RubikRotation{\superflip}%
  \ShowCube{2cm}{0.5}{\DrawRubikCubeLD}
  \quad\quad%
  \ShowCube{5cm}{0.5}{\DrawRubikCubeSF}
\caption{Two representations of the superflip configuration.}
\end{figure}
%----------------------

{\noindent}A superflip sequence converts the solved cube on the left 
into the form on the right, using the command \verb!\RubikRotation{\superflip}!.
The full code for the above figure is as follows:
\begin{verbatim}
\usepackage{tikz,rubikcube,rubikrotation,rubikpatterns}
...
\begin{figure}[hbt]
  \centering
  \RubikCubeSolved
  \ShowCube{2cm}{0.5}{\DrawRubikCubeRU}
  \quad$\longrightarrow$\quad%
  \RubikRotation{\superflip}%
  \ShowCube{2cm}{0.5}{\DrawRubikCubeLD}
  \quad\quad%
  \ShowCube{5cm}{0.5}{\DrawRubikCubeSF}
\caption{...}
\end{figure}
\end{verbatim}


The following superflip sequence\,\footnote{This particular  superflip sequence 
(in the \textsc{rubikpatterns} package) is due to Reid (1995); 
for details see the \textsc{rubikpatterns} package 
documentation, and also  \url{http://kociemba.org/math/oh.htm}. 
Another 20-move superflip sequence (due to H Kociemba),  is designated as  K32466  
  in  \url{www.nickalls.org/dick/papers/tex/RUBIK20moves.zip}.} 
has just 20  HTM rotations (Half Turn Metric: counting 180~degree turns as just 
one `rotation'). Note that the \textsc{rubikpatterns} package contains  this particular  
superflip sequence  as the macro \verb!\superflip!
(see \texttt{rubikpatterns.pdf}). Consequently  the  code 
\verb!\ShowSequence{,}{\large\texttt}{\superflip}!, will typeset the sequence
as follows:

\begin{center}
%% show the Short code
\ShowSequence{,}{\texttt}{\superflip}
\end{center}
Note that for convenience, the \textsc{rubikpatterns} package includes the sequence 
name (in square brackets)  as the first element of the associated  macro. 
This is possible since the contents of a comma-separated  square bracket  is not 
actioned as a rotation when it appears as part of the argument of  
the \verb!\RubikRotation! command.   

\pagebreak

Next  we present the sequence without commas in the form of hieroglyphs using 
the \verb!\Rubik! font, for which we require the `expanded' \verb!\SequenceLong! 
form (since the `short form' includes trailing digits---see \S\,9 in  
\texttt{rubikcube.pdf}), using the code

\begin{quote}
\begin{verbatim}
\usepackage{tikz,rubikcube,rubikrotation,rubikpatterns}
...
\RubikCubeSolved
\RubikRotation{\superflip}
\noindent\strut\hspace{-8mm}\ShowSequence{}{\Rubik}{\SequenceLong}
\end{verbatim}
\end{quote}
which gives


\bigskip

\RubikCubeSolved
\RubikRotation{\superflip}
\noindent\strut\hspace{-8mm}\ShowSequence{}{\Rubik}{\SequenceLong}


%%---------------------------------
\bigskip

\subsubsection*{Equivalent sequence}


Interestingly,  the superflip sequence is actually equivalent to
\Rubikbrace{\Rubikbracket{\Rubik{Rmp}\Rubik{Up}}4, \Rubik{yp}, \Rubik{x}}3.
Furthermore we can readily demonstrate this, as we can process this novel form 
of the sequence using  some useful features of the \verb!\RubikRotation! 
command, as follows:

\begin{quote}
\begin{verbatim}
\RubikCubeSolved%
\RubikRotation[3]{[superflip],(Rmp,Up)4,yp,x}%
\ShowCube{4cm}{0.4}{\DrawRubikCubeSF}%
\end{verbatim}
\end{quote}
which generates the following 

%-------------------
\begin{figure}[hbt]
  \centering
  \RubikCubeSolved%
  \RubikRotation[3]{[shortsuper],(Rmp,Up)4,yp,x}%
  \ShowCube{5cm}{0.5}{\DrawRubikCubeSF}
\end{figure}
%----------------------
{\noindent}which is exactly the same configuration as before.
Note that to do this we had to make  use of  the `repeat'  option \verb![3]!  
as well as  the \verb!(Rmp,Up)4! `repeat-block' in 
the argument of  the \verb!\RubikRotation! command above. 




\pagebreak
%----------------------
\subsection{Inverse sequence}
\typeout{---Example (inverse sequence)}


Generating the inverse of a Rubik sequence involves (a)~reversing the order of 
the sequence, and (b)~inverting each rotation in the sequence 
(see Sections~5.1 and 5.11 in the \textsc{rubikrotation} package documentation).


From  the grey-cube example~(\ref{sec:greycube}) we saw that the sixspot sequence  is: \verb!U,Dp,R,Lp,F,Bp,U,Dp!;
its inverse is therefore readily determined as \verb!D,Up,B,Fp,L,Rp,D,Up!. 
Note that this is easy to check since the sequence generated by the  
\verb!\RubikRotation! command is held by the macro \verb!\SequenceLong!. 
For~example, the output of the following commands
\begin{quote}
\begin{verbatim}
\fbox{\strut\ %
The inverse of the sixspot sequence is:
\RubikRotation{\sixspot,<inverse>}
\ShowSequence{,}{\texttt}{\SequenceLong}.
}
\end{verbatim}
\end{quote}
is \quad\fbox{\strut\ %
The inverse of the sixspot sequence is: 
\RubikRotation{\sixspot,<inverse>}
\ShowSequence{,}{\texttt}{\SequenceLong}.
}

\bigskip

A sequence and its inverse will annihilate each other when applied consecutively.  
For example, in the following figure we start with a solved cube and 
apply the sixspot sequence. Applying the  inverse of the sixspot sequence then 
results in the solved cube configuration again.

\newcommand{\sixspotINV}{[sixspotINV],D,Up,B,Fp,L,Rp,D,Up}
\newcommand{\sixspotarrow}{$\quad\overrightarrow{\strut\textsc{sixspot}}\quad$}
\newcommand{\sixspotINVarrow}{$\quad\overrightarrow{\strut\textsc{sixspotINV}}\quad$}

\begin{figure}[hbt]
\centering
\RubikCubeSolved%  
   \ShowCube{2cm}{0.5}{\DrawRubikCubeRU}\sixspotarrow% 
\RubikRotation{\sixspot}%   
   \ShowCube{2cm}{0.5}{\DrawRubikCubeRU}\sixspotINVarrow%
\RubikRotation{\sixspotINV}%  
   \ShowCube{2cm}{0.5}{\DrawRubikCubeRU}
\end{figure}

{\noindent}The code for the above figure is as follows:

\begin{quote}
\begin{verbatim}
\usepackage{tikz,rubikcube,rubikrotation,rubikpatterns}
...
\newcommand{\sixspotINV}{[sixspotINV],D,Up,B,Fp,L,Rp,D,Up}
\newcommand{\sixspotarrow}{$\quad\overrightarrow{\strut\textsc{sixspot}}\quad$}
\newcommand{\sixspotINVarrow}{$\quad\overrightarrow{\strut\textsc{sixspotINV}}\quad$}

\begin{figure}[hbt]
\centering
\RubikCubeSolved%  
   \ShowCube{2cm}{0.5}{\DrawRubikCubeRU}\sixspotarrow% 
\RubikRotation{\sixspot}%   
   \ShowCube{2cm}{0.5}{\DrawRubikCubeRU}\sixspotINVarrow%
\RubikRotation{\sixspotINV}%  
   \ShowCube{2cm}{0.5}{\DrawRubikCubeRU}
\end{figure}
\end{verbatim}
\end{quote}

\pagebreak

A significant property of the superflip configuration is that it is its own inverse.
Consequently we can achieve  a similar result simply by applying the 
superflip sequence \textit{twice in succession}, as follows:

\newcommand{\superfliparrow}{$\quad\overrightarrow{\strut\textsc{superflip}}\quad$}


\begin{figure}[hbt]
\centering
\RubikCubeSolved%  
   \ShowCube{2cm}{0.5}{\DrawRubikCubeRU}\superfliparrow% 
\RubikRotation{\superflip}%   
   \ShowCube{2cm}{0.5}{\DrawRubikCubeRU}\superfliparrow%
\RubikRotation{\superflip}%  
   \ShowCube{2cm}{0.5}{\DrawRubikCubeRU}
\end{figure}




\begin{center}
------ END ------
\end{center}

\end{document}