ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Fabrice Couvreur <fabrice1.couvreur@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Color specific cells in a table
Date: Sun, 23 Aug 2020 16:35:54 +0200	[thread overview]
Message-ID: <CACyK-eq2BRV7UwVyZxjqw8sRMq-JWxZKb=gSWRdm4enOfzehxA@mail.gmail.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 1697 bytes --]

Hello,
This table will be used to illustrate Pascal's triangle. I manage to color
the cell (2,0) but I would also like to color the cells (2,1) and (3,1). Is
it possible ?
Thank you
Fabrice

\usecolors[X11]

\starttext
\startluacode

  local background_one = {
   align = "middle",
   style = "type",
   background = "color",
   backgroundcolor = "thistle2",
   foregroundcolor = "white",
  }

   local background_two = {
   align = "middle",
   style = "type",
   background = "color",
   backgroundcolor = "peachpuff",
   foregroundcolor = "white",
  }

  context.startxtable({"align={middle,lohi},
width=1cm,offset=0.8ex,bodyfont=9pt,framecolor=cyan"})
  context.startxrow()
  context.startxcell({"background=color,backgroundcolor=thistle2"})
  context("")
  context.stopxcell()
  for j = 0, 7 do

context.startxcell({"foregroundstyle=bold,background=color,backgroundcolor=thistle2"})
  context(j)
  context.stopxcell()
  end

context.startxcell({"foregroundstyle=bold,background=color,backgroundcolor=thistle2"})
  context("\\dots")
  context.stopxcell()
  context.stopxrow()
  for i = 0, 7 do
  context.startxrow()

context.startxcell({"foregroundstyle=bold,background=color,backgroundcolor=thistle2"})
  context(i)
  context.stopxcell()
  for j = 0, 8 do
  context.startxcell(j>i and background_one or i == 2 and j == 0 and
background_two)
  context("")
  context.stopxcell()
  end
  context.stopxrow()
  end
  context.startxrow()
  context.startxcell({"background=color,backgroundcolor=thistle2"})
  context("\\dots")
  context.stopxcell()
  for i = 0, 8 do
  context.startxcell()
  context("")
  context.stopxcell()
  end
  context.stopxrow()
  context.stopxtable()
\stopluacode
\stoptext

[-- Attachment #1.2: Type: text/html, Size: 2810 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 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
___________________________________________________________________________________

                 reply	other threads:[~2020-08-23 14:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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='CACyK-eq2BRV7UwVyZxjqw8sRMq-JWxZKb=gSWRdm4enOfzehxA@mail.gmail.com' \
    --to=fabrice1.couvreur@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).