ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Simplified input for natural tables
@ 2009-03-08 15:24 Wolfgang Schuster
  2009-03-08 16:34 ` Aditya Mahajan
  0 siblings, 1 reply; 17+ messages in thread
From: Wolfgang Schuster @ 2009-03-08 15:24 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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.

Wolfgang



%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}

\def\stopNC{\stopNC}

\def\processNC#1\NC%
   {\def\temp{#1}%
    \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

___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 17+ messages in thread
* Re: Simplified input for natural tables
@ 2009-03-12 17:14 Vyatcheslav Yatskovsky
  2009-03-12 18:05 ` Wolfgang Schuster
  0 siblings, 1 reply; 17+ messages in thread
From: Vyatcheslav Yatskovsky @ 2009-03-12 17:14 UTC (permalink / raw)
  To: hraban, ntg-context

Hello Hraban,

Simplified table syntax is much appreciated! Thank you for 
http://wiki.contextgarden.net/wikitable.

However, I cannot understand how to use it. :)

Best,
Vyatcheslav
___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 17+ messages in thread
[parent not found: <mailman.19.1236882597.12697.ntg-context@ntg.nl>]

end of thread, other threads:[~2009-03-13 22:13 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-08 15:24 Simplified input for natural tables Wolfgang Schuster
2009-03-08 16:34 ` Aditya Mahajan
2009-03-08 16:58   ` Hans Hagen
2009-03-08 18:03     ` John Devereux
2009-03-08 18:36       ` Hans Hagen
2009-03-08 19:10         ` John Devereux
2009-03-09 13:35           ` George N. White III
2009-03-12 10:57             ` Henning Hraban Ramm
2009-03-09 12:15       ` Mojca Miklavec
2009-03-08 19:26     ` Wolfgang Schuster
2009-03-08 19:50       ` Hans Hagen
2009-03-12 17:14 Vyatcheslav Yatskovsky
2009-03-12 18:05 ` Wolfgang Schuster
     [not found] <mailman.19.1236882597.12697.ntg-context@ntg.nl>
2009-03-12 19:51 ` Vyatcheslav Yatskovsky
2009-03-12 20:06   ` Aditya Mahajan
2009-03-12 20:19     ` Wolfgang Schuster
2009-03-13 22:13     ` Mohamed Bana

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).