%% assoc-L3A.tex - an affine projection of the Loday associahedron
%% Author: Markus Rost <https://www.math.uni-bielefeld.de/~rost/>
%% Created: 8 Mar 2026

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

%%%%%%%%

%%%%% A version of 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.

%%%%% Appended are python scripts to produce parenthetical expressions
%%%%% and their Loday coordinates.

%%%%%%%%

\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

\newif\ifPARENS %
%% uncomment to get paren expressions as labels
% \PARENStrue %
\ifPARENS \LABELSfalse \fi % just in case

\newif\ifGREEN %
%% uncomment to draw the 2. dim subassociahedra in green
% \GREENtrue %

%%%%%%%%

\ifPARENS %
%% this is cmb10 scaled 0.5 (there is no cmb5)
%% cmb10 has same sizes and spacing as cmr10
\DeclareFixedFont{\PARENfont}{OT1}{cmr}{b}{n}{5} %
\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/(((01)2)3)4, % ((( 01 )2)3)4
    A1/2/1/3/4/((0(12))3)4, % (( 0(12) )3)4
    X0/1/4/1/4/((01)(23))4, % ( (01)(23) )4
    A2/3/2/1/4/(0(1(23)))4, % ( 0(1(23)) )4
    A3/3/1/2/4/(0((12)3))4, % ( 0((12)3) )4
    Y1/1/2/6/1/((01)2)(34), %  ((01)2)(34)
    Y2/1/6/2/1/(01)(2(34)), %  (01)(2(34))
    B0/4/3/2/1/0(1(2(34))), %  0(1(2(34)))
    Z1/2/1/6/1/(0(12))(34), %  (0(12))(34)
    B1/4/1/4/1/0((12)(34)), %  0((12)(34))
    X2/1/6/1/2/(01)((23)4), %  (01)((23)4)
    X3/4/3/1/2/0(1((23)4)), %  0(1((23)4))
    B2/4/2/1/3/0((1(23))4), %  0((1(23))4)
    B3/4/1/2/3/0(((12)3)4)% %  0(((12)3)4)
  }

  %%%% for the 4-dim. case
  %% \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
  %%   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)
  %% }

  %% one has \x+\y+\z+\t=10
  %% drop the second coordinate
  \path foreach \NNN/\x/\y/\z/\t in \LCOORDINATES { %
    coordinate (\NNN) at ($(\x,\z,\t)$) } ; %

  %%%%%%%%

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

  %%%%%%%%

  %%%% the 9 faces of the associahedron

  \def\faceQA{A2,A3,B3,B2} % square
  \def\faceQB{A1,A0,Y1,Z1} % rectangle at PA
  \def\faceQC{X3,B0,Y2,X2} % rectangle T(Q1) %% T=transpose

  %% 2-dim sub-associahedron + parallel
  \def\facePA{A2,A3,A1,A0,X0} %
  \def\facePF{B0,B1,Z1,Y1,Y2} %
  %% 2-dim sub-associahedron' + parallel
  \def\facePB{B2,B3,B1,B0,X3} % T(PA)
  \def\facePG{X0,A0,Y1,Y2,X2} % T(PF)
  %% pentagons with no parallel face
  \def\facePC{A3,B3,B1,Z1,A1} %
  \def\facePD{A2,B2,X3,X2,X0} % T(PC)

  %%%% the 21 edges of the associahedron

  %% faces in back: at X2,Y2 : QC,PD,PF,PG
  %% faces in front: at A1,A3,B3 : QA,QB,PA,PB,PC

  \def\EDGESBACK{% 5 edges
    B0/Y2,Y2/X2,X2/X3, % QC
    X0/X2,X2/X3,Y2/Y1% PD,PF,PG
  }
  \def\EDGESFRONT{% 16 edges
    A2/A3,A3/B3,B3/B2,B2/A2, % QA
    A1/A0,A0/Y1,Y1/Z1,Z1/A1, % QB
    A0/X0,X0/A2,A1/A3, % PA
    B1/B0,B0/X3,X3/B2, % PB
    B3/B1,B1/Z1% PC
  }
  % \edef\EDGES{\EDGESBACK,\EDGESFRONT}

  %%%%%%%%

  \def\CYCLE#1{foreach\p[count=\i]in#1{\ifnum\i=1 \else--\fi(\p)}--cycle}

  \fill[white] \CYCLE\facePD ; % Bottom
  \fill[blue!30] \CYCLE\faceQC ; % Bottom-Back
  \fill[blue!30] \CYCLE\facePF ; % Back
  \fill[red!10] \CYCLE\facePG ; % Left

  \draw[blue] foreach \XXX/\YYY in \EDGESBACK { (\XXX) -- (\YYY) } ; %

  \ifGREEN %
  \def\SCOLOR{green!50}
  \else %
  \def\SCOLOR{red!20}
  \fi %

  \fill[\SCOLOR,opacity=0.6] \CYCLE\facePA ; % Front
  \fill[red!20,opacity=0.8] \CYCLE\faceQA ; % Front Right
  \fill[\SCOLOR,opacity=0.8] \CYCLE\facePB ; % Right
  \fill[red!20,opacity=0.8] \CYCLE\facePC ; % Top Right
  \fill[red!20,opacity=0.8] \CYCLE\faceQB ; % Top

  \draw[blue] foreach \XXX/\YYY in \EDGESFRONT { (\XXX) -- (\YYY) } ; %

  %%%%%%%%

  \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}

    \ifNAMES

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

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

    \else % \ifNAMES

    %%%%%%%% show the coordinates

    %%%% kinda merging \LCOORDINATES \PLACES
    \path
    foreach \XXX/\place in \PLACES { %
      node[\place] (N\XXX) at (\XXX) {\phantom{0000}} } %
    foreach \XXX/\x/\y/\z/\t in \LCOORDINATES { %
      node at (N\XXX) {\x\y\z\t} } ; %

    \fi % \ifNAMES

  \end{scope}

  \fi % \ifLABELS

  \ifPARENS

  %%%% cf. cube-4-84.tex
  \tikzset{
    labelbox/.style={ %
      fill=white,fill opacity=0.6, %
      draw,text opacity=1, %
      inner sep=4/3pt}, %
  }

  % \def\Label#1{\scalebox{.5}{#1}}
  %% let's be bold, not boring
  \def\Label#1{\PARENfont#1}

  \path foreach \XXX/\x/\y/\z/\t/\P in \LCOORDINATES { %
    node[labelbox] at (\XXX) {\Label{\P}} } ; %

  \fi

  \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 281x331.

%% png creation (large size)

%%% pdflatex cube-3L.tex
%%% pdftocairo -png -singlefile -r 361.35 -W 876 -H 996 -x 1098 -y 481 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: %% 676x796+1198+581
%%%% 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.2-19 Q16-HDRI x86_64 23897 https://imagemagick.org
%%% OptiPNG version 0.7.7

%%%%%%%%

%%%% Created:
%%% 2026-03-08 % first version

%%%% Latest change of an image:
%%% 2026-03-10 % second version
%%% 2026-04-29 % minor changes
%%% 2026-05-02 % tiny change for small version

%%%% Latest code change:
%%% 2026-04-29 % draw edges only once
%%% 2026-05-02 % new macro \CYCLE

%%%%%%%%
