* Color a column (xtable, lua)
@ 2019-01-26 23:08 Fabrice Couvreur
2019-01-26 23:26 ` Henri Menke
0 siblings, 1 reply; 5+ messages in thread
From: Fabrice Couvreur @ 2019-01-26 23:08 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 992 bytes --]
Hi,
How to color the first column as I did for the first line ?
Thank you
Fabrice
\definecolor[fondpaille][c=0,m=0,y=0.2,k=0]
\starttext
\startluacode
local letters_1 = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J" }
local letters_2 = { "A", "0", "1", "1", "0", "", "", "", "", "" }
context.startxtable({"align={middle,lohi}, width=1.25cm,offset=0.8ex"})
context.startxrow()
context.startxcell({"background=color,backgroundcolor=white,frame=off"})
context("") context.stopxcell()
for _, letter in ipairs(letters_1) do
context.startxcell({"background=color,backgroundcolor=fondpaille"})
context(letter) context.stopxcell()
end
context.stopxrow()
context.startxrow()
for _, letter in ipairs(letters_2) do
context.startxcell() context(letter) context.stopxcell()
end
context.stopxrow()
for i=2,10 do
context.startxrow()
context.startxcell() context(converters.convert("A",i))
context.stopxcell()
context.stopxrow()
end
context.stopxtable()
\stopluacode
\stoptext
[-- Attachment #1.2: Type: text/html, Size: 2057 bytes --]
[-- Attachment #2: Type: text/plain, Size: 492 bytes --]
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Color a column (xtable, lua)
2019-01-26 23:08 Color a column (xtable, lua) Fabrice Couvreur
@ 2019-01-26 23:26 ` Henri Menke
2019-01-26 23:33 ` Henri Menke
0 siblings, 1 reply; 5+ messages in thread
From: Henri Menke @ 2019-01-26 23:26 UTC (permalink / raw)
To: ntg-context
On 1/27/19 12:08 PM, Fabrice Couvreur wrote:
> Hi,
> How to color the first column as I did for the first line ?
Stolen from Wolfgang's answer on TeX.SX.
https://tex.stackexchange.com/a/464771
\definecolor[fondpaille][c=0,m=0,y=0.2,k=0]
\startuseMPgraphic {tablebackground}
fill OverlayBox withcolor \MPcolor{fondpaille} ;
\stopuseMPgraphic
\defineoverlay
[tablebackground]
[\ifnum\currentxtablerow=1
\useMPgraphic{tablebackground}%
\else\ifnum\currentxtablecolumn=1
\useMPgraphic{tablebackground}%
\fi\fi]
\setupxtable[background=tablebackground]
\starttext
\startluacode
local letters_1 = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J" }
local letters_2 = { "A", "0", "1", "1", "0", "", "", "", "", "" }
context.startxtable({"align={middle,lohi}, width=1.25cm,offset=0.8ex"})
context.startxrow()
context.startxcell({"background=color,backgroundcolor=white,frame=off"})
context("")
context.stopxcell()
for _, letter in ipairs(letters_1) do
context.startxcell()
context(letter) context.stopxcell()
end
context.stopxrow()
context.startxrow()
for _, letter in ipairs(letters_2) do
context.startxcell() context(letter) context.stopxcell()
end
context.stopxrow()
for i=2,10 do
context.startxrow()
context.startxcell() context(converters.convert("A",i))
context.stopxcell()
context.stopxrow()
end
context.stopxtable()
\stopluacode
\stoptext
> Thank you
> Fabrice
>
> \definecolor[fondpaille][c=0,m=0,y=0.2,k=0]
> \starttext
> \startluacode
> local letters_1 = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J" }
> local letters_2 = { "A", "0", "1", "1", "0", "", "", "", "", "" }
> context.startxtable({"align={middle,lohi}, width=1.25cm,offset=0.8ex"})
> context.startxrow()
> context.startxcell({"background=color,backgroundcolor=white,frame=off"})
> context("") context.stopxcell()
> for _, letter in ipairs(letters_1) do
> context.startxcell({"background=color,backgroundcolor=fondpaille"})
> context(letter) context.stopxcell()
> end
> context.stopxrow()
> context.startxrow()
> for _, letter in ipairs(letters_2) do
> context.startxcell() context(letter) context.stopxcell()
> end
> context.stopxrow()
> for i=2,10 do
> context.startxrow()
> context.startxcell() context(converters.convert("A",i))
> context.stopxcell()
> context.stopxrow()
> end
> context.stopxtable()
> \stopluacode
> \stoptext
>
>
> ___________________________________________________________________________________
> 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
> ___________________________________________________________________________________
>
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Color a column (xtable, lua)
2019-01-26 23:26 ` Henri Menke
@ 2019-01-26 23:33 ` Henri Menke
2019-01-26 23:59 ` Fabrice Couvreur
0 siblings, 1 reply; 5+ messages in thread
From: Henri Menke @ 2019-01-26 23:33 UTC (permalink / raw)
To: ntg-context
On 1/27/19 12:26 PM, Henri Menke wrote:
> On 1/27/19 12:08 PM, Fabrice Couvreur wrote:
>> Hi,
>> How to color the first column as I did for the first line ?
>
> Stolen from Wolfgang's answer on TeX.SX.
> https://tex.stackexchange.com/a/464771
>
You could also evaluate the conditional purely in MetaPost. I don't
know if that would be faster, but it's a bit more readable to me.
\startuseMPgraphic{tablebackground}{i,j}
if (\MPvar{i} = 1) or (\MPvar{j} = 1):
fill OverlayBox withcolor \MPcolor{fondpaille} ;
fi;
\stopuseMPgraphic
\defineoverlay
[tablebackground]
[\useMPgraphic{tablebackground}{i=\currentxtablerow,j=\currentxtablecolumn}]
\setupxtable[background=tablebackground]
>
> \definecolor[fondpaille][c=0,m=0,y=0.2,k=0]
>
> \startuseMPgraphic {tablebackground}
> fill OverlayBox withcolor \MPcolor{fondpaille} ;
> \stopuseMPgraphic
>
> \defineoverlay
> [tablebackground]
> [\ifnum\currentxtablerow=1
> \useMPgraphic{tablebackground}%
> \else\ifnum\currentxtablecolumn=1
> \useMPgraphic{tablebackground}%
> \fi\fi]
>
> \setupxtable[background=tablebackground]
>
> \starttext
> \startluacode
> local letters_1 = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J" }
> local letters_2 = { "A", "0", "1", "1", "0", "", "", "", "", "" }
> context.startxtable({"align={middle,lohi}, width=1.25cm,offset=0.8ex"})
>
> context.startxrow()
> context.startxcell({"background=color,backgroundcolor=white,frame=off"})
> context("")
> context.stopxcell()
> for _, letter in ipairs(letters_1) do
> context.startxcell()
> context(letter) context.stopxcell()
> end
> context.stopxrow()
>
> context.startxrow()
> for _, letter in ipairs(letters_2) do
> context.startxcell() context(letter) context.stopxcell()
> end
> context.stopxrow()
>
> for i=2,10 do
> context.startxrow()
> context.startxcell() context(converters.convert("A",i))
> context.stopxcell()
> context.stopxrow()
> end
>
> context.stopxtable()
> \stopluacode
> \stoptext
>
>
>> Thank you
>> Fabrice
>>
>> \definecolor[fondpaille][c=0,m=0,y=0.2,k=0]
>> \starttext
>> \startluacode
>> local letters_1 = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J" }
>> local letters_2 = { "A", "0", "1", "1", "0", "", "", "", "", "" }
>> context.startxtable({"align={middle,lohi}, width=1.25cm,offset=0.8ex"})
>> context.startxrow()
>> context.startxcell({"background=color,backgroundcolor=white,frame=off"})
>> context("") context.stopxcell()
>> for _, letter in ipairs(letters_1) do
>> context.startxcell({"background=color,backgroundcolor=fondpaille"})
>> context(letter) context.stopxcell()
>> end
>> context.stopxrow()
>> context.startxrow()
>> for _, letter in ipairs(letters_2) do
>> context.startxcell() context(letter) context.stopxcell()
>> end
>> context.stopxrow()
>> for i=2,10 do
>> context.startxrow()
>> context.startxcell() context(converters.convert("A",i))
>> context.stopxcell()
>> context.stopxrow()
>> end
>> context.stopxtable()
>> \stopluacode
>> \stoptext
>>
>>
>> ___________________________________________________________________________________
>> 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
>> ___________________________________________________________________________________
>>
>
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Color a column (xtable, lua)
2019-01-26 23:33 ` Henri Menke
@ 2019-01-26 23:59 ` Fabrice Couvreur
2019-01-27 9:23 ` Wolfgang Schuster
0 siblings, 1 reply; 5+ messages in thread
From: Fabrice Couvreur @ 2019-01-26 23:59 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 5547 bytes --]
Hi Henry,
Thank you for your proposition. I tested both : the first work but not the
second.
Fabrice
lua error > lua error on line 13 in file /home/viserion/Ntg_7.tex:
...ext/tex/texmf-context/tex/context/base/mkiv/tabl-xtb.lua:1269: attempt
to index a nil value (upvalue 'data')
3
4 \startuseMPgraphic{tablebackground}{i,j}
5 if (\MPvar{i} = 1) or (\MPvar{j} = 1):
6 fill OverlayBox withcolor \MPcolor{fondpaille} ;
7 fi;
8 \stopuseMPgraphic
9
10 \defineoverlay
11 [tablebackground]
12
13 >>
[\useMPgraphic{tablebackground}{i=\currentxtablerow,j=\currentxtablecolumn}]
14
15 \setupxtable[background=tablebackground]
16
17 \starttext
18 \startluacode
19 local letters_1 = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J"
}
20 local letters_2 = { "A", "0", "1", "1", "0", "", "", "", "", "" }
21 context.startxtable({"align={middle,lohi},
width=1.25cm,offset=0.8ex"})
22
23 context.startxrow()
?
Le dim. 27 janv. 2019 à 00:34, Henri Menke <henrimenke@gmail.com> a écrit :
> On 1/27/19 12:26 PM, Henri Menke wrote:
> > On 1/27/19 12:08 PM, Fabrice Couvreur wrote:
> >> Hi,
> >> How to color the first column as I did for the first line ?
> >
> > Stolen from Wolfgang's answer on TeX.SX.
> > https://tex.stackexchange.com/a/464771
> >
>
> You could also evaluate the conditional purely in MetaPost. I don't
> know if that would be faster, but it's a bit more readable to me.
>
>
> \startuseMPgraphic{tablebackground}{i,j}
> if (\MPvar{i} = 1) or (\MPvar{j} = 1):
> fill OverlayBox withcolor \MPcolor{fondpaille} ;
> fi;
> \stopuseMPgraphic
>
> \defineoverlay
> [tablebackground]
>
>
> [\useMPgraphic{tablebackground}{i=\currentxtablerow,j=\currentxtablecolumn}]
>
> \setupxtable[background=tablebackground]
>
> >
> > \definecolor[fondpaille][c=0,m=0,y=0.2,k=0]
> >
> > \startuseMPgraphic {tablebackground}
> > fill OverlayBox withcolor \MPcolor{fondpaille} ;
> > \stopuseMPgraphic
> >
> > \defineoverlay
> > [tablebackground]
> > [\ifnum\currentxtablerow=1
> > \useMPgraphic{tablebackground}%
> > \else\ifnum\currentxtablecolumn=1
> > \useMPgraphic{tablebackground}%
> > \fi\fi]
> >
> > \setupxtable[background=tablebackground]
> >
> > \starttext
> > \startluacode
> > local letters_1 = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J" }
> > local letters_2 = { "A", "0", "1", "1", "0", "", "", "", "", "" }
> > context.startxtable({"align={middle,lohi}, width=1.25cm,offset=0.8ex"})
> >
> > context.startxrow()
> > context.startxcell({"background=color,backgroundcolor=white,frame=off"})
> > context("")
> > context.stopxcell()
> > for _, letter in ipairs(letters_1) do
> > context.startxcell()
> > context(letter) context.stopxcell()
> > end
> > context.stopxrow()
> >
> > context.startxrow()
> > for _, letter in ipairs(letters_2) do
> > context.startxcell() context(letter) context.stopxcell()
> > end
> > context.stopxrow()
> >
> > for i=2,10 do
> > context.startxrow()
> > context.startxcell() context(converters.convert("A",i))
> > context.stopxcell()
> > context.stopxrow()
> > end
> >
> > context.stopxtable()
> > \stopluacode
> > \stoptext
> >
> >
> >> Thank you
> >> Fabrice
> >>
> >> \definecolor[fondpaille][c=0,m=0,y=0.2,k=0]
> >> \starttext
> >> \startluacode
> >> local letters_1 = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J" }
> >> local letters_2 = { "A", "0", "1", "1", "0", "", "", "", "", "" }
> >> context.startxtable({"align={middle,lohi}, width=1.25cm,offset=0.8ex"})
> >> context.startxrow()
> >> context.startxcell({"background=color,backgroundcolor=white,frame=off"})
> >> context("") context.stopxcell()
> >> for _, letter in ipairs(letters_1) do
> >> context.startxcell({"background=color,backgroundcolor=fondpaille"})
> >> context(letter) context.stopxcell()
> >> end
> >> context.stopxrow()
> >> context.startxrow()
> >> for _, letter in ipairs(letters_2) do
> >> context.startxcell() context(letter) context.stopxcell()
> >> end
> >> context.stopxrow()
> >> for i=2,10 do
> >> context.startxrow()
> >> context.startxcell() context(converters.convert("A",i))
> >> context.stopxcell()
> >> context.stopxrow()
> >> end
> >> context.stopxtable()
> >> \stopluacode
> >> \stoptext
> >>
> >>
> >>
> ___________________________________________________________________________________
> >> 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
> >>
> ___________________________________________________________________________________
> >>
> >
>
>
> ___________________________________________________________________________________
> 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
>
> ___________________________________________________________________________________
[-- Attachment #1.2: Type: text/html, Size: 9075 bytes --]
[-- Attachment #2: Type: text/plain, Size: 492 bytes --]
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Color a column (xtable, lua)
2019-01-26 23:59 ` Fabrice Couvreur
@ 2019-01-27 9:23 ` Wolfgang Schuster
0 siblings, 0 replies; 5+ messages in thread
From: Wolfgang Schuster @ 2019-01-27 9:23 UTC (permalink / raw)
To: mailing list for ConTeXt users, Fabrice Couvreur
Fabrice Couvreur schrieb am 27.01.19 um 00:59:
> Hi Henry,
> Thank you for your proposition. I tested both : the first work but
> not the second.
> Fabrice
Remove the empty line between the two arguments of the \defineoverlay
command.
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-01-27 9:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-26 23:08 Color a column (xtable, lua) Fabrice Couvreur
2019-01-26 23:26 ` Henri Menke
2019-01-26 23:33 ` Henri Menke
2019-01-26 23:59 ` Fabrice Couvreur
2019-01-27 9:23 ` Wolfgang Schuster
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).