%-------------------------------------------------------------------------------
\setupoutput [pdftex]

\setuppapersize [A4, landscape] [A4, landscape]
\setuplayout[
    topspace=1cm, 
    backspace=1cm, 
    width=27.7cm, 
    height=19.5cm, 
    header=0cm, 
    footer=1.5cm,
    top=0.7cm,
    topdistance=0.8cm
]

\setupbodyfont [sansserif, 10pt]

\setupcolors [state=start]
\definecolor [TableBackground] [r=0.91, g=0.93, b=0.96]
\definecolor [CouleurChapitre] [r=0.35, g=0.53, b=0.77]
\definecolor [CouleurSujet] [r=0.96, g=0.52, b=0.15]

\setupheads [sectionnumber=no]
\setuphead [chapter] [style=\bfc, color=CouleurChapitre]
\setuphead [subject] [style=\bfa, color=CouleurSujet]

\setupTABLE[frame=off, option=stretch]
\setupTABLE[row][first][topframe=on, bottomframe=on, background=color, backgroundcolor=TableBackground]
\setupTABLE[row][last][bottomframe=on]
\setupTABLE[column][first][align={right,lohi}, aligncharacter=no]
\setupTABLE[column][each][align={middle,lohi}, aligncharacter=yes, alignmentcharacter={;}]
% NOTE: character ';' is a workaround to mix numbers and percentages in the same column

%-------------------------------------------------------------------------------
\starttext

\chapter{A bug in character alignment?}

\subject{Table 1 - No problem: every numbers are aligned}

\bTABLE
    \setupTABLE[c][1][width=4.3cm]
    \setupTABLE[c][2,3,4,5,6,7][width=3.9cm]
    \bTR
        \bTH Responsable \eTH
        \bTH Nombre de cours \eTH
        \bTH Evolution en cours \crlf / année 2000 \eTH
        \bTH Revenu \eTH
        \bTH Evolution en revenu \crlf / année 2000 \eTH
        \bTH Revenu moyen par an \crlf par cour \eTH
        \bTH Evolution du revenu moyen \crlf / année 2000 \eTH
    \eTR
    \bTR
        \bTD Cacahuète \eTD
        \bTD 38 229 \eTD
        \bTD +8,3\% \eTD
        \bTD 387 930 k\$ \eTD
        \bTD +8,3\% \eTD
        \bTD 10,1 k\$ \eTD
        \bTD -0,0\% \eTD
    \eTR
    \bTR
        \bTD Choufleur Italie \eTD
        \bTD 29 616 \eTD
        \bTD +7,0\% \eTD
        \bTD 272 241 k\$ \eTD
        \bTD +0,7\% \eTD
        \bTD 9,2 k\$ \eTD
        \bTD -5,9\% \eTD
    \eTR
    \bTR[style=\bf,topframe=on]
        \bTD Total \eTD
        \bTD 60 129 \eTD
        \bTD +7,8\% \eTD
        \bTD 660 172 k\$ \eTD 
        \bTD +5,1\% \eTD
        \bTD 11,0 k\$ \eTD
        \bTD -2,5\% \eTD
    \eTR
\eTABLE

\subject{Table 2 - This table causes the bug! Comment this table to remove the bug...}

\bTABLE
    \setupTABLE[c][1,2,3][width=5cm]
    \bTR
        \bTH Responsable \eTH
        \bTH Evolution en cours \crlf / année 2000 \eTH
        \bTH Evolution en revenu \crlf / année 2000 \eTH
    \eTR
    \bTR
        \bTD Cacahuète \eTD
        \bTD -5,7\% \eTD
        \bTD +7,9\% \eTD
    \eTR
    \bTR
        \bTD Choufleur Italie \eTD
        \bTD +7,9\% \eTD
        \bTD -2,9\% \eTD
    \eTR
    \bTR[style=\bf,topframe=on]
        \bTD Total \eTD
        \bTD -0,4\% \eTD
        \bTD +3,1\% \eTD
    \eTR
\eTABLE

\subject{Table 3 - Numbers in column 4 are no more aligned}

\bTABLE
    \setupTABLE[c][1][width=2.1cm]
    \setupTABLE[c][2,3,5,6,7,8,9][width=3.1cm]
    \setupTABLE[c][4][width=3.9cm]
    \bTR
        \bTH Responsable \eTH 
        \bTH Nombre de cours \eTH
        \bTH Part \crlf des cours \eTH
        \bTH Evolution en cours \crlf / année 2000 \eTH
        \bTH Revenu \eTH
        \bTH Part du revenu \eTH
        \bTH Evolution en revenu \crlf / année 2000 \eTH
        \bTH Revenu moyen par cour \eTH
        \bTH Evolution du revenu moyen \crlf / année 2000 \eTH
    \eTR
        \bTR
            \bTD Chouette \eTD
            \bTD 35 184 \eTD 
            \bTD 58,5\% \eTD
            \bTD +7,5\% \eTD
            \bTD 619 778 k\$ \eTD 
            \bTD 93,9\% \eTD
            \bTD +5,9\% \eTD
            \bTD 17,6 k\$ \eTD    
            \bTD -1,5\% \eTD
        \eTR
        \bTR
            \bTD Hiboux \eTD
            \bTD 24 945 \eTD 
            \bTD 41,5\% \eTD
            \bTD +8,1\% \eTD
            \bTD 40 394 k\$ \eTD 
            \bTD 6,1\% \eTD
            \bTD -6,4\% \eTD
            \bTD 1,6 k\$ \eTD    
            \bTD -13,4\% \eTD
        \eTR
    \bTR[style=\bf,topframe=on]
        \bTD Total \eTD
        \bTD 60 129 \eTD 
        \bTD 100,0\% \eTD 
        \bTD +7,8\% \eTD
        \bTD 660 172 k\$ \eTD 
        \bTD 100,0\% \eTD
        \bTD +5,1\% \eTD
        \bTD 11,0 k\$ \eTD
        \bTD -2,5\% \eTD
    \eTR
\eTABLE

\subject{Table 4 - Numbers in column 4 are no more aligned}

\bTABLE[option=stretch]
    \setupTABLE[c][1][width=4.5cm]
    \setupTABLE[c][2,3,5,6,7,8,9][width=2.8cm]
    \setupTABLE[c][4][width=3.4cm]
    \bTR
        \bTH Responsable \eTH 
        \bTH Nombre \crlf de cours \eTH
        \bTH Part \crlf des cours \eTH
        \bTH Evolution en cours \crlf / année 2000 \eTH
        \bTH Revenu \eTH
        \bTH Part du revenu \eTH
        \bTH Evolution en revenu \crlf / année 2000 \eTH
        \bTH Revenu moyen \crlf par cour \eTH
        \bTH Evolution du revenu moyen \crlf / année 2000 \eTH
    \eTR
        \bTR
            \bTD Chouette -> Chouette \eTD
            \bTD 34 440 \eTD 
            \bTD 57,3\% \eTD
            \bTD +7,0\% \eTD
            \bTD 613 293 k\$ \eTD 
            \bTD 92,9\% \eTD 
            \bTD +5,4\% \eTD
            \bTD 17,8 k\$ \eTD    
            \bTD -1,5\% \eTD
        \eTR
        \bTR
            \bTD Hiboux -> Hiboux \eTD
            \bTD 20 926 \eTD 
            \bTD 34,8\% \eTD
            \bTD +9,0\% \eTD
            \bTD 29 647 k\$ \eTD 
            \bTD 4,5\% \eTD 
            \bTD +5,8\% \eTD
            \bTD 1,4 k\$ \eTD    
            \bTD -2,9\% \eTD
        \eTR
        \bTR
            \bTD Chouette -> Hiboux \eTD
            \bTD 3 856 \eTD 
            \bTD 6,4\% \eTD
            \bTD +1,3\% \eTD
            \bTD 10 395 k\$ \eTD 
            \bTD 1,6\% \eTD 
            \bTD -30,5\% \eTD
            \bTD 2,7 k\$ \eTD    
            \bTD -31,4\% \eTD
        \eTR
        \bTR
            \bTD Hiboux -> Chouette \eTD
            \bTD 720 \eTD 
            \bTD 1,2\% \eTD
            \bTD +38,2\% \eTD
            \bTD 6 372 k\$ \eTD 
            \bTD 1,0\% \eTD 
            \bTD +90,7\% \eTD
            \bTD 8,9 k\$ \eTD    
            \bTD +38,0\% \eTD
        \eTR
        \bTR
            \bTD Autre -> Hiboux \eTD
            \bTD 163 \eTD 
            \bTD 0,3\% \eTD
            \bTD +67,2\% \eTD
            \bTD 352 k\$ \eTD 
            \bTD 0,1\% \eTD 
            \bTD +10,7\% \eTD
            \bTD 2,2 k\$ \eTD    
            \bTD -21,1\% \eTD
        \eTR
        \bTR
            \bTD Autre -> Chouette \eTD
            \bTD 24 \eTD 
            \bTD 0,0\% \eTD
            \bTD +71,4\% \eTD
            \bTD 112 k\$ \eTD 
            \bTD 0,0\% \eTD 
            \bTD +15,2\% \eTD
            \bTD 4,7 k\$ \eTD    
            \bTD -32,8\% \eTD
        \eTR
    \bTR[style=\bf,topframe=on]
        \bTD Total \eTD
        \bTD 60 129 \eTD 
        \bTD 100,0\% \eTD 
        \bTD +7,8\% \eTD
        \bTD 660 172 k\$ \eTD 
        \bTD 100,0\% \eTD
        \bTD +5,1\% \eTD
        \bTD 11,0 k\$ \eTD
        \bTD -2,5\% \eTD
    \eTR
\eTABLE

\subject{Table 5 - Numbers in column 4 are no more aligned}

\bTABLE
    \setupTABLE[c][1][width=3cm]
    \setupTABLE[c][2,3,5,6,7,8][width=3.4cm]
    \setupTABLE[c][4][width=3.9cm]
    \bTR
        \bTH Responsable \eTH 
        \bTH Nombre de cours \eTH
        \bTH Part des cours \eTH
        \bTH Evolution en cours / année 2000 \eTH
        \bTH Revenu \eTH
        \bTH Part du revenu \eTH
        \bTH Evolution en revenu / année 2000 \eTH
        \bTH Revenu moyen par an par cour \eTH
    \eTR
        \bTR
            \bTD Centre \eTD 
            \bTD 9 940 \eTD
            \bTD 16,5\% \eTD
            \bTD +8,8\% \eTD
            \bTD 78 836 k\$ \eTD
            \bTD 11,9\% \eTD
            \bTD +4,5\% \eTD
            \bTD 7,9 k\$ \eTD
        \eTR
        \bTR
            \bTD Chef \eTD 
            \bTD 16 609 \eTD
            \bTD 27,6\% \eTD
            \bTD +7,0\% \eTD
            \bTD 208 113 k\$ \eTD
            \bTD 31,5\% \eTD
            \bTD +4,5\% \eTD
            \bTD 12,5 k\$ \eTD
        \eTR
        \bTR
            \bTD Haut \eTD 
            \bTD 8 547 \eTD
            \bTD 14,2\% \eTD
            \bTD +8,5\% \eTD
            \bTD 157 537 k\$ \eTD
            \bTD 23,9\% \eTD
            \bTD +5,2\% \eTD
            \bTD 18,4 k\$ \eTD
        \eTR
        \bTR
            \bTD Gauche \eTD 
            \bTD 7 535 \eTD
            \bTD 12,5\% \eTD
            \bTD +9,0\% \eTD
            \bTD 73 061 k\$ \eTD
            \bTD 11,1\% \eTD
            \bTD +5,3\% \eTD
            \bTD 9,7 k\$ \eTD
        \eTR
        \bTR
            \bTD Bas \eTD 
            \bTD 8 059 \eTD
            \bTD 13,4\% \eTD
            \bTD +8,2\% \eTD
            \bTD 72 623 k\$ \eTD
            \bTD 11,0\% \eTD
            \bTD +7,7\% \eTD
            \bTD 9,0 k\$ \eTD
        \eTR
        \bTR
            \bTD Droite \eTD 
            \bTD 7 023 \eTD
            \bTD 11,7\% \eTD
            \bTD +5,4\% \eTD
            \bTD 57 818 k\$ \eTD
            \bTD 8,8\% \eTD
            \bTD +2,5\% \eTD
            \bTD 8,2 k\$ \eTD
        \eTR
        \bTR
            \bTD Externe \eTD 
            \bTD 232 \eTD
            \bTD 0,4\% \eTD
            \bTD -0,9\% \eTD
            \bTD 716 k\$ \eTD
            \bTD 0,1\% \eTD
            \bTD +3,4\% \eTD
            \bTD 3,1 k\$ \eTD
        \eTR
        \bTR
            \bTD Voisinne \eTD 
            \bTD 2 101 \eTD
            \bTD 3,5\% \eTD
            \bTD +10,4\% \eTD
            \bTD 9 796 k\$ \eTD
            \bTD 1,5\% \eTD
            \bTD +15,9\% \eTD
            \bTD 4,7 k\$ \eTD
        \eTR
        \bTR
            \bTD Tête \eTD 
            \bTD 83 \eTD
            \bTD 0,1\% \eTD
            \bTD -2,4\% \eTD
            \bTD 1 672 k\$ \eTD
            \bTD 0,3\% \eTD
            \bTD +2,0\% \eTD
            \bTD 20,1 k\$ \eTD
        \eTR
    \bTR[style=\bf,topframe=on]
        \bTD Total \eTD
        \bTD 60 129 \eTD 
        \bTD 100,0\% \eTD 
        \bTD +7,8\% \eTD
        \bTD 660 172 k\$ \eTD 
        \bTD 100,0\% \eTD
        \bTD +5,1\% \eTD
        \bTD 11,0 k\$ \eTD
    \eTR
\eTABLE

\subject{Table 6 - Numbers in column 4 and 5 are no more aligned}

\bTABLE
    \setupTABLE[c][1][width=4.9cm]
    \setupTABLE[c][2][width=4.4cm]
    \setupTABLE[c][3,4,6,7,9,10][width=2.3cm]
    \bTABLEhead
    \bTR
        \bTH Produit \eTH 
        \bTH Responsable \eTH 
        \bTH Nb cours \eTH
        \bTH Part \crlf des cours \eTH
        \bTH Evolution en cours \crlf / année 2000 \eTH
        \bTH Revenu \eTH
        \bTH Part du revenu \eTH
        \bTH Evolution en revenu \crlf / année 2000 \eTH
        \bTH \% cumulé \crlf du revenu total \eTH
        \bTH Revenu moyen \crlf par cour \eTH
    \eTR
\eTABLEhead
\bTABLEbody
            \bTR
        \bTD Cacahuète Bateau \eTD
        \bTD[align={right,lohi}, aligncharacter=no] Cacahuète \eTD
        \bTD 22 258 \eTD
        \bTD 37,0\% \eTD
            \bTD +7,1\% \eTD
        \bTD 175 916 k\$ \eTD
        \bTD 26,6\% \eTD
            \bTD +7,3\% \eTD
        \bTD 26,6\% \eTD
            \bTD 7,9 k\$ \eTD
        \eTR
            \bTR
        \bTD Sardine Maison Parent \eTD
        \bTD[align={right,lohi}, aligncharacter=no] Choufleur Italie \eTD
        \bTD 27 269 \eTD
        \bTD 45,4\% \eTD
            \bTD +7,3\% \eTD
        \bTD 127 110 k\$ \eTD
        \bTD 19,3\% \eTD
            \bTD -2,0\% \eTD
        \bTD 45,9\% \eTD
            \bTD 4,7 k\$ \eTD
        \eTR
            \bTR
        \bTD Cacahuète Direct Bateau \eTD
        \bTD[align={right,lohi}, aligncharacter=no] Cacahuète \eTD
        \bTD 4 380 \eTD
        \bTD 7,3\% \eTD
            \bTD +80,0\% \eTD
        \bTD 68 367 k\$ \eTD
        \bTD 10,4\% \eTD
            \bTD +16,3\% \eTD
        \bTD 56,3\% \eTD
            \bTD 15,6 k\$ \eTD
        \eTR
            \bTR
        \bTD Sardine Ami Parent \eTD
        \bTD[align={right,lohi}, aligncharacter=no] Choufleur Italie \eTD
        \bTD 20 084 \eTD
        \bTD 33,4\% \eTD
            \bTD +1,6\% \eTD
        \bTD 65 770 k\$ \eTD
        \bTD 10,0\% \eTD
            \bTD +2,7\% \eTD
        \bTD 66,2\% \eTD
            \bTD 3,3 k\$ \eTD
        \eTR
            \bTR
        \bTD Sardine Maison Canapé \eTD
        \bTD[align={right,lohi}, aligncharacter=no] Choufleur Italie \eTD
        \bTD 2 606 \eTD
        \bTD 4,3\% \eTD
            \bTD +14,7\% \eTD
        \bTD 50 302 k\$ \eTD
        \bTD 7,6\% \eTD
            \bTD +7,5\% \eTD
        \bTD 73,8\% \eTD
            \bTD 19,3 k\$ \eTD
        \eTR
            \bTR[bottomframe=on]
        \bTD Cacahuète Brise \eTD
        \bTD[align={right,lohi}, aligncharacter=no] Cacahuète \eTD
        \bTD 11 \eTD
        \bTD 0,0\% \eTD
            \bTD +37,5\% \eTD
        \bTD 48 032 k\$ \eTD
        \bTD 7,3\% \eTD
            \bTD +30,3\% \eTD
        \bTD 81,1\% \eTD
            \bTD 4 366,5 k\$ \eTD
        \eTR
            \bTR
        \bTD Voiture Oups \eTD
        \bTD[align={right,lohi}, aligncharacter=no] Cacahuète \eTD
        \bTD 144 \eTD
        \bTD 0,2\% \eTD
            \bTD +32,1\% \eTD
        \bTD 25 265 k\$ \eTD
        \bTD 3,8\% \eTD
            \bTD -15,6\% \eTD
        \bTD 84,9\% \eTD
            \bTD 175,4 k\$ \eTD
        \eTR
            \bTR
        \bTD Sardine Maison Frange \eTD
        \bTD[align={right,lohi}, aligncharacter=no] Choufleur Italie \eTD
        \bTD 13 923 \eTD
        \bTD 23,2\% \eTD
            \bTD +0,3\% \eTD
        \bTD 23 318 k\$ \eTD
        \bTD 3,5\% \eTD
            \bTD -5,8\% \eTD
        \bTD 88,5\% \eTD
            \bTD 1,7 k\$ \eTD
        \eTR
            \bTR
        \bTD Fleur Porte \eTD
        \bTD[align={right,lohi}, aligncharacter=no] Cacahuète \eTD
        \bTD 6 909 \eTD
        \bTD 11,5\% \eTD
            \bTD -8,7\% \eTD
        \bTD 12 689 k\$ \eTD
        \bTD 1,9\% \eTD
            \bTD +6,6\% \eTD
        \bTD 90,4\% \eTD
            \bTD 1,8 k\$ \eTD
        \eTR
            \bTR
        \bTD Cacahuète Bateau Italie \eTD
        \bTD[align={right,lohi}, aligncharacter=no] Cacahuète \eTD
        \bTD 7 250 \eTD
        \bTD 12,1\% \eTD
            \bTD +16,1\% \eTD
        \bTD 8 140 k\$ \eTD
        \bTD 1,2\% \eTD
            \bTD +11,7\% \eTD
        \bTD 91,6\% \eTD
            \bTD 1,1 k\$ \eTD
        \eTR
    \bTR[style=\bf,topframe=on]
        \bTD Total \eTD
        \bTD \eTD
        \bTD 60 129 \eTD 
        \bTD NA \eTD 
        \bTD +7,8\% \eTD
        \bTD 660 172 k\$ \eTD 
        \bTD 100,0\% \eTD
        \bTD +5,1\% \eTD
        \bTD 100,0\% \eTD
        \bTD NA \eTD 
    \eTR
\eTABLEbody
\eTABLE

\subject{Table 7}

\bTABLE
    \bTR
        \bTH Produit \eTH 
        \bTH Nombre \crlf de cours \eTH
        \bTH Part \crlf des cours \eTH
        \bTH Evolution en cours \crlf / année 2000 \eTH
        \bTH Revenu \eTH
        \bTH Part du revenu \eTH
        \bTH Evolution en revenu \crlf / année 2000 \eTH
        \bTH \% cumulé \crlf du revenu total \eTH
        \bTH Revenu moyen \crlf par cour \crlf par produit \eTH
    \eTR
        \bTR
            \bTD Sardine Maison Parent \eTD 
            \bTD 27 269 \eTD        
            \bTD 92,1\% \eTD
                \bTD +7,3\% \eTD
            \bTD 127 110 k\$ \eTD
            \bTD 46,7\% \eTD
                \bTD -2,0\% \eTD
            \bTD 46,7\% \eTD
                \bTD 4,7 k\$ \eTD
        \eTR
        \bTR
            \bTD Sardine Ami Parent \eTD 
            \bTD 20 084 \eTD        
            \bTD 67,8\% \eTD
                \bTD +1,6\% \eTD
            \bTD 65 770 k\$ \eTD
            \bTD 24,2\% \eTD
                \bTD +2,7\% \eTD
            \bTD 70,8\% \eTD
                \bTD 3,3 k\$ \eTD
        \eTR
        \bTR
            \bTD Sardine Maison Canapé \eTD 
            \bTD 2 606 \eTD        
            \bTD 8,8\% \eTD
                \bTD +14,7\% \eTD
            \bTD 50 302 k\$ \eTD
            \bTD 18,5\% \eTD
                \bTD +7,5\% \eTD
            \bTD 89,3\% \eTD
                \bTD 19,3 k\$ \eTD
        \eTR
        \bTR
            \bTD Sardine Maison Frange \eTD 
            \bTD 13 923 \eTD        
            \bTD 47,0\% \eTD
                \bTD +0,3\% \eTD
            \bTD 23 318 k\$ \eTD
            \bTD 8,6\% \eTD
                \bTD -5,8\% \eTD
            \bTD 97,9\% \eTD
                \bTD 1,7 k\$ \eTD
        \eTR
        \bTR
            \bTD Sardine Canapé Ami \eTD 
            \bTD 379 \eTD        
            \bTD 1,3\% \eTD
                \bTD +95,4\% \eTD
            \bTD 2 414 k\$ \eTD
            \bTD 0,9\% \eTD
                \bTD +75,5\% \eTD
            \bTD 98,8\% \eTD
                \bTD 6,4 k\$ \eTD
        \eTR
        \bTR
            \bTD Arbre Souple Maison \eTD 
            \bTD 1 321 \eTD        
            \bTD 4,5\% \eTD
                \bTD -12,1\% \eTD
            \bTD 2 198 k\$ \eTD
            \bTD 0,8\% \eTD
                \bTD -11,0\% \eTD
            \bTD 99,6\% \eTD
                \bTD 1,7 k\$ \eTD
        \eTR
        \bTR
            \bTD Filet Profond \eTD 
            \bTD 871 \eTD        
            \bTD 2,9\% \eTD
                \bTD -9,6\% \eTD
            \bTD 553 k\$ \eTD
            \bTD 0,2\% \eTD
                \bTD -15,2\% \eTD
            \bTD 99,8\% \eTD
                \bTD 0,6 k\$ \eTD
        \eTR
        \bTR
            \bTD Arbre Souple Voisin \eTD 
            \bTD 298 \eTD        
            \bTD 1,0\% \eTD
                \bTD -10,2\% \eTD
            \bTD 392 k\$ \eTD
            \bTD 0,1\% \eTD
                \bTD +6,0\% \eTD
            \bTD 99,9\% \eTD
                \bTD 1,3 k\$ \eTD
        \eTR
        \bTR
            \bTD Sardine Ami Frange \eTD 
            \bTD 637 \eTD        
            \bTD 2,2\% \eTD
                \bTD +29,2\% \eTD
            \bTD 184 k\$ \eTD
            \bTD 0,1\% \eTD
                \bTD +43,9\% \eTD
            \bTD 100,0\% \eTD
                \bTD 0,3 k\$ \eTD
        \eTR
        \bTR
            \bTD Bloc Profond \eTD 
            \bTD 2 \eTD        
            \bTD 0,0\% \eTD
                \bTD -80,0\% \eTD
            \bTD 1 k\$ \eTD
            \bTD 0,0\% \eTD
                \bTD -61,1\% \eTD
            \bTD 100,0\% \eTD
                \bTD 0,5 k\$ \eTD
        \eTR
    \bTR[style=\bf,topframe=on]
        \bTD Total \eTD
        \bTD 29 616 \eTD
        \bTD NA \eTD
        \bTD +7,0\% \eTD
        \bTD 272 241 k\$ \eTD 
        \bTD 100,0\% \eTD
        \bTD +0,7\% \eTD
        \bTD 100,0\% \eTD        
        \bTD NA \eTD 
    \eTR
\eTABLE

\stoptext
