I am writing a booklet for use by junior doctors at the hospital where
I work. It will contain random bits of data that is available from
various online sources such as phone numbers, dosages of exotic drugs,
referral routes and assorted things better written down than
remembered. Much of it is in tabular form, and I have so far used
natural tables. It is intended to be extremely compact so I make many
adjustments to save space, such as using multiple columns where
appropriate.

Some of the things listed would benefit from being sorted such as
phone numbers, but I would still like it to be presented in a table
(with the added complication that the table will have two columns of
names}. Using pseudocode I would like it to work like this:

\phone{person c}{54321, 12345}
\phone{clinic a}{12345, 54321}
\phone{clinic c}{54321, 12345}
\phone{person b}{12345}
\phone{clinic b}{12345}
\phone{person a}{12345}

This should automatically be converted to

\bTABLE
\bTR\bTD person a\eTD\bTD 12345\eTD\bTD clinic a\eTD\bTD 12345, 54321\eTD\eTR
\bTR\bTD person b\eTD\bTD 12345\eTD\bTD clinic b\eTD\bTD 12345\eTD\eTR
\bTR\bTD person c\eTD\bTD 54321, 12345\eTD\bTD clinic c\eTD\bTD 54321,
12345\eTD\eTR
\eTABLE

presumably using something like

1. name and number added to a register
2. register is sorted on first field
3. t = total number of entries in register
4. l = number of lines in table, calculated as l=t\2 + t mod 2
3. create a table with l lines where each line has
  \bTR\bTD name(i) \eTD\bTD phone(i)\eTD\bTD name(i+l)\eTD\bTD phone(i+l)\eTR

It would not surprise me if this is implemented somewhere in ConTeXt
but I have been unable to find it. I would be very happy to see a
solution using lua, but I lack the knowledge to implement it myself.

Regards, Johan

-- 
Johan Sandblom, MD PhD
m +46735521477  Sweden
"What is wanted is not the will to believe, but the
will to find out, which is the exact opposite"
- Bertrand Russell
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to