%% -*- tex-command: "./.tex-command.bash"; -*-
%% (setq tex-command "pdflatex")

\documentclass{amsart}
%% \documentclass{article}

%%%%%

\usepackage{input/tamari-diagram}

%% \usepackage{tikz}
%% \usetikzlibrary{calc} %% coordinate calculations: $(\XXX)!0.55!(\YYY)$
%% \usetikzlibrary{arrows.meta} %% arrow tips 'Latex', 'Straight Barb'
%% %% \show\next : \pgfrcs@final {pgflibraryarrows.meta.code.tex}
%% \let\next\undefined

%%%%%

\begin{document}

\thispagestyle{empty} % for png trim

%% -*- mode: latex; -*- input file begin

%% include this file with
% \centerline{\vbox{\input{tamari-diagram}}}

%%%%%

\def\TYPEOUT#1{}
%% uncomment to print some dimensions
% \let\TYPEOUT\typeout

\newif\ifRULES
%% uncomment to show baseline and borders of the extra boxes
% \RULEStrue

%%%%%

%% \typeout{\the\hsize}
%%% 345.0pt article / 360.0pt amsart / 469.755pt plain
%% \hsize will be the natural width:
%%% 429.1994pt (total width of \extrabox 4)

%% \setbox0\vbox{\input{input/tamari-diagram}} %
%% \typeout{page dimensions: \the\wd0 \space \the\ht0 \space \the\dp0} %
%%% page dimensions: 429.1994pt 300.95107pt 2.22223pt
%% width = \hsize
%% height 300.95107pt = tt-height + 27*\baselineskip = 6.11111pt+27*10.92pt
%% depth 2.22223pt stems from "g" in "Fig. 1"

%%%%%

%% The basic layout is a normal TeX text in font \tt with tikz
%% graphics in smashed boxes.  All dimensions are given in pt (in
%% tikz, "pt" is written even when not necessary).

%%%%%

%% \tt dimensions

% \setbox0\hbox{\tt X} %
% \setbox0\hbox{\tt 123456789 } %
% \setbox0\hbox{\tt 123456789 123456789 123456789 123456789 } %
%% \typeout{TT X: \the\wd0 \space \the\ht0 \space \the\dp0} %

%%% TT X: 5.24995pt 6.11111pt 0.0pt
%%% TT10: 52.49954pt 6.11111pt 0.0pt
%%% TT40: 209.99817pt 6.11111pt 0.0pt
%%% TT x: 5.24995pt 4.30554pt 0.0pt
%%% TT g: 5.24995pt 4.30554pt 2.22223pt
%%% TT ): 5.24995pt 6.94444pt 0.8333pt
%% latex tt section sign \S : \font\ts=tctt1000 {\ts \char167}
%%% TT\S: 5.24872pt 6.10962pt 2.22168pt

%%%% 5.25pt=21/4pt % \tt width (monospacing)
%%%% 6.11111pt=55/9pt % \tt height (uppercase, digits)

%%%% x-height: \fontdimen5\tensy 4.30554pt.

%%%% parens are vertically centered at capital letters:
%%%% 0.8333pt = 2.5/3pt
%%%% 6.94444pt = 0.8333pt + 6.11111pt

%%%%%

%% the \tt layout

\def\TTEN{5.25pt} % \tt letter width, \tt \enspace
% \newdimen\tten % defines globally, use a less simple name
% \newlength{\TMttenskip} % in preamble
\let\tten\TMttenskip %
\tten=\TTEN

\let\bs\baselineskip % abbrev % normal value: 12.0pt
% \bs=10.92pt % crucial value, a guess from the original jpg
%% set below

%%%%%

%% \extrabox is a right shifted smashed box with internal down shift
%% placed at the reference point of the previous line, basically like
%% this:

%% \long\def\extrabox#1#2#3{ %
%%   \vskip-\baselineskip % go up to previous line
%%   \setbox0\hbox{#3}
%%   \moveright #1 \hbox{\smash{\lower #2 \box0}}
%% }
%% \extrabox{97.125pt}{52.6pt}{...}

%% If placed between lines with normal interline glue (\lineskiplimit
%% does not interfere), the rest is formatted as if it were not
%% present.

%% The actual macro \extrabox gives finer control.  The shifts are
%% specified by sequences of kerns which eases additions.  It adjusts
%% \hsize.

%% assumes \parindent=0pt so that a box of width \hsize fits

%% arg 1 is used only in messages and meant as a name

%% args 2 (3) are for \hskip (\vskip) material

\long\def\extrabox#1 | #2|#3|#4{ %
  \setbox0\hbox{#4} %
  \TYPEOUT{extra box #1: \the\wd0 \space \the\ht0 \space \the\dp0} %
  \setbox0\hbox{#2% beware of empty #2
    \vbox to 0pt{#3 %

      \ifRULES
      \setbox1\vbox{ %
        %% the rules are centered, like from a \draw
        \setbox1\vbox to 0pt{\vss \hrule width \wd0 \vss} %
        \copy1 % baseline
        \nointerlineskip %
        \vbox to 0pt{\vss \copy1 \vskip\ht0} % top
        \nointerlineskip %
        \vbox to 0pt{\vskip\dp0 \box1 \vss} % bottom
        \nointerlineskip %
        \setbox1\hbox to 0pt{\hss \vrule height \ht0 depth \dp0 \hss} %
        \ht1=0pt \dp1=0pt \copy1 % left border
        \nointerlineskip %
        \hbox to 0pt{\hskip\wd0 \box1 \hss} % right border
      } %

      \ht0=0pt \dp0=0pt % smash
      \box0 %
      \unvbox1 %

      \else

      \ht0=0pt % \dp0=0pt % smash (\dp0 eaten by \vss)
      \box0 %

      \fi
      \vss}% don't add horizontal space
  }
  \TYPEOUT{extra box #1 complete: \the\wd0 \space \the\ht0 \space \the\dp0} %
  \ifdim\hsize<\wd0\hsize=\wd0\fi % adjust \hsize
  \vskip-\baselineskip % go up to previous line
  \unhbox0 %
}

%%% usages:
%% \extrabox top line | | | {...} %
%% \extrabox 1-2-3 | \hskip18.5\tten | \vskip5\bs \vskip-2pt \RULESfalse | {...} %
%% \extrabox 1 | \hskip18.5\tten | \vskip5\bs \vskip-2pt | {...} %
%% \extrabox 2 | \hskip19.5\tten | \vskip8\bs \vskip3pt | {...} %
%% \extrabox 3 | \hskip23.5\tten | \vskip14\bs \vskip3pt | {...} %
%% \extrabox 4 | \hskip58\tten | \vskip4\bs \vskip-1pt | {...} %

%%% all skips could be \kern, but \hskip/\vskip are better readable

%%%%%

\ifRULES
%% supersedes #1 in \ARROWX \BULLETX
\tikzset{every path/.style={color=red,draw=blue,fill=green}} %
%% useful, but extends some boxes
% \tikzset{every node/.style={draw=magenta,draw opacity=0.75}} %
\fi

%%%%%

\tikzset{
  color pentagon/.style={red!25,opacity=0.6}, % extrabox 3,4
  color background/.style={blue!20,opacity=.15}, % extrabox 4
  dots gray/.style={dotted,gray}, % extrabox 3,4
  dashedC/.style={dashed,#1!75}, % colored dashed % extrabox 4
  dashedC/.value required, %
}

%%%%%

%% arrow tip Latex dimensions

%% \setbox0\hbox{%
%%   \begin{tikzpicture} [baseline=0]
%%     %% sep=-0.2pt ... -4.5pt
%%     \draw[arrows={-Latex[sep=-1pt]}] (0,0) -- (0.00001pt,0) ; %
%% \end{tikzpicture}}
%% \typeout{tip Latex: \the\wd0 \space \the\ht0 \space \the\dp0}
%%% tip Latex: 4.79997pt 1.79999pt 1.79999pt
%%% tip Latex: 4.8pt 1.8pt 1.8pt % rounded

%%%%%

%% arrow paths are split at the tip to get more coherent dashes and
%% dots

%% arrow tip Latex forward leaning
\tikzset{LatexF/.tip={Latex[sep=-4pt]}} %
%%% dashes on the continuing path start out nicely

%%% arrows are reversed with tip in the middle
\def\ARROW#1#2{
  \coordinate (M) at ($(#1)!1/2!(#2)$) ; %
  \draw[-LatexF] (#2) -- (M) ; %
  \draw (M) -- (#1) ; %
}
\def\ARROWX[#1]#2#3{
  \begin{scope} [#1] \ARROW{#2}{#3} \end{scope}}

%%%%%

\def\BULLET#1{
  \filldraw (#1) circle (1.2pt) ; %
}
\def\BULLETX[#1]#2{
  \begin{scope} [#1] \BULLET{#2} \end{scope}}

%%%%%

%%% \ARROW, \ARROWX, \BULLET, \BULLETX apparently don't need a
%%% trailing ";" by themselves (in most cases, however, there is a
%%% preceding \foreach which needs to be closed)

%%% these cool versions need a trailing ";"
%% \def\ARROWX[#1]{\scoped[#1] \ARROW}
%% \def\BULLETX[#1]{\scoped[#1] \BULLET}

%%%%%

%% arrow line width for \tt
\def\TTthick{semithick} % 0.6pt
%% default thickness: thin = TeX rule width 0.4pt

%%% \overharpoon is build like TeX \overline
%% removing the \draw options results in
% \def\overharpoon#1{$\tt \overline{#1}$}

\def\overharpoon#1{%
  \vbox{ %
    \setbox0\hbox{#1}
    \hbox{%
      \begin{tikzpicture} [trim left,trim right=0]
        % \draw % imitates \overline
        \draw[\TTthick,arrows={-Straight Barb[harpoon]}]
        (0,0) -- (\the\wd0,0) ; %
      \end{tikzpicture}%
    }
    \nointerlineskip %
    \vskip1.2pt % clearance as in \overline
    \box0 %
  }%
}

%%% straightforward right arrow for monospaced \tt
% \def\TTto{\hbox to 3\tten{\hss$\to$\hss}}

%% arrow length 2\tten, with padding 3\tten
%% note: math axis \fontdimen22\tensy = 2.5pt
\def\TTto{\hbox to 3\tten{% 15.75pt
    \hss
    \begin{tikzpicture} [baseline=-2.5pt] % vcenter
      \draw[\TTthick,-Straight Barb] (0,0) -- (2*\TTEN,0) ; % 10.5pt
    \end{tikzpicture}%
    \hss}%
}

%%%%%

\def\TTsubscript#1{\lower 3.5pt\hbox{#1}}
%% in math mode like
% \def\TTsubscript#1{_{\lower2pt\hbox{#1}}\kern-\scriptspace}
%% it means to replace \fontdimen16\tensy 1.5pt by 3.5pt
%% then x-height and \fontdimen19\tensy 0.5pt play no role
%% no \hskip\scriptspace 0.5pt as for $_{}$ to keep monospacing
% \setbox0\hbox{$_{}$} %
%% \typeout{$_{}$: \the\wd0 \space \the\ht0 \space \the\dp0} %
%%% $_{}$: 0.5pt 0.0pt 1.49998pt

%%%%%

%% more dimensions

% \setbox0\hbox{$\mathcal M$} %
% \setbox0\hbox{$\TMfont M$} % scaled 1100
% \setbox0\hbox{$\TMfontL M$} % scaled 1400
%% \typeout{TMfontL M: \the\wd0 \space \the\ht0 \space \the\dp0} %
%%% mathcal M: 12.00899pt 6.83331pt 0.0pt
%%% TMfont  M: 13.20996pt 7.5167pt 0.0pt
%%% TMfontL M: 16.81252pt 9.5666pt 0.0pt

% ratio of font scalings: 14/11 = 1.2727272727 (approx. 5/4)

% \pgfkeysgetvalue{/pgf/inner xsep}{\innerXsep} %
% \pgfkeysgetvalue{/pgf/inner ysep}{\innerYsep} %
%% \typeout{inner seps: \innerXsep \space \innerYsep} %
%%% inner seps: .3333em .3333em
%%%% \tt .3333em = (21/2pt)/3 = 3.5pt

% \pgfkeysgetvalue{/pgf/outer xsep}{\outerXsep} %
% \pgfkeysgetvalue{/pgf/outer ysep}{\outerYsep} %
%% \tikz{\typeout{outer seps: \outerXsep \outerYsep \string\pgflinewidth=\the\pgflinewidth}} %
%%% outer seps: .5\pgflinewidth .5\pgflinewidth \pgflinewidth=0.4pt

%%%%%

\def\TMCaption#1{${\TMfont M}_{\hbox{#1}}$}
\def\TMCaptionL#1{${\TMfontL M}_{\hbox{#1}}$}

\def\TMclear{8pt} % clearance below the line
\def\showTMCaption#1#2#3{
  %% outer ysep=0.2pt accounts for the line
  %% trims at the bottom
  \node[anchor=north,inner ysep=0,yshift=-\TMclear] at ($(#1)!1/2!(#2)$) %
       {\TMCaption#3} ; }

%% multiply by ratio 14:11 of font scalings: 14/11*8pt = 10.181818pt
%% account for the other label {1201}: \tt digit height: 55/9pt
%% assumes same outer/inner ysep, no trimming at the bottom
\def\showTMCaptionL#1#2{
  \node[anchor=north,yshift=-55/9pt-14/11*\TMclear] at (#1) %
       {\TMCaptionL#2} ; }

%%%%%

%% dimensions of a circle

%%% the square box defined by a circle has size 2*radius+\pgflinewidth

%% \setbox0\hbox{%
%%   \begin{tikzpicture} [baseline=0]
%%     \filldraw (0,0) circle (0pt) ; %
%%     \filldraw (0,0) circle (0.3pt) ; % \dottedbox
%%     \filldraw (0,0) circle (1.2pt) ; % \BULLET
%% \end{tikzpicture}}
%% \typeout{circle box: \the\wd0 \space \the\ht0 \space \the\dp0}
%%% circle box: 0.4pt 0.2pt 0.2pt % radius 0pt
%%% circle box: 1.0pt 0.5pt 0.5pt % radius 0.3pt
%%% circle box: 2.79999pt 1.4pt 1.4pt % radius 1.2pt

%%%%%

%% the dotted box

%% \dottedbox has natural height but width 0

\def\dottedbox{%
  \begin{tikzpicture} [trim left,trim right=0,baseline=-55/18pt]
    % \tikzset{every path/.style={draw=yellow}} % show the fill
    \filldraw[x=2.8125pt,y=2.8125pt,radius=0.3pt]
    foreach \x in {0,28} { foreach \y in {-4,...,4} { (\x,\y) circle[] }} %
    foreach \y in {-4,4} { foreach \x in {1,...,27} { (\x,\y) circle[] }} ; %
  \end{tikzpicture}%
}

%%%%% long version:

%%%%% \def\dottedbox{%
%%%%%
%%%%%   %%%% the dotted box
%%%%%
%%%%%   %%% like \draw[thick,dotted], but with explicit dots to get exact
%%%%%   %%% corners and symmetric dotting
%%%%%
%%%%%   %% the dots are vertically centered (like parens) at
%%%%%   %%% 1/2 height of \tt X = 55/18pt = 3.055555pt
%%%%%   \begin{tikzpicture} [trim left,trim right=0,baseline=-55/18pt]
%%%%%
%%%%%     \def\Nx{28} % 29 horizontal dots with distance \dx
%%%%%     % \def\Ny{8} % 9 vertical dots with distance \dy
%%%%%     %% fortunately \Ny is even
%%%%%     \def\My{4} % \Ny = 2*\My
%%%%%
%%%%%     %%% \draw[thick,dotted] : \dx = 2.8pt
%%%%%     %% the content has width 15\tten (15=6+3+6)
%%%%%     %% 15 * 21/4 / \Nx = 45/16 = 2.8125
%%%%%     \def\dx{2.8125pt} %
%%%%%     \let\dy\dx %
%%%%%
%%%%%     % \draw[thick,dotted] (0,\My*\dy) -- (\Nx*\dx,\My*\dy) -- (\Nx*\dx,-\My*\dy) -- (0,-\My*\dy) -- cycle ; %
%%%%%
%%%%%     \def\DotSize{0.3pt} % like \draw[thick,dotted]
%%%%%     % \def\DotSize{0.4pt} % like {\tt .}
%%%%%
%%%%%     \def\DrawDot##1##2{\filldraw (##1*\dx,##2*\dy) circle (\DotSize)} %
%%%%%     %% like with \DotSize{0.4pt} but get somewhat irregular distances
%%%%%     % \def\DrawDot#1#2{\node at (#1*\dx,#2*\dy) {.}} %
%%%%%
%%%%%     \foreach \x in {0,\Nx} %
%%%%%     \foreach \y in {-\My,...,\My} %
%%%%%     \DrawDot\x\y ; %
%%%%%
%%%%%     \foreach \x [parse=true] in {1,...,\Nx-1} %
%%%%%     \foreach \y in {-\My,\My} %
%%%%%     \DrawDot\x\y ; %
%%%%%
%%%%%   \end{tikzpicture}%
%%%%%
%%%%% }

%%%%%% main body %%%%%%

\tt %

\bs=10.92pt % \baselineskip

\parindent=0pt % don't prepend space

%% ? is space
\catcode`\?=\active %
\let?\ %

%%%%%%

%% the top line is very long, handle it with \extrabox

\vphantom{X}% a box with the same height as the top line

\hsize=0pt %

\extrabox top line | | | {%
  \hskip33\tten %
  -?\S
  ?1?-%
  \hskip30\tten %
  -?12?-%
}

%%%%%%

%% '11' in \extrabox 2 is aligned with 'A0' in \extrabox 1

%% extrabox 3 is "half-aligned" with extrabox 1,2

%% there is no intended alignment with extrabox 4

\ifRULES %
\extrabox 1-2-3 | \hskip18.5\tten | \vskip5\bs \vskip-2pt \RULESfalse | {%
  \begin{tikzpicture} [trim left,baseline=0]
    \draw[cyan!50] %
    %% \tt height = 55/9pt
    %%% extrabox 1-2
    %% (5*\bs-2pt) - (8*\bs+3pt)
    foreach \X in {0,1,2,16,17,18}
    { (\X*\TTEN,55/9pt) -- (\X*\TTEN,-3*\bs-5pt) } %
    %%% extrabox 1--3
    %% (5*\bs-2pt) - (14*\bs+3pt)
    foreach \X in {4,5,6}
    { (\X*\TTEN,55/9pt) -- (\X*\TTEN,-9*\bs-5pt) } %
    ; %
  \end{tikzpicture}%
}
\fi %

%%%%%%

\extrabox 1 | \hskip18.5\tten | \vskip5\bs \vskip-2pt | {%

  \overharpoon{A0}\TTsubscript{2}%

  ?:?%

  \dottedbox

  %% fill \dottedbox with the content
  ?a(bc)\TTto(ab)c?%

} %

%%%%%%

%%% identical result but for the bounding box
%% \extrabox 2 | \hskip18.5\tten | \vskip8\bs \vskip3pt | {%
%%   \begin{tikzpicture} [baseline=(11),inner xsep=0]
\extrabox 2 | \hskip19.5\tten | \vskip8\bs \vskip3pt | {%
  \begin{tikzpicture} [trim left,trim right=(20),baseline=(11)]

    \coordinate (11) at (0,0) ; %
    \coordinate (20) at (16*\TTEN,0) ; %

    \ARROWX[green]{11}{20} ; %

    \BULLET{11} ; %
    \BULLET{20} ; %

    %%%% the 'n' in the original seems to be a typo
    \node[anchor=south] at (11) {11} ; %
    \node[anchor=south] at (20) {20} ; %

    \showTMCaption{11}{20}{2} %

  \end{tikzpicture}%
}

%%%%%%

\extrabox 3 | \hskip23.5\tten | \vskip14\bs \vskip3pt | {%
  \begin{tikzpicture} [trim left,baseline=(201)]

    \coordinate (201) at (0,0) ; %

    \coordinate (300) at (-11*\TTEN,-37pt) ; %
    \coordinate (210) at (-7*\TTEN,-107pt) ; %

    \coordinate (111) at ([xscale=-1] 300) ; %
    \coordinate (120) at ([xscale=-1] 210) ; %

    %%%%

    \fill[color pentagon] %
    (201) -- (300) -- (210) -- (120) -- (111) -- cycle ; %

    %%%%

    \foreach \XXX/\YYY in {% no spaces in empty list
      111/201, 201/300, 120/210} %
    \ARROWX[red]{\XXX}{\YYY} ; %

    \foreach \XXX/\YYY in {%
      111/120} %
    \ARROWX[green]{\XXX}{\YYY} ; %

    \foreach \XXX/\YYY in {%
      210/300} %
    \ARROWX[dots gray]{\XXX}{\YYY} ; %

    %%%%

    \foreach \XXX in {%
      201, 300, 210, 111, 120} %
    \BULLET{\XXX} ; %

    %%%%

    \node[anchor=south] at (201) {201} ; %
    \node[anchor=east] at (300) {300} ; %
    \node[anchor=east] at (210) {210} ; %
    \node[anchor=west] at (111) {111} ; %
    \node[anchor=west] at (120) {120} ; %

    \showTMCaption{120}{210}{3} %

  \end{tikzpicture}%
}

%%%%%%

\extrabox 4 | \hskip58\tten | \vskip4\bs \vskip-1pt | {%
  \begin{tikzpicture} [trim left,baseline=(3010)]

    %%%% unadjusted coordinates and parenthesis expressions are from
    %%% https://commons.wikimedia.org/wiki/File:Associahedron_K5_back.svg#Tikz_Source
    %%%% comments from that file:
    % node numbering is from Tamari's thesis
    % parenthesization is reversed
    % https://www.math.wustl.edu/~escobar/pdf/Olivetti2015.pdf

    \begin{scope} [x=6.25pt,y=5.08pt] % try to get close to the original

      \coordinate (3010) at (0,20) ; % a((bc)(de))
      \coordinate (4000) at (0,15) ; % a(b(c(de)))

      \coordinate (3001) at (-5.5,5) ; % (ab)(c(de))
      \coordinate (3100) at ([xscale=-1] 3001) ; % a(b((cd)e))

      \coordinate (2101) at (0,-5) ; % (ab)((cd)e)
      \coordinate (1201) at (0,-19) ; % ((ab)(cd))e

      % \coordinate (2020) at (-11.5,12) ; % (a(bc))(de)
      \coordinate (2020) at (-11.5 + 0.5,12) ; % (a(bc))(de)
      \coordinate (2011) at (-16,1) ; % ((ab)c)(de)
      \coordinate (1120) at (-7.3,-1.6) ; % ((a(bc))d)e
      % \coordinate (1111) at (-12,-11) ; % (((ab)c)d)e
      \coordinate (1111) at (-12,-11 - 1) ; % (((ab)c)d)e

      \coordinate (2110) at ([xscale=-1] 2020) ; % a(((bc)d)e)
      \coordinate (2200) at ([xscale=-1] 2011) ; % a((b(cd))e)
      \coordinate (1210) at ([xscale=-1] 1120) ; % (a((bc)d)))e
      \coordinate (1300) at ([xscale=-1] 1111) ; % (a(b(cd)))e

    \end{scope}

    %%%%%%%%

    \fill[color background] %
    (3010) -- (2020) -- (2011) -- (1111) -- (1120) -- %
    (1210) -- (1300) -- (2200) -- (3100) -- (4000) -- cycle ; %

    %%%%

    %% lower pentagon

    \fill[color pentagon] %
    (1201) -- (1300) -- (1210) -- (1120) -- (1111) -- cycle ; %

    \foreach \XXX/\YYY in {%
      %% border edges
      1111/1201, 1201/1300} %
    \ARROWX[red]{\XXX}{\YYY} ; %

    \foreach \XXX/\YYY in {%
      %% front edges - now back
      1120/1210} %
    \ARROWX[dashedC=red]{\XXX}{\YYY} ; %

    \foreach \XXX/\YYY in {%
      %% front edges - now back
      1111/1120} %
    \ARROWX[dashedC=green]{\XXX}{\YYY} ; %

    \foreach \XXX/\YYY in {%
      %% front edges - now back
      1210/1300} %
    \ARROWX[dashedC=gray]{\XXX}{\YYY} ; %

    %% homotopy

    \foreach \XXX/\YYY in {%
      %% front edges - now back
      1120/2020, 1210/2110} %
    \ARROWX[dashedC=blue]{\XXX}{\YYY} ; %

    \foreach \XXX/\YYY in {%
      %% back edges - now front
      3001/4000, 2011/3001, 2101/3100, 1201/2101, %
      %% border edges
      2020/3010, 1111/2011, 1300/2200} %
    \ARROWX[blue]{\XXX}{\YYY} ; %

    %% non-homotopy

    \foreach \XXX/\YYY in {%
      %% back edges - now front
      2101/3001, %
      %% border edges
      2011/2020} %
    \ARROWX[dots gray]{\XXX}{\YYY} ; %

    %% upper pentagon

    \fill[color pentagon] %
    (3010) -- (2110) -- (2200) -- (3100) -- (4000) -- cycle ; %

    \foreach \XXX/\YYY in {%
      %% back edges - now front
      3010/4000, 3100/4000, 2200/3100, %
      %% border edges
      2110/3010, 2110/2200} %
    \ARROWX[dots gray]{\XXX}{\YYY} ; %

    %%%%%%%%

    \foreach \XXX in {%
      %% back - now front
      4000, 3001, 3100, 2101, %
      %% border
      3010, %
      2020, 2011, 1111, %
      2110, 2200, 1300, %
      1201} %
    \BULLET{\XXX} ; %

    \foreach \XXX in {%
      %% front - now back
      1120, 1210} %
    \BULLETX[gray]{\XXX} ; %

    %%%%%%%%

    \node[anchor=south] at (3010) {3010} ; %
    \node[anchor=west,yshift=.5pt] at (4000) {4000} ; %

    \node[anchor=west,xshift=2pt] (3001L) at (3001) {3001} ; %
    \node at ([xscale=-1] 3001L) {3100} ; %

    \node[anchor=south east,xshift=4pt] (2020L) at (2020) {2020} ; %
    \node at ([xscale=-1] 2020L) {2110} ; %
    \node[anchor=north east,xshift=4pt] (1111L) at (1111) {1111} ; %
    \node at ([xscale=-1] 1111L) {1300} ; %

    \node[anchor=east] (2011L) at (2011) {2011} ; %
    % \node at ([xscale=-1] 2011L) {2200} ; %
    %%%% trim right (this is the right border of the whole page)
    %% \pgfkeysgetvalue{/pgf/inner xsep}{\innerXsep} % 3.5pt
    %% \node[anchor=west,inner xsep=0,xshift=\innerXsep] at (2200) {2200} ; %
    %%% simple solution using location (2011L)
    \node[inner xsep=0] at ([xscale=-1] 2011L) {2200} ; %

    %%%% unsymmetric placements as in the original
    \node[anchor=north west,xshift=-4pt] at (1120) {1120} ; %
    \node[anchor=west] at (1210) {1210} ; %

    \node[anchor=north west,yshift=4pt] at (2101) {2101} ; %
    \node[anchor=north] at (1201) {1201} ; %

    %%%%

    \showTMCaptionL{1201}{4} %

  \end{tikzpicture}%
}

%%%%%%

\leavevmode % empty line

???1- ab

??11- a(bc)

??20- (ab)c

?111- a(b(cd))

?120- a((bc)d)

?201- (ab)(cd)

?210- (a(bc))d

?300- ((ab)c)d

1111-a(b(c(de)))

1120-a(b((cd)e))

1201-a((bc)(de))

2011-(ab)(c(de))

2020-(ab)((cd)e)

.?.?.?.?.?.?.?.

\vskip11\bs

\hskip36.5\tten %
\hskip-1pt %
Fig.?1

%%%% input file end

\end{document}
