[NTG-context] Number format with lua

Fabrice Couvreur fabrice1.couvreur at gmail.com
Sat Nov 9 10:38:10 CET 2019


Hi,
In the table below, how to have numbers with only three decimals ?
Thank you.
Fabrice

\starttext
\startluacode
local letters_1 = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J" }
local letters_2 = { "1", "Année", "1998", "1999", "2000", "2001", "2002",
"2003", "2004", "2005","2006" }
context.startxtable({"align={middle,lohi},
width=1.2cm,offset=0.8ex,bodyfont=9pt"})

context.startxrow({"background=color,backgroundcolor=green"})
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()

context.startxrow()
context.startxcell() context("2") context.stopxcell()
context.startxcell({"width=2cm"}) context("Prix (kg)") context.stopxcell()
for i=0,8 do
    context.startxcell() context("%0.5g",1.031^i) context.stopxcell()
end
context.stopxrow()

context.stopxtable()
\stopluacode
\stoptext
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20191109/5b98e89b/attachment.html>


More information about the ntg-context mailing list