On Sun, 8 Mar 2009, Wolfgang Schuster wrote:
Hi Hans,
natural tables are perfect to create tables with a fixed size for the cells but the syntax requires sometimes a lot of typing for small content and takes to many lines of code in the document.
I wrote a while ago a simple wrapper to use a table/tabulate like syntax for the input, what I don't like is to load a extra module for just a few lines of code and I think they can be integrated in the core-ntb code.
Only yesterday I went over my old mails to search for this and hoped that it would be available as a module :) Just a few comments.
%D \module %D [ file=wolf-tab, %D version=2007.01.26, %D title=\CONTEXT\ User Module, %D subtitle=New Tables, %D author=Wolfgang Schuster, %D date=\currentdate, %D copyright=Wolfgang Schuster]
\writestatus{loading}{Context User Module / New Tables}
\unprotect
%D This module provides an easy way to use natural in a similiar %D way as the older table module (based on the \TABLE\ macros) and %D the newer tabulate module. %D %D You can see the advantage in the following table, once created %D with the new macros and once with the normal macros provided %D with the natural table module. %D %D Let us start with the original macros: %D %D \starttyping %D \bTABLE %D \bTR %D \bTD Text 1 \eTD %D \bTD Text 2 \eTD %D \eTR %D \bTR %D \bTD Text 3 \eTD %D \bTD Text 4 \eTD %D \eTR %D \eTABLE %D \stoptyping %D %D and now with my new macros: %D %D \starttyping %D \startTABLE %D \NC Text 1 \NC Text 2 \NC\NR %D \NC Text 3 \NC Text 4 \NC\NR %D \stopTABLE %D \stoptyping
\def\startTABLE {\dosingleempty\dostartTABLE}
\def\dostartTABLE[#1]% {\bgroup \def\NC{\parseNC} \bTABLE[#1]}
\def\stopTABLE {\eTABLE \egroup}
\def\parseNC#1\NR {\bTR \processNC#1\stopNC\NC}
To avoid potential conflicts, can you name \parseNC as \paseTABLENC, \processNC as \processTABLENC, and \stopNC as \stopTABLENC.
\def\stopNC{\stopNC}
\def\processNC#1\NC% {\def\temp{#1}%
How about \currentTABLEcell instead of \temp?
\ifx\temp\stopNC \eTR \else \bTD#1\eTD% \expandafter\processNC \fi}
% shorter but did not work when external files are loaded in the table, % e.g. \bTD \input knuth \eTD. % %\def\parseNC#1\NC\NR % {\bTR % \processseparatedlist[#1][\NC]\processNC % \eTR} % %\def\processNC#1% % {\bTD#1\eTD}
%D I used the same mechanism as in \type{core-ntb.tex} to allow different %D headers on the first and the following pages. The only changes ist that %D I renamed the commands from \tex{bTABLE...} to \tex{startTABLE...} and %D from \tex{eTABLE...} to \tex{stopTABLE...} to match the start and stop %D pair at begin and end of the table.
\long\def\startTABLEhead{\dosingleempty\dostartTABLEhead} \long\def\startTABLEnext{\dosingleempty\dostartTABLEnext} \long\def\startTABLEbody{\dosingleempty\dostartTABLEbody} \long\def\startTABLEfoot{\dosingleempty\dostartTABLEfoot}
\long\def\dostartTABLEhead[#1]#2\stopTABLEhead{\appendtoks\doTABLEsection[#1]{#2}\to\TBLhead} \long\def\dostartTABLEnext[#1]#2\stopTABLEnext{\appendtoks\doTABLEsection[#1]{#2}\to\TBLnext} \long\def\dostartTABLEbody[#1]#2\stopTABLEbody{\appendtoks\doTABLEsection[#1]{#2}\to\TBLbody} \long\def\dostartTABLEfoot[#1]#2\stopTABLEfoot{\appendtoks\doTABLEsection[#1]{#2}\to\TBLfoot}
%D \startbuffer %D \startTABLE %D \NC Text 1 \NC Text 2 \NC\NR %D \NC Text 3 \NC Text 4 \NC\NR %D \stopTABLE %D \stopbuffer %D %D My example from the begin of this module %D %D \typebuffer %D %D looks like this: %D %D \startlinecorrection %D \getbuffer %D \stoplinecorrection
\protect \endinput
Thanks, Aditya