Re: [NTG-context] right item marks for associative questions?

2022-04-11 Thread śrīrāma via ntg-context
On 4/12/22 12:16 AM Damien Thiriet via ntg-context wrote:
> Hi!
> 
> I am used to giving associative questions to my pupils,
> something like
> 
> * connect the author with its ideas
> 
> Friedrich Nietzsche *  * "God is dead"
> Woody Allen *  * "Nietzsche is dead, God is dead 
>   and I don't feel so good"
> God *  * "Nietzsche is dead"
> 
> I design it as a two-cells xtable with itemized lists inside.
> How can I have the item mark on the right side?

If you are certain that the there will be no multi-line item (i.e. item text is 
short enough that it fits in slightly less than half of textwidth) you can use 
an enumeration, and put the contents inside a two-column layout:

%%% start example-1
  \define[1]\aitemcmd{\inframed[width=1cm,align=flushright,frame=off]{(#1)}}
  \defineenumeration
[aitem]
  \setupenumeration
[aitem]
[text=,
alternative=empty,
headstyle=normal,
width=fit,
align=flushright,
closesymbol={\getnumber[aitem]},
closecommand=\aitemcmd]

  \starttext
  \startcolumns[distance=1cm]
  \startitemize[n]
  \dorecurse{5}{
\startaitem
  whatever left
\stopaitem
  }
  \stopitemize

  \startitemize[a][left=(,right=),stopper=,width=1cm]
  \dorecurse{5}{
\startitem
  whatever right
\stopitem
  }
  \stopitemize
  \stopcolumns
  \stoptext
%%% stop example-1

[You can tweak the alternative, align, closesymbol, closecommand to get exactly 
what you want; the example above will give a somewhat symmetric layout]

More generally, if the text can multi-line, then I think TABLE (with proper 
alignment options) might be better-suited:

%%% start example-2
  \define\startItemize{
\bTABLE\setupTABLE[frame=on,align=lohi]
\setupTABLE[2][distance=1cm,align={flushright,lohi}]
\setupTABLE[2,3][width=0.05\textwidth]
\setupTABLE[1][align=flushright,width=0.4\textwidth]
\setupTABLE[4][align=flushleft,width=0.4\textwidth]
  }
  \define\stopItemize{\eTABLE}
  \define[1]\metI{\bTR \bTD #1 \eTD \bTD (\character{\currentTABLErow}) \eTD}
  \define[1]\Item{\bTD (\currentTABLErow) \eTD \bTD #1 \eTD  \eTR}

  \starttext
  \startItemize
  \dorecurse{5}{
  \metI {whatever here on the left}
  \Item {whatever here on the right}
  }
  \stopItemize
  \stoptext
%%% stop example-2

Best,
  Sreeram


___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Strange behaviour of TABLE with \currentTABLErow

2018-12-10 Thread Tomas Hala
Hi Wolfgang, 

thank you for your reply. 

The split=repeat -- my fault, sorry. But -- surprisingly -- this mistake
helped me along understanding the problem. I discovered -- if head
and next head are defined -- that the "line number 1" servers for the
opening head at the beginning of a table whereas "line number 2" 
is used for all "next heads" at all pages of the table. 

So the problem is reduced to substracting one or two for only heads
and head+next heads, respectively.

Best wishes,

Tomáš 

P. S.
One possible solution can be e.g.:

\newcount\myrow
\def\currentTABLEbodyrow{\def\takenumber##1{\myrow=##1\advance\myrow-2 
\the\myrow}\takenumber\currentTABLErow}



The number of rows is now determined by the number of all rows
# (including header and footer) and the counting starts also from the first
# row in the table independent of the type of the row.



Mon, Dec 03, 2018 ve 11:14:53PM +0100 Wolfgang Schuster napsal(a):
# Tomas Hala schrieb am 03.12.18 um 20:23:
# >Hi all,
# >
# >at https://wiki.contextgarden.net/Command/currentTABLEcolumn I learnt
# >about \currentTABLErow etc. for counting lines in natural tables.
# >
# >I have got the following two minimal non-working examples (on TeXlive 2018):
# >
# >\starttext\setupTABLE[split=yes]
# >   \bTABLE
# >   \bTABLEhead\bTR\bTH head  \eTH\eTR\eTABLEhead
# >   \bTABLEbody
# > \dorecurse{100}{\bTR\bTD \currentTABLErow xxx \eTD\eTR}
# >   \eTABLEbody
# >   \eTABLE
# >\stoptext
# >
# >In this case, the head-line is alse counted which makes no sense
# >and I do not know how to supress it.
# Even though this is not what you expect it makes sense because when ConTeXt
# creates the table the whole thing is only one huge part which the
# headers for
# the first and the following pages on top and the footer on the bottom.
# 
# The number of rows is now determined by the number of all rows
# (including header and footer) and the counting starts also from the first
# row in the table independent of the type of the row.
# 
# What you want is a counter which removes the header row from the value
# but to keep backwards compatibility this has to be a new command,
# e.g. \currentTABLEbodyrow
# >If I add \bTABLEnext (below), I receive very strange result -- both heads
# >are at the beginning of the table and both counted. Moreover, the "next"
# >head is not used on the following pages.
# >
# >\starttext\setupTABLE[split=yes]
# >   \bTABLE
# >   \bTABLEhead\bTR\bTH head  \eTH\eTR\eTABLEhead
# >   \bTABLEnext\bTR\bTH next head \eTH\eTR\eTABLEnext
# >   \bTABLEbody
# > \dorecurse{100}{\bTR\bTD \currentTABLErow xxx \eTD\eTR}
# >   \eTABLEbody
# >   \eTABLE
# >\stoptext
# >
# >I tried \TC and \TD instead of \TH, also without success.
# >What I am doing wrong?
# You need split=repeat.
# 
# The normal command to create a cell is \bTD, the \bTH command
# is usefull for the header because it changes the font style to bold
# and it also disables the character alignment for the current cell.
# 
# Wolfgang

 Tomáš Hála

Mendelova univerzita, Provozně ekonomická fakulta, ústav informatiky
Zemědělská 1, CZ-613 00 Brno,  tel. +420 545 13 22 28

http://akela.mendelu.cz/~thala
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

Re: [NTG-context] Strange behaviour of TABLE with \currentTABLErow

2018-12-03 Thread Wolfgang Schuster

Tomas Hala schrieb am 03.12.18 um 20:23:

Hi all,

at https://wiki.contextgarden.net/Command/currentTABLEcolumn I learnt
about \currentTABLErow etc. for counting lines in natural tables.

I have got the following two minimal non-working examples (on TeXlive 2018):

\starttext\setupTABLE[split=yes]
   \bTABLE
   \bTABLEhead\bTR\bTH head  \eTH\eTR\eTABLEhead
   \bTABLEbody
 \dorecurse{100}{\bTR\bTD \currentTABLErow xxx \eTD\eTR}
   \eTABLEbody
   \eTABLE
\stoptext

In this case, the head-line is alse counted which makes no sense
and I do not know how to supress it.

Even though this is not what you expect it makes sense because when ConTeXt
creates the table the whole thing is only one huge part which the 
headers for

the first and the following pages on top and the footer on the bottom.

The number of rows is now determined by the number of all rows
(including header and footer) and the counting starts also from the first
row in the table independent of the type of the row.

What you want is a counter which removes the header row from the value
but to keep backwards compatibility this has to be a new command,
e.g. \currentTABLEbodyrow

If I add \bTABLEnext (below), I receive very strange result -- both heads
are at the beginning of the table and both counted. Moreover, the "next"
head is not used on the following pages.

\starttext\setupTABLE[split=yes]
   \bTABLE
   \bTABLEhead\bTR\bTH head  \eTH\eTR\eTABLEhead
   \bTABLEnext\bTR\bTH next head \eTH\eTR\eTABLEnext
   \bTABLEbody
 \dorecurse{100}{\bTR\bTD \currentTABLErow xxx \eTD\eTR}
   \eTABLEbody
   \eTABLE
\stoptext

I tried \TC and \TD instead of \TH, also without success.
What I am doing wrong?

You need split=repeat.

The normal command to create a cell is \bTD, the \bTH command
is usefull for the header because it changes the font style to bold
and it also disables the character alignment for the current cell.

Wolfgang

___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

[NTG-context] Strange behaviour of TABLE with \currentTABLErow

2018-12-03 Thread Tomas Hala
Hi all,

at https://wiki.contextgarden.net/Command/currentTABLEcolumn I learnt
about \currentTABLErow etc. for counting lines in natural tables.

I have got the following two minimal non-working examples (on TeXlive 2018):

\starttext\setupTABLE[split=yes]
  \bTABLE
  \bTABLEhead\bTR\bTH head  \eTH\eTR\eTABLEhead
  \bTABLEbody
\dorecurse{100}{\bTR\bTD \currentTABLErow xxx \eTD\eTR}
  \eTABLEbody
  \eTABLE
\stoptext

In this case, the head-line is alse counted which makes no sense
and I do not know how to supress it.

If I add \bTABLEnext (below), I receive very strange result -- both heads
are at the beginning of the table and both counted. Moreover, the "next"
head is not used on the following pages.

\starttext\setupTABLE[split=yes]
  \bTABLE
  \bTABLEhead\bTR\bTH head  \eTH\eTR\eTABLEhead
  \bTABLEnext\bTR\bTH next head \eTH\eTR\eTABLEnext
  \bTABLEbody
\dorecurse{100}{\bTR\bTD \currentTABLErow xxx \eTD\eTR}
  \eTABLEbody
  \eTABLE
\stoptext

I tried \TC and \TD instead of \TH, also without success. 
What I am doing wrong?  
Thanks in advance for help.

Best wishes,

Tomáš

___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

[NTG-context] \bTD\numexpr\currentTABLErow\minusone\relax\eTD

2013-04-19 Thread Alan BRASLAU
Hello,

I naively tried using
\bTD\numexpr\currentTABLErow\minusone\relax\dTD
in a TABLE.

As I do not master even simple calculations under TeX, I do not see
what I am missing in order to label TABLE rows, starting from 0?


(Row 1 is a heading, set off by \bTABLEhead\eTABLEhead, which is why I
am looking to subtract 1 from \currentTABLErow, but this does not
matter of course.

But perhaps the addressing of TABLE rows, including within \setupTABLE,
should or could handle this situation? This is a secondary question to
think about...)

Alan
___
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  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] \bTD\numexpr\currentTABLErow\minusone\relax\eTD

2013-04-19 Thread Marco Patzer
On 2013–04–19 Alan BRASLAU wrote:

   \bTD\numexpr\currentTABLErow\minusone\relax\dTD

  \bTD\the\numexpr\currentTABLErow-1\relax\eTD


Marco


signature.asc
Description: Digital signature
___
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  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

Re: [NTG-context] \dorecurse within TABLE

2012-10-26 Thread Marco Patzer
2012-10-26 Alan BRASLAU:

 Now, is there some better way, or perhaps not, around creating my own
 counter (of course, I can use a counter for the column as well...)

You can use \currentTABLEcolumn and \currentTABLErow

\starttext
\bTABLE
  \dorecurse{8}{
\bTR
\dorecurse{5}{\bTD \currentTABLErow,\currentTABLEcolumn \eTD} \eTR }
  \eTABLE
\stoptext


Marco

___
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  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Setting options for every n-th row in natural TABLEs

2012-09-05 Thread Procházka Lukáš Ing . - Pontex s . r . o .

... Thanks Hans for implementation and Sietse for wikifying.

BTW: Wouldn't be better to enclose ConText source on wiki into context mode=mkiv 
source=yes rather than texcode even if the source doesn't compile due to 
wiki-ConTeXt oldness?

I believe one day the wiki-ConTeXt engine will be updated and so all examples with the 
current result (context error, something is wrong with the input) will work.

Otherwise, inside texcode element, the result will never appear, which seems 
to me to be pity...

Best regards,

Lukas


On Tue, 04 Sep 2012 19:33:20 +0200, Sietse Brouwer sbbrou...@gmail.com wrote:


http://wiki.contextgarden.net/Command/currentTABLErow
http://wiki.contextgarden.net/Command/currentTABLEcolumn
http://wiki.contextgarden.net/Command/nofTABLErows
http://wiki.contextgarden.net/Command/nofTABLEcolumns

A bit of cutting, a bit of pasting ... the six-year-old in me is happy. :-)

--Sietse



--
Ing. Lukáš Procházka [mailto:l...@pontex.cz]
Pontex s. r. o.  [mailto:pon...@pontex.cz] [http://www.pontex.cz]
Bezová 1658
147 14 Praha 4

Tel: +420 244 062 238
Fax: +420 244 461 038

___
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  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Setting options for every n-th row in natural TABLEs

2012-09-04 Thread Hans Hagen

On 2-9-2012 20:58, Wolfgang Schuster wrote:


Am 02.09.2012 um 17:59 schrieb Aditya Mahajan adit...@umich.edu:


Hi,

On Edward Tufte's website, there is a discussion on zebra coloring in 
tables[1]. One of the suggestion is to add a horizontal rule after every third 
line or shade three lines with one background color and the remaining three 
with another background color.

Is there an easy way to do this with natural TABLEs? I can do something like:

\setupTABLE[row][1,2,3][background=color, backgroundcolor=gray]
\setupTABLE[row][7,8,9][background=color, backgroundcolor=gray]

but it requires knowing the number of lines in advance.

Aditya

[1]: http://www.edwardtufte.com/bboard/q-and-a-fetch-msg?msg_id=0001IV


Natural tables have “odd” and “even” keywords for \setupTABLE but none in the 
way you like it. What I would do is to use a overlay in combination with 
metapost to create the background but there is no global register to access the 
current column/row of a cell, e.g. \currenttablecolumn (this name is already 
used by tables) and \currenttablerow.


I've added 4 status macros:

\starttext

\bTABLE
\bTR
\bTD 
(\currentTABLErow,\currentTABLEcolumn,\nofTABLErows,\nofTABLEcolumns) \eTD
\bTD 
(\currentTABLErow,\currentTABLEcolumn,\nofTABLErows,\nofTABLEcolumns) \eTD
\bTD 
(\currentTABLErow,\currentTABLEcolumn,\nofTABLErows,\nofTABLEcolumns) \eTD
\bTD 
(\currentTABLErow,\currentTABLEcolumn,\nofTABLErows,\nofTABLEcolumns) \eTD

\eTR
\bTR
\bTD 
(\currentTABLErow,\currentTABLEcolumn,\nofTABLErows,\nofTABLEcolumns) \eTD
\bTD 
(\currentTABLErow,\currentTABLEcolumn,\nofTABLErows,\nofTABLEcolumns) \eTD
\bTD 
(\currentTABLErow,\currentTABLEcolumn,\nofTABLErows,\nofTABLEcolumns) \eTD
\bTD 
(\currentTABLErow,\currentTABLEcolumn,\nofTABLErows,\nofTABLEcolumns) \eTD

\eTR
\eTABLE

\stoptext


-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
 | www.pragma-pod.nl
-
___
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  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Setting options for every n-th row in natural TABLEs

2012-09-04 Thread Aditya Mahajan

On Tue, 4 Sep 2012, Hans Hagen wrote:


I've added 4 status macros:

\starttext

\bTABLE
   \bTR
   \bTD 
(\currentTABLErow,\currentTABLEcolumn,\nofTABLErows,\nofTABLEcolumns) \eTD
   \bTD 
(\currentTABLErow,\currentTABLEcolumn,\nofTABLErows,\nofTABLEcolumns) \eTD
   \bTD 
(\currentTABLErow,\currentTABLEcolumn,\nofTABLErows,\nofTABLEcolumns) \eTD
   \bTD 
(\currentTABLErow,\currentTABLEcolumn,\nofTABLErows,\nofTABLEcolumns) \eTD

   \eTR
   \bTR
   \bTD 
(\currentTABLErow,\currentTABLEcolumn,\nofTABLErows,\nofTABLEcolumns) \eTD
   \bTD 
(\currentTABLErow,\currentTABLEcolumn,\nofTABLErows,\nofTABLEcolumns) \eTD
   \bTD 
(\currentTABLErow,\currentTABLEcolumn,\nofTABLErows,\nofTABLEcolumns) \eTD
   \bTD 
(\currentTABLErow,\currentTABLEcolumn,\nofTABLErows,\nofTABLEcolumns) \eTD

   \eTR
\eTABLE

\stoptext


Thanks!

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  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Setting options for every n-th row in natural TABLEs

2012-09-04 Thread Sietse Brouwer
http://wiki.contextgarden.net/Command/currentTABLErow
http://wiki.contextgarden.net/Command/currentTABLEcolumn
http://wiki.contextgarden.net/Command/nofTABLErows
http://wiki.contextgarden.net/Command/nofTABLEcolumns

A bit of cutting, a bit of pasting ... the six-year-old in me is happy. :-)

--Sietse
___
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  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Setting options for every n-th row in natural TABLEs

2012-09-03 Thread Procházka Lukáš Ing . - Pontex s . r . o .

Natural tables have “odd” and “even” keywords for \setupTABLE but none in the 
way you like it. What I would do is to use a overlay in combination with 
metapost to create the background but there is no global register to access the 
current column/row of a cell, e.g. \currenttablecolumn (this name is already 
used by tables) and \currenttablerow.


... Maybe \currentTABLEcolumn (no collision with tables' \currenttablecolumn) 
and \currentTABLErow could be defined for this purpose.

Lukas

--
Ing. Lukáš Procházka [mailto:l...@pontex.cz]
Pontex s. r. o.  [mailto:pon...@pontex.cz] [http://www.pontex.cz]
Bezová 1658
147 14 Praha 4

Tel: +420 244 062 238
Fax: +420 244 461 038

___
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  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

Re: [NTG-context] Setting options for every n-th row in natural TABLEs

2012-09-03 Thread Aditya Mahajan

On Mon, 3 Sep 2012, Procházka Lukáš Ing. - Pontex s. r. o. wrote:

Natural tables have “odd” and “even” keywords for \setupTABLE but none in 
the way you like it. What I would do is to use a overlay in combination 
with metapost to create the background but there is no global register to 
access the current column/row of a cell, e.g. \currenttablecolumn (this 
name is already used by tables) and \currenttablerow.


... Maybe \currentTABLEcolumn (no collision with tables' \currenttablecolumn) 
and \currentTABLErow could be defined for this purpose.


I agree. In addition, \currentTABLEheaderrow, \currentTABLEheadercolumn, 
\currentTABLEfooterrow, \currentTABLEfootercolumn, and the \max... version 
of all of these are also useful at the user level.


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  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

Re: [NTG-context] Setting options for every n-th row in natural TABLEs

2012-09-02 Thread Wolfgang Schuster

Am 02.09.2012 um 17:59 schrieb Aditya Mahajan adit...@umich.edu:

 Hi,
 
 On Edward Tufte's website, there is a discussion on zebra coloring in 
 tables[1]. One of the suggestion is to add a horizontal rule after every 
 third line or shade three lines with one background color and the remaining 
 three with another background color.
 
 Is there an easy way to do this with natural TABLEs? I can do something like:
 
 \setupTABLE[row][1,2,3][background=color, backgroundcolor=gray]
 \setupTABLE[row][7,8,9][background=color, backgroundcolor=gray]
 
 but it requires knowing the number of lines in advance.
 
 Aditya
 
 [1]: http://www.edwardtufte.com/bboard/q-and-a-fetch-msg?msg_id=0001IV

Natural tables have “odd” and “even” keywords for \setupTABLE but none in the 
way you like it. What I would do is to use a overlay in combination with 
metapost to create the background but there is no global register to access the 
current column/row of a cell, e.g. \currenttablecolumn (this name is already 
used by tables) and \currenttablerow.

Wolfgang

___
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  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Setting options for every n-th row in natural TABLEs

2012-09-02 Thread Aditya Mahajan

On Sun, 2 Sep 2012, Wolfgang Schuster wrote:



Am 02.09.2012 um 17:59 schrieb Aditya Mahajan adit...@umich.edu:


Hi,

On Edward Tufte's website, there is a discussion on zebra coloring in 
tables[1]. One of the suggestion is to add a horizontal rule after every third 
line or shade three lines with one background color and the remaining three 
with another background color.

Is there an easy way to do this with natural TABLEs? I can do something like:

\setupTABLE[row][1,2,3][background=color, backgroundcolor=gray]
\setupTABLE[row][7,8,9][background=color, backgroundcolor=gray]

but it requires knowing the number of lines in advance.

Aditya

[1]: http://www.edwardtufte.com/bboard/q-and-a-fetch-msg?msg_id=0001IV


Natural tables have “odd” and “even” keywords for \setupTABLE but none 
in the way you like it.


Well, I can always change what odd and even means :) (I also realized that 
odd and even are just dummy values. I can change them to anything, and can 
in fact even turn \v!oddeven to a switch statement that returns multiple 
values)


\unprotect
\def\redefineoddeven% HACK
{\def\v!oddeven##1% Return odd if in set 1-3, 7-9, etc. and even otherwise
{\ctxcommand{doifelse(math.mod(##1-1,6)  3)}\v!odd\v!even}}
\protect

\startsetups zebra:three
\redefineoddeven
\setupTABLE[frame=off,background=color]
\setupTABLE[row][odd][backgroundcolor=blue]
\setupTABLE[row][even][backgroundcolor=red]
\stopsetups

\starttext
\startTABLE[setups={zebra:three}]
  \NC A \NC B \NC C \NC \NR
  \NC A \NC B \NC C \NC \NR
  \NC A \NC B \NC C \NC \NR
  \NC A \NC B \NC C \NC \NR
  \NC A \NC B \NC C \NC \NR
  \NC A \NC B \NC C \NC \NR
  \NC A \NC B \NC C \NC \NR
  \NC A \NC B \NC C \NC \NR
  \NC A \NC B \NC C \NC \NR
  \NC A \NC B \NC C \NC \NR
  \NC A \NC B \NC C \NC \NR
\stopTABLE
\stoptext

What I would do is to use a overlay in combination with metapost to 
create the background but there is no global register to access the 
current column/row of a cell, e.g. \currenttablecolumn (this name is 
already used by tables) and \currenttablerow.


Thanks for the hint. It is relatively easy to access the local counter for 
a cell, and changing background colors dependon the current row works 
well.


\defineconversion
[triadcolors]
[blue,blue,blue,red,red,red]

\startsetups zebra:three
\setupTABLE[frame=off,background=color]

\setupTABLE[row][backgroundcolor={\convertnumber{triadcolors}{\getvalue{m_tabl_ntb_positive_row}}}]
\stopsetups

If I need rules, I guess I can explicitly check for the value of \m_tabl_ntb_postive_pow 
inside an overlay.


Thanks,
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  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___