[NTG-context] Table cell colo(u)rs

Christian metan0r at gmx.de
Thu Nov 17 11:35:18 CET 2011


> Hello,
> 
> I am trying to do a simple cell background shading in a table using the
> example at the wiki:
> 
> http://wiki.contextgarden.net/Table
> 
> Unfortunately, I get an "Undefined control sequence ..." error:
> 
> ! Undefined control sequence.
> 
> system          > tex > error on line 4 in file tmp.tex: Undefined control
> sequence ...
> 
>   1     \setupcolors[state=start]
>   2     \starttable[|l|l|]
>   3     \HL
>   4 >>  \BL[1]\SR
>   5     \NC Command	\NC Meaning	\NC\SR
>   6     \HL
>   7     \NC \tex{NC}	\NC next column	\NC\FR
>   8     \NC \tex{NR}	\NC next row	\NC\LR
>   9     \HL
> 10     \CL[green]\SR
> 11     \NC \tex{AR}	\NC automatic row\NC\SR
> 12     \HL
> 13     \stoptable
> 14
> 
> <recently read> \BL
> 
> l.4 \BL
>         [1]\SR
> ?
> 
> Any suggestions?

Well, not for this particular problem, it happens here, too.
But may I suggest the use of "natural tables" (aka TALBES)? I find them way more comfortable to use and the code is cleaner (to my eyes, at least).
This should get you going:

% Start of file
\setupTABLE[r][first][foregroundstyle={\ss \bf \color[white]},background=color,backgroundcolor=blue,framecolor=blue]
\setupTABLE[column][each][leftframe=off,rightframe=off]
\setupTABLE[column][1][align=right]
\setupTABLE[column][2][alignmentcharacter={.},aligncharacter=yes,align=middle,style={\color[red]}]
\chardef\characteralignmentmode=2
\starttext
\startplacetable[title=test]
\bTABLE
\bTR \bTH Category \eTH \bTH Data entry \eTH \eTR
\bTR \bTD First \eTD \bTD 35.12 \eTD \eTR
\bTR \bTD[background=color,backgroundcolor=red] Second \eTD \bTD 5.014 \eTD \eTR
\bTR[background=color,backgroundcolor=gray]
	\bTD Total \eTD \bTD 110 \eTD
\eTR
\eTABLE
\stopplacetable
\stoptext
% End of file

More information:
http://wiki.contextgarden.net/TABLE
Many more examples:
http://www.pragma-ade.com/general/manuals/enattab.pdf

Cheers!



More information about the ntg-context mailing list