%% to be compiled with pdflatex

\documentclass{amsart}

%%%%%%%%

%%%%% Shows an affine projection of Loday's realization of the
%%%%% 3-dimensional associahedron (Loday, Jean-Louis.  Realization of
%%%%% the Stasheff polytope.  Arch. Math. 83, no. 3, 267-278, 2004. MR
%%%%% 2108555.)

%%%%% Another drawing can be found at the end of Loday's paper
%%%%% (p.277).

%%%%%%%%

%%%%% The realization lies in the hyperplane
%%%%%
%%%%%           H = { x + y + z + t = 10 }
%%%%%
%%%%% in R^4.  The drawing is the projection
%%%%%
%%%%%              (x, y, z, t)
%%%%%           -> (x, z, t)
%%%%%           -> (x - 3ct, z - ct)    c = 0.1925

%%%%% The plane { t = 4 } contains the 2-dimensional
%%%%% sub-associahedron
%%%%%
%%%%%              3214 - 1414 - 1234
%%%%%                 \          /
%%%%%                 3124 -- 2134
%%%%%
%%%%% the parallel plane { t = 1 } another pentagon face.

%%%%%%%%

%%%%% By the way:

%%%%% The 3 quadrilaterals are parallelograms and exactly 2 of them
%%%%% share (both) directions.  From this one sees that the drawing
%%%%%
%%%%% https://commons.wikimedia.org/wiki/File:Associahedron_K5.svg
%%%%%
%%%%% is NOT an affine projection of Loday's realization.

%%%%%%%%

%%%%% The macro \LCOORDINATES contains the coordinates of Loday's
%%%%% realization of the 4-dimensional associahedron.  I did not dare
%%%%% to try for a nice plane projection.

%%%%%%%%

\newif\ifLABELS %
%% uncomment to show the coordinates
% \LABELStrue %

\newif\ifNAMES %
%% uncomment to show instead the internal names of the vertices
%%% recommended if you read this file
% \NAMEStrue % no effect with \LABELSfalse
\ifNAMES \LABELStrue \fi

%%%%%%%%

\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
\thispagestyle{empty} %

\centerline{%

  \tikzpicture[x={(1cm,0cm)}, y={(0cm,1cm)}, z={(-3.85mm*3/2,-3.85mm/2)}] %
  %% a first version used the default tikz projection:
  %%% [x={(1cm,0cm)}, y={(0cm,1cm)}, z={(-3.85mm,-3.85mm)}]

  %%%%%%%% Loday coordinates

  %%% Computed from \VERTICES in cube-4-84.tex with a python script
  %%% (appended below).

  %%% The internal names (A0, etc.) could be eventually replaced by
  %%% the coordinates and dropped.  However I find them simpler to
  %%% recognize.

  \def\LCOORDINATES{%
    A0/1/2/3/4/5, % (((( 01 )2)3)4)5
    A1/2/1/3/4/5, % ((( 0(12) )3)4)5
    X0/1/4/1/4/5, % (( (01)(23) )4)5
    A2/3/2/1/4/5, % (( 0(1(23)) )4)5
    A3/3/1/2/4/5, % (( 0((12)3) )4)5
    Y1/1/2/6/1/5, % ( ((01)2)(34) )5
    Y2/1/6/2/1/5, % ( (01)(2(34)) )5
    B0/4/3/2/1/5, % ( 0(1(2(34))) )5
    Z1/2/1/6/1/5, % ( (0(12))(34) )5
    B1/4/1/4/1/5, % ( 0((12)(34)) )5
    X2/1/6/1/2/5, % ( (01)((23)4) )5
    X3/4/3/1/2/5, % ( 0(1((23)4)) )5
    B2/4/2/1/3/5, % ( 0((1(23))4) )5
    B3/4/1/2/3/5% % ( 0(((12)3)4) )5
    %%%% for the 4-dim. case
    %% A0a/1/2/3/8/1, % (((01)2)3)(45)
    %% A0b/1/2/9/2/1, % ((01)2)(3(45))
    %% A0c/1/8/3/2/1, % (01)(2(3(45)))
    %% A0d/5/4/3/2/1, % 0(1(2(3(45))))
    %% A1a/2/1/3/8/1, % ((0(12))3)(45)
    %% A1b/2/1/9/2/1, % (0(12))(3(45))
    %% A1d/5/1/6/2/1, % 0((12)(3(45)))
    %% X0a/1/4/1/8/1, % ((01)(23))(45)
    %% X0c/1/8/1/4/1, % (01)((23)(45))
    %% X0d/5/4/1/4/1, % 0(1((23)(45)))
    %% Y1b/1/2/9/1/2, % ((01)2)((34)5)
    %% Y1c/1/8/3/1/2, % (01)(2((34)5))
    %% Y1d/5/4/3/1/2, % 0(1(2((34)5)))
    %% A2a/3/2/1/8/1, % (0(1(23)))(45)
    %% A2d/5/2/1/6/1, % 0((1(23))(45))
    %% A3a/3/1/2/8/1, % (0((12)3))(45)
    %% A3d/5/1/2/6/1, % 0(((12)3)(45))
    %% Y2c/1/8/2/1/3, % (01)((2(34))5)
    %% Y2d/5/4/2/1/3, % 0(1((2(34))5))
    %% Z1b/2/1/9/1/2, % (0(12))((34)5)
    %% Z1d/5/1/6/1/2, % 0((12)((34)5))
    %% X2c/1/8/1/2/3, % (01)(((23)4)5)
    %% X2d/5/4/1/2/3, % 0(1(((23)4)5))
    %% B0d/5/3/2/1/4, % 0((1(2(34)))5)
    %% B1d/5/1/4/1/4, % 0(((12)(34))5)
    %% X3d/5/3/1/2/4, % 0((1((23)4))5)
    %% B2d/5/2/1/3/4, % 0(((1(23))4)5)
    %% B3d/5/1/2/3/4% % 0((((12)3)4)5)
  }

  \foreach \NNN/\A/\B/\C/\D/\E in \LCOORDINATES { %

    %% one has \A+\B+\C+\D+\E=15 and E=5 (in the 3-dim case)
    %% drop the second and the constant last coordinate
    \coordinate (\NNN) at ($(\A,\C,\D)$) ;

  }

  %%%%%%%%

  %% placement in shipout is independent of labels
  \useasboundingbox (X0) (Z1) (B0) ; %

  %%%%%%%%

  %%%% the drawing is based on

  %%%% 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

  %%%%

  %% faces at A1, A3, B3 in front

  %% edges are drawn twice

  %% split some "-- cycle" at sharp corners

  \begin{scope} [blue]

    \draw[fill=white] % [fill=yellow!80]
    (X0) -- (A2) -- (B2) -- (X3) (X3) -- (X2) -- (X0) ; % Bottom

    \draw[fill=blue!30]
    (Y2) -- (X2) -- (X3) -- (B0) -- cycle ; % Bottom-Back
    \draw[fill=blue!30]
    (Y1) -- (Y2) -- (B0) -- (B1) -- (Z1) -- cycle ; % Back

    \draw[fill=red!10]
    (Y1) -- (A0) -- (X0) -- (X2) -- (Y2) -- (Y1) ; % Left

    \draw[fill=red!20,opacity=0.8]
    (B1) -- (B0) -- (X3) -- (B2) -- (B3) -- (B1) ; % Right
    \draw[fill=red!20,opacity=0.8]
    (A1) -- (Z1) -- (B1) -- (B3) -- (A3) -- cycle ; % Top Right
    \draw[fill=red!20,opacity=0.8]
    (A0) -- (Y1) -- (Z1) -- (A1) -- cycle ; % Top
    \draw[fill=red!20,opacity=0.8]
    (A2) -- (B2) -- (B3) -- (A3) -- cycle ; % Front Right

    \draw[fill=red!20,opacity=0.6]
    (A0) -- (A1) -- (A3) -- (A2) -- (X0) -- cycle ; % Front

  \end{scope}

  %%%%%%%%

  % \LABELStrue %
  \ifLABELS

  \begin{scope} [outer sep=0pt,inner sep=2pt]

    \tiny

    %%%% ad hoc hacking...

    \tikzset{ %
      B3place/.style={below left,yshift=-1.8pt}, %
    } %

    \def\PLACES{ %
      A0/left, A1/above left, A2/below, A3/below right, %
      B0/right, B1/right, B2/below, B3/B3place, %
      X0/below, X2/above left, X3/right, %
      Y1/above, Y2/above right, Z1/above}

    % \NAMEStrue %
    \ifNAMES

    %%%%%%%% show the names of the vertices

    \foreach \XXX/\place in \PLACES { %
      \node[\place] at (\XXX) {\XXX} ; %
    }

    \else % \ifNAMES

    %%%%%%%% show the coordinates

    \foreach \XXX/\place in \PLACES { %
      \node[\place] (N\XXX) at (\XXX) {\phantom{0000}} ; %
    }

    \foreach \XXX/\A/\B/\C/\D in \LCOORDINATES { %
      \node at (N\XXX) {\A\B\C\D} ; %
    }

    \fi % \ifNAMES

  \end{scope}

  \fi % \ifLABELS

  \endtikzpicture
} % \centerline
\end{document}

%%%%%%%%

%%%% python3 script to get paren expressions

%%% import itertools
%%%
%%% def parens(n,s):
%%%     if n == 1:
%%%         return [s]
%%%     return itertools.chain.from_iterable(
%%%         [itertools.product(parens(k,s),parens(n-k,s+k)) for k in range(1,n)])
%%%
%%% for n in range(7):
%%%     for p in parens(n,0):
%%%         print (p)

%%%% python3 script to compute Lodays coordinates

%%% ## see \VERTICES in cube-4-84.tex
%%% DATA=[
%%%     ("A0", "Co", "(((( 01 )2)3)4)5"),
%%%     ("A1", "Ca", "((( 0(12) )3)4)5"),
%%%     ("X0", "Cb", "(( (01)(23) )4)5"),
%%%     ("A2", "Cd", "(( 0(1(23)) )4)5"),
%%%     ("A3", "Cd", "(( 0((12)3) )4)5"),
%%%     ("Y1", "Cc", "( ((01)2)(34) )5"),
%%%     ("Y2", "Cd", "( (01)(2(34)) )5"),
%%%     ("B0", "Ce", "( 0(1(2(34))) )5"),
%%%     ("Z1", "Cd", "( (0(12))(34) )5"),
%%%     ("B1", "Ce", "( 0((12)(34)) )5"),
%%%     ("X2", "Cd", "( (01)((23)4) )5"),
%%%     ("X3", "Ce", "( 0(1((23)4)) )5"),
%%%     ("B2", "Ce", "( 0((1(23))4) )5"),
%%%     ("B3", "Ce", "( 0(((12)3)4) )5"),
%%%     ("A0a", "Co", "(((01)2)3)(45)"),
%%%     ("A0b", "Co", "((01)2)(3(45))"),
%%%     ("A0c", "Co", "(01)(2(3(45)))"),
%%%     ("A0d", "Co", "0(1(2(3(45))))"),
%%%     ("A1a", "Ca", "((0(12))3)(45)"),
%%%     ("A1b", "Ca", "(0(12))(3(45))"),
%%%     ("A1d", "Ca", "0((12)(3(45)))"),
%%%     ("X0a", "Cb", "((01)(23))(45)"),
%%%     ("X0c", "Cb", "(01)((23)(45))"),
%%%     ("X0d", "Cb", "0(1((23)(45)))"),
%%%     ("Y1b", "Cc", "((01)2)((34)5)"),
%%%     ("Y1c", "Cc", "(01)(2((34)5))"),
%%%     ("Y1d", "Cc", "0(1(2((34)5)))"),
%%%     ("A2a", "Cd", "(0(1(23)))(45)"),
%%%     ("A2d", "Cd", "0((1(23))(45))"),
%%%     ("A3a", "Cd", "(0((12)3))(45)"),
%%%     ("A3d", "Cd", "0(((12)3)(45))"),
%%%     ("Y2c", "Cd", "(01)((2(34))5)"),
%%%     ("Y2d", "Cd", "0(1((2(34))5))"),
%%%     ("Z1b", "Cd", "(0(12))((34)5)"),
%%%     ("Z1d", "Cd", "0((12)((34)5))"),
%%%     ("X2c", "Cd", "(01)(((23)4)5)"),
%%%     ("X2d", "Cd", "0(1(((23)4)5))"),
%%%     ("B0d", "Ce", "0((1(2(34)))5)"),
%%%     ("B1d", "Ce", "0(((12)(34))5)"),
%%%     ("X3d", "Ce", "0((1((23)4))5)"),
%%%     ("B2d", "Ce", "0(((1(23))4)5)"),
%%%     ("B3d", "Ce", "0((((12)3)4)5)"),
%%% ]
%%%
%%% import re
%%%
%%% for d in DATA:
%%%     name, color, S = d
%%%
%%%     parens = re.split('[0-9]',S.replace(' ',''))[1:-1]
%%%     N = len(parens)
%%%     dp = [parens[h].count('(') - parens[h+1].count(')') for h in range(N-1)]
%%%
%%%     LC = []
%%%     for k in range(N):
%%%
%%%         a = 1
%%%         d = 0
%%%         for h in range(k,N-1):
%%%             d += dp[h]
%%%             if d <= 0: break
%%%             a += 1
%%%
%%%         b = 1
%%%         d = 0
%%%         for h in range(k):
%%%             d -= dp[k-h-1]
%%%             if d <= 0: break
%%%             b += 1
%%%
%%%         LC.append(str(a*b))
%%%
%%%     print (name + '/' + '/'.join(LC) + ', % ' + S)

%%%%%%%%

%% png creation (normal size, transparent)

%%% pdflatex cube-3L.tex
%%% pdftocairo -png -singlefile -transp cube-3L.pdf tmp
%%% magick -define png:exclude-chunk=date,time tmp.png -trim +repage cube-3L.png
%%% optipng cube-3L.png

%%%% magick adds white (fallback) background to the transparent image
%%%% and has the convenient option -trim.

%%%% Default resolution of pdftocairo is 150 ppi.  Size of trimmed
%%%% image is 283x333.

%% png creation (large size)

%%% pdflatex cube-3L.tex
%%% pdftocairo -png -singlefile -r 361.35 -W 877 -H 998 -x 1097 -y 480 cube-3L.pdf cube-3L-large
%%% optipng cube-3L-large.png

%%%% The resolution 361.35 ppi translates 1pt to 5 pixels.  Hence 1
%%%% pixel in the png corresponds to 0.2pt.  A TeX rule becomes 2
%%%% pixels wide.

%%%% trim parameters:
%%% magick tmp.png -format "%@\n" info: %% 677x798+1197+580
%%%% padding is 100 pixels

%% 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

%%%%%%%%

%%%% Created:
%%% 2026-03-08

%%%% Latest changes:
%%% 2026-03-10 % new projection
%%% 2026-03-11 % yellow!80 -> white

%%%% Latest comment changes:
%%% 2026-03-18 % describe the projection, add/change python scripts

%%%%%%%%
