On Fri, 6 Mar 2009, Wolfgang Schuster wrote:


Am 06.03.2009 um 04:05 schrieb Aditya Mahajan:

My summary of this thread:
http://randomdeterminism.wordpress.com/2009/03/05/tex-programming-the-past-the-present-and-the-future/

Nice article but I have a few corrections for you.


Table setup:

To achieve horizontal and vertical centered content in the table cell
you need 'align={middle,lohi}'.

Hmm... align={middle,middle} also works. I haven't checked the code to see why.


Pure table code:

You forgot the \bTR and \eTR before and after each row.

Thanks.


Expandafter solution:

You don't need as many \expandafter as you did in your example,
one before \bTD in each loop is enough.

\bTABLE
\bTR
 \bTD $(+)$ \eTD
 \dorecurse{6}
  {\expandafter \bTD \recurselevel \eTD}
 \eTR
\dorecurse{6}
{\bTR
    \edef\firstrecurselevel{\recurselevel}
    \expandafter\bTD \recurselevel \eTD
 \dorecurse{6}
   {\expandafter
    \bTD
     \the\numexpr\firstrecurselevel+\recurselevel\relax
    \eTD}
 \eTR}
\eTABLE

Ah. I was experimenting without the \the\numexpr (replacing both by \relax) so that I could see the output. I did not realize that \numexpr expands its arguments anyways.

\for loop:

If you really want to show this loop you also the correct
commands to access the counters. #1 did also work but only
because the command is wrapped around \dostepwiserecurse.

\bTABLE
 \bTR
   \bTD $(+)$ \eTD
   \for \y=1 \to 6 \step 1 \do
     {\bTD \y \eTD}
 \eTR
 \for \x=1 \to 6 \step 1 \do
 {\bTR
    \bTD \x \eTD
   \for \y=1 \to 6 \step 1 \do
   {\bTD \the\numexpr\x+\y \eTD}
 \eTR}
\eTABLE

This does not work, for the same reason that the \dorecurse solution does not work. You need to exapnad \x and \y in the first row and first column.

Thank you for the article and I'm looking forward for the next.

Thanks for the feedback.

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 via email to