[NTG-context] Feature request: Creating tables from (tab-separated) values

Mojca Miklavec mojca.miklavec.lists at gmail.com
Sun Apr 23 13:13:05 CEST 2006


On 4/22/06, Peter Münster wrote:
> On Sat, 22 Apr 2006, Mojca Miklavec wrote:
>
> > - [with luaTeX in mind] calculating sums of rows & columns & other
> > Excel-like calculations & references accross tables ;) - well, that
> > one wasn't meant seriously.
>
> Hello Mojca,
> should be possible even without luaTeX:
>
> \input realcalc % can be found on CTAN

Thanks for the pointer! I've never used this one so far.

> \def\SumFF{0}
> \def\SumEUR{0}
>
> \def\AddEUR#1{\Radd\SumEUR\SumEUR{#1}%
>   \Rmul\R{#1}{6.55957}\Radd\R\R{0.005}\Rtrunc\R2\R
>   \Radd\SumFF\SumFF\R \bTR \bTD\eTD \bTD#1\eTD \expanded{\bTD\R\eTD} \eTR}
>
> \def\PrintSums{\bTR \bTD Sums: \eTD
>   \bTD\Rtrunc\SumEUR2\SumEUR \SumEUR\eTD
>   \bTD\Rtrunc\SumFF2\SumFF   \SumFF \eTD \eTR}
>
> \starttext
> \setupTABLE[r][each][align=flushright]
> \setupTABLE[r][1][align=middle]
> \bTABLE
> \bTR \bTH\eTH \bTH Euro \eTH \bTH FF \eTH \eTR
> \AddEUR{1.23}
> \AddEUR{2.34}
> \AddEUR{45.67}
> \PrintSums
> \eTABLE
> \stoptext
>
> With LaTeX, you can even replace the . by a , :

Stupid me! I forgot about the following trick
    \uccode`.=`,
    \WORD{3.14}

(It can be surely done without using \WORD, but that was the easiest
way to recall it from another evil example that Hans sent me some time
ago.)

Mojca


More information about the ntg-context mailing list