Hi, Is it possible to fill columns A, B and C using a loop with lua ? Thank you. Fabrice \starttext \startxtable[align={lohi,middle},bodyfont=8pt,width=0.8cm] \startxrow \startxcell \stopxcell \startxcell A \stopxcell \startxcell B \stopxcell \startxcell C \stopxcell \stopxrow \startxrow \startxcell 1 \stopxcell \startxcell \m{x} \stopxcell \startxcell \m{N} \stopxcell \startxcell \m{B} \stopxcell \stopxrow \startxrow \startxcell 2 \stopxcell \startxcell 1 \stopxcell \startxcell 7 \stopxcell \startxcell 20 \stopxcell \stopxrow \startxrow \startxcell 3 \stopxcell \startxcell 2 \stopxcell \startxcell 14 \stopxcell \startxcell 24 \stopxcell \stopxrow \startxrow \startxcell 4 \stopxcell \startxcell 3 \stopxcell \startxcell 21 \stopxcell \startxcell 28 \stopxcell \stopxrow \startxrow \startxcell 5 \stopxcell \startxcell 4 \stopxcell \startxcell 28 \stopxcell \startxcell 32 \stopxcell \stopxrow \startxrow \startxcell 6 \stopxcell \startxcell 5 \stopxcell \startxcell 35 \stopxcell \startxcell 36 \stopxcell \stopxrow \startxrow \startxcell 7 \stopxcell \startxcell 6 \stopxcell \startxcell 42 \stopxcell \startxcell 40 \stopxcell \stopxrow \startxrow \startxcell 8 \stopxcell \startxcell 7 \stopxcell \startxcell 49 \stopxcell \startxcell 44 \stopxcell \stopxrow \startxrow \startxcell 9 \stopxcell \startxcell 8 \stopxcell \startxcell 56 \stopxcell \startxcell 48 \stopxcell \stopxrow \startxrow \startxcell 10 \stopxcell \startxcell 9 \stopxcell \startxcell 63 \stopxcell \startxcell 52 \stopxcell \stopxrow \startxrow \startxcell 11 \stopxcell \startxcell 10 \stopxcell \startxcell 70 \stopxcell \startxcell 56 \stopxcell \stopxrow \startxrow \startxcell 12 \stopxcell \startxcell 11 \stopxcell \startxcell 77 \stopxcell \startxcell 60 \stopxcell \stopxrow \stopxtable \stoptext
On Sun, 30 Sep 2018, Fabrice Couvreur wrote:
Hi, Is it possible to fill columns A, B and C using a loop with lua ? Thank you.
Here is a blog post summarizing a similar question from almost a decade ago: https://adityam.github.io/context-blog/post/tex-programming/ Aditya
Hi Aditya, Thanks for pointing to your context-blog: one learns always some good stuff there! I wanted to make an observation about the last example in that page, which does not typeset correctly as expected, and also it does not work well if one wanted to make a multiplication table instead of the addition table of your examples. I think the following modification might be necessary (here for the multiplication table): %%%%%%% \startplacetable \startluacode context.bTABLE() context.bTR() context.bTD() context("($\\times$)") context.eTD() for n = 1,6 do context.bTD() context(n) context.eTD() end context.eTR() for x = 1,6 do context.bTR() for y = 0,6 do context.bTD() if y == 0 then context(x) elseif y > 0 then context(x*y) end context.eTD() end context.eTR() end context.eTABLE() \stopluacode \stopplacetable %%%%%%% Thanks again, and best regards: OK
On 30 Sep 2018, at 21:15, Aditya Mahajan
wrote: On Sun, 30 Sep 2018, Fabrice Couvreur wrote:
Hi, Is it possible to fill columns A, B and C using a loop with lua ? Thank you.
Here is a blog post summarizing a similar question from almost a decade ago:
https://adityam.github.io/context-blog/post/tex-programming/
Aditya ___________________________________________________________________________________ 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 ___________________________________________________________________________________
On Mon, 1 Oct 2018, Otared Kavian wrote:
Hi Aditya,
Thanks for pointing to your context-blog: one learns always some good stuff there!
I wanted to make an observation about the last example in that page, which does not typeset correctly as expected, and also it does not work well if one wanted to make a multiplication table instead of the addition table of your examples. I think the following modification might be necessary (here for the multiplication table):
Thanks. I fixed this with a slightly different solution that does not require an extra if statement. Aditya
participants (3)
-
Aditya Mahajan
-
Fabrice Couvreur
-
Otared Kavian