Hi, What is the correct way of using * key with TaBlE? The following does not work \starttext \starttable[|*{2}l|] \HL \NC A \NC B \NC \NR \HL \stoptable \starttable[|l|l|] \HL \NC A \NC B \NC \NR \HL \stoptable \stoptext Thanks, Aditya
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. Aditya
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-ka... 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
participants (1)
-
Aditya Mahajan