ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Aditya Mahajan <adityam@umich.edu>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Repeat (*) key in TaBlE
Date: Thu, 25 Oct 2007 00:47:39 -0400 (EDT)	[thread overview]
Message-ID: <alpine.WNT.0.9999.0710250037540.3692@nqvgln> (raw)
In-Reply-To: <alpine.WNT.0.9999.0710241402490.668@nqvgln>

On Wed, 24 Oct 2007, Aditya Mahajan wrote:

> Restarting an old thread ...
>
> On Wed, 6 Jun 2007, Aditya Mahajan wrote:
>
>> What is the correct way of using * key with TaBlE? The following does not work
>>
>> \starttext
>>
>> \starttable[|*{2}l|]
>
> This should be [*{2}{l|}] but even then it does not work.
>
>>   \HL
>>   \NC A \NC B \NC \NR
>>   \HL
>> \stoptable
>> \starttable[|l|l|]
>>   \HL
>>   \NC A \NC B \NC \NR
>>   \HL
>> \stoptable
>>
>> \stoptext
>
> I finally found out why this is not working. \getTABLEnofcolumns does
> not expand *. For example
>
> This works fine.
> \getTABLEnofcolumns{|l|l|}
> \the\maxTABLEcolumn % gives 2.
>
> This does not.
> \getTABLEnofcolumns{|*{2}{l|}}
> \the\maxTABLEcolumn %gives 1
>
> \getTABLEnoofcolumns is simply counting the number of | in the format.
> It should first expand the *#1#2, and then do the counting. A really
> ugly workaround
>
> \starttable[|*{2}{l|}]
>   % Manually set the number of columns :-(
>   \noalign{\global\maxTABLEcolumn=2}
>   \NC AA  \NC 5 \NC \AR
>   \NC AAA \NC 6 \NC \AR
> \stoptable
>
> I do not understand TeX well enough to correct the
> \get\TABLEnofcolumns macro.

Here is another solution. We first need a fully expandable \dorecurse 
macro. I copied David Kastrup's replicate from TeX pearls
http://www-stary.gust.org.pl/pearls/2005/david-kastrup/bachotex2005-david-kastrup-pearl3.pdf

This works as expected.

\def\replicate#1#2{\ifnum#1>0 #2%
   \expandafter\replicate\expandafter{\number\numexpr#1-1}{#2}\fi}

\starttable[|\replicate{2}{l|}]
   \NC AA  \NC 5 \NC \AR
   \NC AAA \NC 6 \NC \AR
\stoptable

Questions:

1. Is there something equivalent to replicate in ConTeXt. 
(\dorecuse is not expandable)? If not, should it be added?

2. Are there any plans to ensure that the * form works? I am happy 
with the above solution, but I am curious from the purpose of 
documentation. I am writing about some the advanced features of 
\starttable. If the * version will not be supported, I can just say 
that the replicate trick is the correct way to do things.

3. BTW, there are other things that do not work with \starttable. All 
the keys of TaBlE that start with \ do not work (\LeftGlue, 
\RightGlue, \{, \|), as they are tried to be expanded, and result in 
a undefined control sequence error. One solution is to pad 
each of them with \noexpand. Are there plans to work on this, or 
should I just say (in the tugboat article) that the \noexpand is the 
correct way to do things.

Aditya
___________________________________________________________________________________
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	other threads:[~2007-10-25  4:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-06 22:38 Aditya Mahajan
2007-10-24 18:09 ` Aditya Mahajan
2007-10-25  4:47   ` Aditya Mahajan [this message]

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=alpine.WNT.0.9999.0710250037540.3692@nqvgln \
    --to=adityam@umich.edu \
    --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).