ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: "Peter Münster" <pmlists@free.fr>
Subject: Re: Feature request: Creating tables from (tab-separated) values
Date: Sat, 22 Apr 2006 20:02:45 +0200 (CEST)	[thread overview]
Message-ID: <Pine.LNX.4.58.0604221957290.30824@gaston.pm> (raw)
In-Reply-To: <6faad9f00604211902m5c88d10apcd5c208f1825f51c@mail.gmail.com>

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

\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 , :

\documentclass{article}
\usepackage{dcolumn}
\input{realcalc}% on CTAN
\newcommand*\cc[1]{\multicolumn{1}{c}{#1}}
\def\scanwert\ignorespaces#1\unskip{\gdef\WERT{#1}#1}
\begin{document}
\begin{tabular}{>{\scanwert}D{.}{,}{-1}%
        >{\Rmul\res\WERT{6.55957}\Radd\res\res{0.005}\Rtrunc\res2\res\res}%
        D{.}{,}{-1}}%
  \cc{Euro} & \cc{FF}\\\hline
  20.33     & \\
  20.3      & \\
  20        & \\
  14.46     &
\end{tabular}
\end{document}

Cheers, Peter

-- 
http://pmrb.free.fr/contact/

  reply	other threads:[~2006-04-22 18:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-22  2:02 Mojca Miklavec
2006-04-22 18:02 ` Peter Münster [this message]
2006-04-23 11:13   ` Mojca Miklavec
2006-04-23 16:31     ` Peter Münster
2006-04-23 17:15 ` Taco Hoekwater

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.58.0604221957290.30824@gaston.pm \
    --to=pmlists@free.fr \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).