%% to be compiled with pdflatex

\documentclass{amsart}

%%%%%%%%

\newif\ifNAMES %
%% uncomment to show the internal names of the vertices
%%% recommended if you read this file
% \NAMEStrue %

%%%%%%%%

\usepackage{tikz}
\usetikzlibrary{calc,decorations.markings}

\begin{document}
\thispagestyle{empty}

\centerline{%
  \tikzpicture

  %%%% names as in cube-4-84.tex except for
  %%% (A02) = (X0)
  %%% (TAi) = (Bi)

  \coordinate (A0) at (0,0) ; %
  \coordinate (A1) at (0,-2.1) ; %
  \coordinate (TA0) at (-9,0) ; %

  % \coordinate (A0) at (A0) ; %
  \coordinate (K01) at ($(A0)!0.5!(A1)$) ; %
  % \coordinate (A1) at (A1) ; %
  \coordinate (K13) at ($(A0)!1.5!(A1)$) ; %
  \coordinate (A3) at ($(A0)!2!(A1)$) ; %
  \coordinate (K32) at ($(A0)!2.5!(A1)$) ; %
  \coordinate (A2r) at ($(A0)!3!(A1)$) ; %

  \coordinate (K002) at ($(A0)!-0.5!(A1)$) ; %
  \coordinate (A02) at ($(A0)!-1!(A1)$) ; %
  \coordinate (K022) at ($(A0)!-1.5!(A1)$) ; %
  \coordinate (A2) at ($(A0)!-2!(A1)$) ; %

  \def\RightVertices{K01,A1,K13,A3,K32,A2r,K002,A02,K022,A2}
  %% left vertices
  \foreach \XXX in \RightVertices { %
    \coordinate (T\XXX) at ($(\XXX)+(TA0)$) ; }
  \edef\RightVertices{A0,\RightVertices}

  %% 2x2 inner subdivisions and the midpoints of 2 non-arrow edges

  \coordinate (X1) at ($(A02)!2/3!(TA02)$) ; %
  \coordinate (Y1) at ($(A0)!2/3!(TA0)$) ; %
  \coordinate (XY1) at ($(X1)!1/2!(Y1)$) ; %
  \coordinate (Y0) at ($(A0)!1/3!(TA0)$) ; %
  \coordinate (Z0) at ($(A1)!1/3!(TA1)$) ; %
  \coordinate (YZ0) at ($(Y0)!1/2!(Z0)$) ; %

  %%%%%%%%

  %% placement in shipout is independent of labels, thickness of
  %% bullets
  \useasboundingbox (TA2) (A2) (TA2r) (A2r) ; %

  %%%%%%%%

  %%%% cf. cube-4-84.tex, cube-3.tex

  %%%% https://tex.stackexchange.com/questions/28284/how-to-draw-a-cube-with-tikz-where-all-faces-have-a-distinct-color
  %%%% https://tex.stackexchange.com/a/28286

  %%% \draw[blue,fill=yellow!80] % Bottom Face
  %%%% \draw[blue,fill=blue!30] % Back Face
  %%% \draw[blue,fill=red!10] % Left Face
  %%% \draw[blue,fill=red!20,opacity=0.8] % Right Face
  %%%% \draw[blue,fill=red!20,opacity=0.6] % Front Face
  %%% \draw[blue,fill=red!20,opacity=0.8] % Top Face

  \definecolor{mydarkgreen}{RGB}{5,128,85}

  \iffalse %
  % \fi\iftrue %

  %% experiment with transparency

  \fill[yellow!62.5,opacity=0.8] (A1) -- (TA1) -- (TA3) -- (A3) -- cycle ; % Bottom Face
  \fill[red!12.5,opacity=0.8] (A2r) -- (TA2r) -- (TA3) -- (A3) -- cycle ; % Left Face
  \fill[orange!50,opacity=0.8] (A0) -- (TA0) -- (TA1) -- (A1) -- cycle ; % Right Face
  \fill[mydarkgreen!25,opacity=0.8] (A0) -- (A2) -- (TA2) -- (TA0) -- cycle ; % Top Face

  \else %

  \fill[yellow!50] (A1) -- (TA1) -- (TA3) -- (A3) -- cycle ; % Bottom Face
  \fill[red!10] (A2r) -- (TA2r) -- (TA3) -- (A3) -- cycle ; % Left Face
  \fill[orange!40] (A0) -- (TA0) -- (TA1) -- (A1) -- cycle ; % Right Face
  \fill[mydarkgreen!20] (A0) -- (A2) -- (TA2) -- (TA0) -- cycle ; % Top Face

  \fi %

  %%%%%%%%

  \tikzset{
    outer sep=0pt, %
    midtip/.style={postaction={decorate,decoration= %
        {markings,mark=at position #1 with %
          %% need the thin,black to override
          {\arrow[thin,black]{stealth[sep=-2pt]}} %
    }}}, %
    midtip/.default=1/2, %
  }

  \def\ST#1|{$\scriptstyle #1$}
  \def\SB#1|{$\scriptstyle \bf #1$}
  \def\SS#1|{$\scriptscriptstyle #1$}

  %%%% horizontal lines

  \draw[thick,midtip] (TA2) -- (A2) %
  node[pos=1/2,above] {\SB 1(2(34))5 |} ; %

  %% red line
  \draw[thick,draw=red,midtip] (TK022) -- (K022) %
  node[pos=1/2,above] {\SS P:12(34)5 |} ; %

  \draw[thick,midtip=1/6,midtip=2/3] (TA02) -- (A02) %
  node[pos=1/6,above] {\SB 12((34)5) |} %
  node[pos=1/3,above] {\ST (12)((34)5) |} % (X1)
  node[pos=2/3,above] {\SB (12)(34)5 |} ; %

  %% red line
  \draw[thick,draw=red,midtip=1/6,midtip=2/3] (TK002) -- (K002) %
  node[pos=1/6,above] {\SS Q:12(345) |} %
  % coordinate[pos=1/3] (XY1) % defined above
  node[pos=1/3,above right] {\SS (12)(345) |} %
  node[pos=2/3,above] {\SS P:(12)345 |} ; %

  \draw[thick,midtip=1/6,midtip=1/2,midtip=5/6] (TA0) -- (A0) %
  node[pos=1/6,above] {\SB 12(3(45)) |} %
  node[pos=1/3,below] {\ST (12)(3(45)) |} % (Y1)
  node[pos=1/2,above] {\SB (12)3(45) |} %
  node[pos=2/3,above] {\ST ((12)3)(45) |} % (Y0)
  node[pos=5/6,above] {\SB ((12)3)45 |} ; %

  %% red line
  \draw[thick,draw=red,midtip=1/3,midtip=5/6] (TK01) -- (K01) %
  node[pos=1/3,above] {\SS P:123(45) |} %
  % coordinate[pos=2/3] (YZ0) % defined above
  node[pos=2/3,above left] {\SS (123)(45) |} %
  node[pos=5/6,above] {\SS Q:(123)45 |} ; %

  \draw[thick,midtip=1/3,midtip=5/6] (TA1) -- (A1) %
  node[pos=1/3,above] {\SB 1(23)(45) |} %
  node[pos=2/3,below] {\ST (1(23))(45) |} % (Z0)
  node[pos=5/6,above] {\SB (1(23))45 |} ; %

  %% red line
  \draw[thick,draw=red,midtip] (TK13) -- (K13) %
  node[pos=1/2,above] {\SS P:1(23)45 |} ; %

  \draw[thick,midtip] (TA3) -- (A3) %
  node[pos=1/2,above] {\SB 1((23)4)5 |} ; %

  %% red line
  \draw[thick,draw=red,midtip] (TK32) -- (K32) %
  node[pos=1/2,above] {\SS Q:1(234)5 |} ; %

  %% repeat (TA2) -- (A2)
  \draw[thick,midtip] (TA2r) -- (A2r) %
  node[pos=1/2,above] {\SB 1(2(34))5 |} ; %

  %%%% blue dots

  %% get the same dotting on each segment, symmetric at blue bullets

  \tikzset{mydots/.style={thick,draw=blue,loosely dotted,dash expand off}} %

  \foreach \A/\M/\B in {%
    A2/K022/A02, A02/K002/A0, A0/K01/A1, A1/K13/A3, A3/K32/A2r%
  }{
    \path[mydots] (\A) -- (\M) ; %
    \path[mydots] (\B) -- (\M) ; %
    \path[mydots] (T\A) -- (T\M) ; %
    \path[mydots] (T\B) -- (T\M) ; %
  }
  \foreach \A/\M/\B in {%
    X1/XY1/Y1,Y0/YZ0/Z0%
  }{
    \path[mydots] (\A) -- (\M) ; %
    \path[mydots] (\B) -- (\M) ; %
  }

  %%%%

  \path (A2) -- (A2r) %
  node[pos=1/10,right] {\SS (12(34))5 |} %
  node[pos=3/10,right] {\SS ((12)34)5 |} %
  node[pos=5/10,right] {\SS ((123)4)5 |} %
  node[pos=7/10,right] {\SS (1(23)4)5 |} %
  node[pos=9/10,right] {\SS (1(234))5 |} %
  node[pos=0/5,right] {\ST (1(2(34)))5 |} %
  node[pos=1/5,right] {\ST ((12)(34))5 |} %
  node[pos=2/5,right] {\ST (((12)3)4)5 |} %
  node[pos=3/5,right] {\ST ((1(23))4)5 |} %
  node[pos=4/5,right] {\ST (1((23)4))5 |} %
  node[pos=5/5,right] {\ST (1(2(34)))5 |} %
  ;

  \path (TA2) -- (TA2r) %
  node[pos=1/10,left] {\SS 1(2(34)5) |} %
  node[pos=3/10,left] {\SS 1(2(345)) |} %
  node[pos=5/10,left] {\SS 1(23(45)) |} %
  node[pos=7/10,left] {\SS 1((23)45) |} %
  node[pos=9/10,left] {\SS 1((234)5) |} %
  node[pos=0/5,left] {\ST 1((2(34))5) |} %
  node[pos=1/5,left] {\ST 1(2((34)5)) |} %
  node[pos=2/5,left] {\ST 1(2(3(45))) |} %
  node[pos=3/5,left] {\ST 1((23)(45)) |} %
  node[pos=4/5,left] {\ST 1(((23)4)5) |} %
  node[pos=5/5,left] {\ST 1((2(34))5) |} %
  ;

  %%%% bullets

  \tikzset{radius=1.7pt} %

  \foreach \XXX in {%
    A0,A1,A3,A2r,A02,A2} {
    \fill (\XXX) circle[] ; %
    \fill (T\XXX) circle[] ; } %

  \foreach \XXX in {%
    Y1,X1,Z0,Y0} { %
    \fill (\XXX) circle[] ; } %

  \foreach \XXX in {%
    K01,K13,K32,K002,K022} { %
    \fill[blue] (\XXX) circle[] ; %
    \fill[blue] (T\XXX) circle[] ; } %

  \foreach \XXX in {%
    XY1,YZ0} { %
    \fill[blue] (\XXX) circle[] ; } %

  %%%%%%%% show the names of the vertices
  \ifNAMES

  \foreach \XXX in \RightVertices {
    \node[above left] at (\XXX) {\tiny \XXX} ; %
    \node[above right] at (T\XXX) {\tiny T\XXX} ; %
  }

  \node[below right] at (X1) {\tiny X1} ; %
  \node[above left] at (Y1) {\tiny Y1} ; %
  \node[above left] at (XY1) {\tiny XY1} ; %
  \node[below right] at (Y0) {\tiny Y0} ; %
  \node[above left] at (Z0) {\tiny Z0} ; %
  \node[below right] at (YZ0) {\tiny YZ0} ; %

  \fi % \ifNAMES

  \endtikzpicture
} % \centerline
\end{document}

%%%%%%%%

%% png creation (normal size, transparent)

%%% pdflatex diagram3-2.tex
%%% pdftocairo -png -singlefile -transp diagram3-2.pdf tmp
%%% magick -define png:exclude-chunk=date,time tmp.png -crop 705x649+285+220 +repage diagram3-2.png
%%% optipng diagram3-2.png

%%%% Default resolution of pdftocairo is 150 ppi.

%%%% magick adds white (fallback) background to the transparent image.

%%%% trim parameters:
%%% magick tmp.png -format "%@\n" info: %% 704x649+286+220

%%%% Left padding 1px (after trimming) to get symmetric dots.

%% program versions

%%% This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019/Debian) (preloaded format=pdflatex)
%%% Document Class: amsart 2017/10/31 v2.20.4
%%% Package: tikz 2020/01/08 v3.1.5b (3.1.5b)

%%% pdftocairo version 0.86.1
%%% ImageMagick 7.1.1-43 Q16-HDRI x86_64 22550 https://imagemagick.org
%%% OptiPNG version 0.7.7

%%%%%%%%

%%%% First version:
%%% 2025-01-25

%%%% Latest changes:
%%% 2025-08-19 % use midtip and refactor
%%% 2026-01-31 % fix midtip
%%% 2026-03-01 % outer sep=0pt

%%%%%%%%
