[NTG-context] Split numbers in natural tables

Hans Hagen pragma at wxs.nl
Fri Aug 21 18:43:07 CEST 2015


On 8/21/2015 4:52 PM, Xan wrote:
> Hi,
>
> I have a simple script in mako templates which generate this table:

\starttext

\def\whatever#1{\processtokens{}{\allowbreak}{}{}{#1}}
\hsize2em \tt \whatever{12345}

\stoptext

Alan will reveal better alternatives at the upcoming ctx meeting.

> \starttext
> \bTABLE[align={lohi,middle}]
>
>   \bTR
>     \bTD[width=2.8cm, height=2.8cm] 1 \eTD
>   \eTR
>
>     \bTD[width=2.8cm, height=2.8cm] 2 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 4 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 8 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 16 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 32 \eTD
>
>   \bTR
>     \bTD[width=2.8cm, height=2.8cm] 64 \eTD
>   \eTR
>
>     \bTD[width=2.8cm, height=2.8cm] 128 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 256 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 512 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 1024 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 2048 \eTD
>
>   \bTR
>     \bTD[width=2.8cm, height=2.8cm] 4096 \eTD
>   \eTR
>
>     \bTD[width=2.8cm, height=2.8cm] 8192 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 16384 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 32768 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 65536 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 131072 \eTD
>
>   \bTR
>     \bTD[width=2.8cm, height=2.8cm] 262144 \eTD
>   \eTR
>
>     \bTD[width=2.8cm, height=2.8cm] 524288 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 1048576 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 2097152 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 4194304 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 8388608 \eTD
>
>   \bTR
>     \bTD[width=2.8cm, height=2.8cm] 16777216 \eTD
>   \eTR
>
>     \bTD[width=2.8cm, height=2.8cm] 33554432 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 67108864 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 134217728 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 268435456 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 536870912 \eTD
>
>   \bTR
>     \bTD[width=2.8cm, height=2.8cm] 1073741824 \eTD
>   \eTR
>
>     \bTD[width=2.8cm, height=2.8cm] 2147483648 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 4294967296 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 8589934592 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 17179869184 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 34359738368 \eTD
>
>   \bTR
>     \bTD[width=2.8cm, height=2.8cm] 68719476736 \eTD
>   \eTR
>
>     \bTD[width=2.8cm, height=2.8cm] 137438953472 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 274877906944 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 549755813888 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 1099511627776 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 2199023255552 \eTD
>
>   \bTR
>     \bTD[width=2.8cm, height=2.8cm] 4398046511104 \eTD
>   \eTR
>
>     \bTD[width=2.8cm, height=2.8cm] 8796093022208 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 17592186044416 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 35184372088832 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 70368744177664 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 140737488355328 \eTD
>
>   \bTR
>     \bTD[width=2.8cm, height=2.8cm] 281474976710656 \eTD
>   \eTR
>
>     \bTD[width=2.8cm, height=2.8cm] 562949953421312 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 1125899906842624 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 2251799813685248 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 4503599627370496 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 9007199254740992 \eTD
>
>   \bTR
>     \bTD[width=2.8cm, height=2.8cm] 18014398509481984 \eTD
>   \eTR
>
>     \bTD[width=2.8cm, height=2.8cm] 36028797018963968 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 72057594037927936 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 144115188075855872 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 288230376151711744 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 576460752303423488 \eTD
>
>   \bTR
>     \bTD[width=2.8cm, height=2.8cm] 1152921504606846976 \eTD
>   \eTR
>
>     \bTD[width=2.8cm, height=2.8cm] 2305843009213693952 \eTD
>
>     \bTD[width=2.8cm, height=2.8cm] 4611686018427387904 \eTD
>
>
> \eTABLE
> \stoptext
>
>
>
> How can I do for, automatically, split the number in the cells? That is, I want the numbers to fit all the cell size, not matter what return carriages it needs.
>
> So some thing like   \bTD[width=2.8cm, height=2.8cm] 4611686018427387904 \eTD  would be transformed into:
>
>     \bTD[width=2.8cm, height=2.8cm] 4611
>
> 686018427
>
> 387904 \eTD
>
> or something similar.
>
>
> Thanks,
> Xan
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context at ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
>


-- 

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------


More information about the ntg-context mailing list