ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Henri Menke <henrimenke@gmail.com>
To: ntg-context@ntg.nl
Subject: Re: Color a column (xtable, lua)
Date: Sun, 27 Jan 2019 12:26:08 +1300	[thread overview]
Message-ID: <24efaa94-588a-2d85-bcd1-bd44b909dae0@gmail.com> (raw)
In-Reply-To: <CACyK-eowci055i5J0gUUKuEOaOYV4ZTOTjjpi5ospmrSU3GrBw@mail.gmail.com>

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
___________________________________________________________________________________

  reply	other threads:[~2019-01-26 23:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-26 23:08 Fabrice Couvreur
2019-01-26 23:26 ` Henri Menke [this message]
2019-01-26 23:33   ` Henri Menke
2019-01-26 23:59     ` Fabrice Couvreur
2019-01-27  9:23       ` Wolfgang Schuster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=24efaa94-588a-2d85-bcd1-bd44b909dae0@gmail.com \
    --to=henrimenke@gmail.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).