On Sun, 2 Sep 2012, Wolfgang Schuster wrote: > > Am 02.09.2012 um 17:59 schrieb Aditya Mahajan : > >> 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