[NTG-context] Table, xtable and lua

Wolfgang Schuster wolfgang.schuster.lists at gmail.com
Sun Nov 11 09:57:22 CET 2018



Henri Menke schrieb am 11.11.18 um 01:25:
>
> On 11/11/18 12:33 PM, Fabrice Couvreur wrote:
>> Hi,
>> I can not complete the first line of the table with the letters of the
>> alphabet.
>> Thank you.
>> Fabrice
>>
>> \starttext
>> \startlinecorrection[blank]
>> \startmidaligned
>> \startluacode
>> context.startxtable({"align=middle, width=1.25cm"})
>>      context.startxrow()
>>      context.startxcell({"width=0.5cm"}) context("") context.stopxcell()
>>      letter = {'A','B','C','D','E','F','G','H','I','J'}
>>       for letter = 1,10 do
>>           context.startxcell() context(print(letter)) context.stopxcell()
>>       end
>      letters = {'A','B','C','D','E','F','G','H','I','J'}
>      for _,letter in ipairs(letters) do
>          context.startxcell() context(letter) context.stopxcell()
>      end

A few more alternatives (take a look at the number converter):

\setupbodyfont[dejavu]

\starttext

\startluacode

local letters = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J" }

for _, letter in ipairs(letters) do
     context(letter)
end

context.par()

for _, letter in next, letters do
     context(letter)
end

context.par()

for i=1,10 do
     context(letters[i])
end

context.par()

for i=1,10 do
     context(converters.convert("A",i))
end

context.par()

for i=1,10 do
     context(converters.convert("A",i,"ru"))
end

\stopluacode

\stoptext

Wolfgang



More information about the ntg-context mailing list