* making tables with lua @ 2012-10-17 1:13 Jeong Dal 2012-10-17 6:49 ` Procházka Lukáš Ing. - Pontex s. r. o. 2012-10-17 7:19 ` Hans Hagen 0 siblings, 2 replies; 7+ messages in thread From: Jeong Dal @ 2012-10-17 1:13 UTC (permalink / raw) To: ntg-context Dear all, I used code which generates the table as following: \startluacode local NC, NR, HL, VL = context.NC, context.NR, context.HL, context.VL context.starttabulate { "|c|c|c|c|c|c|c|c|c|c|" } HL() for i=1, 6, 1 do for j=1,10 ,1 do k= i % 3 if k==1 then VL() context(10*(i - k)/3+j) else VL() end end VL() NR() if k==0 then HL() end end context.stoptabulate() \stopluacode But it has a fixed column definition as "|c|c|c|c|c|c|c|c|c|c|" and the number of columns. I wonder it is possible to use the variable for "j" to control the number of columns and the column setting. Of course, I may put similar codes which are different only in the number of columns and column settings when I need a table. But I have many similar tables whose number of columns are different only. If such a method is possible, I'd like to put such a code in \startbuffer…\stopbudffer and call it to generate tables of various number of columns given at each time. I also don't know whether it is possible to convey a number from ConTeXt to the variable in Lua code. I write this email because I saw a hope in recent discussion "Re: Fwd: Need help with \definetabulate" which has a method to vary the column setting. \definetabulate [whatever] [|l|r|] \definetabulate [whatever][else] [|l|c|r|] It may be a lazy man's question with no need for others. Thank you for reading. Best regards, Dalyoung ___________________________________________________________________________________ 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: making tables with lua 2012-10-17 1:13 making tables with lua Jeong Dal @ 2012-10-17 6:49 ` Procházka Lukáš Ing. - Pontex s. r. o. 2012-10-17 7:19 ` Hans Hagen 1 sibling, 0 replies; 7+ messages in thread From: Procházka Lukáš Ing. - Pontex s. r. o. @ 2012-10-17 6:49 UTC (permalink / raw) To: mailing list for ConTeXt users [-- Attachment #1: Type: text/plain, Size: 3053 bytes --] Hello, my experience is that the best way is to create the table first, then to call Lua function to typeset the table. You may choose whether the table will be typeset with 'tabulate' family functions or 'TABLE' family; I may recommend you the latter as it gives you much more control of the final look than the former; 'TABLE' is much better anyway. Once you have such functions prepared, you just select to type: printTabulate(mytab) -- via 'tabulate' or printTABLE(mytab) -- via 'TABLE' If you insist on 'tabulate' family, you could use the following snippet for your start: ---- \starttext \startluacode local tab = {{1,2},{3,4}} printTabulate = function(tab) context.starttabulate{"|" .. string.rep("c|", #tab[1])} context.HL() for _, r in ipairs(tab) do for _, c in ipairs(r) do context.VL() context(c) end context.VL() context.NR() context.HL() end context.stoptabulate() end printTabulate(tab) \stopluacode \stoptext ---- You can write a similar function(s) to typeset via 'TABLE'. Best regards, Lukas On Wed, 17 Oct 2012 03:13:39 +0200, Jeong Dal <haksan@me.com> wrote: > Dear all, > > I used code which generates the table as following: > > \startluacode > local NC, NR, HL, VL = context.NC, context.NR, context.HL, context.VL > context.starttabulate { "|c|c|c|c|c|c|c|c|c|c|" } > HL() > for i=1, 6, 1 do > for j=1,10 ,1 do > k= i % 3 > if k==1 then > VL() context(10*(i - k)/3+j) > else > VL() > end > end > VL() > NR() > if k==0 then > HL() > end > end > context.stoptabulate() > \stopluacode > > But it has a fixed column definition as "|c|c|c|c|c|c|c|c|c|c|" and the number of columns. > I wonder it is possible to use the variable for "j" to control the number of columns and the column setting. > Of course, I may put similar codes which are different only in the number of columns and column settings when I need a table. > But I have many similar tables whose number of columns are different only. > If such a method is possible, I'd like to put such a code in \startbuffer…\stopbudffer and call it to generate tables of various number of columns given at each time. > I also don't know whether it is possible to convey a number from ConTeXt to the variable in Lua code. > > I write this email because I saw a hope in recent discussion "Re: Fwd: Need help with \definetabulate" which has a method to vary the column setting. > > \definetabulate > [whatever] > [|l|r|] > > \definetabulate > [whatever][else] > [|l|c|r|] > > > It may be a lazy man's question with no need for others. > > Thank you for reading. > > Best regards, > > Dalyoung -- Ing. Lukáš Procházka [mailto:LPr@pontex.cz] Pontex s. r. o. [mailto:pontex@pontex.cz] [http://www.pontex.cz] Bezová 1658 147 14 Praha 4 Tel: +420 244 062 238 Fax: +420 244 461 038 [-- Attachment #2: t-Tabulate.mkiv --] [-- Type: application/octet-stream, Size: 496 bytes --] \starttext \startluacode local tab = {{1,2},{3,4}} printTabulate = function(tab) context.starttabulate{"|" .. string.rep("c|", #tab[1])} context.HL() for _, r in ipairs(tab) do for _, c in ipairs(r) do context.VL() context(c) end context.VL() context.NR() context.HL() end context.stoptabulate() end printTabulate(tab) \stopluacode \stoptext [-- Attachment #3: t-Tabulate.pdf --] [-- Type: application/pdf, Size: 5121 bytes --] [-- Attachment #4: Type: text/plain, Size: 485 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: making tables with lua 2012-10-17 1:13 making tables with lua Jeong Dal 2012-10-17 6:49 ` Procházka Lukáš Ing. - Pontex s. r. o. @ 2012-10-17 7:19 ` Hans Hagen 1 sibling, 0 replies; 7+ messages in thread From: Hans Hagen @ 2012-10-17 7:19 UTC (permalink / raw) To: mailing list for ConTeXt users; +Cc: Jeong Dal On 17-10-2012 03:13, Jeong Dal wrote: > Dear all, > > I used code which generates the table as following: > > \startluacode > local NC, NR, HL, VL = context.NC, context.NR, context.HL, context.VL > context.starttabulate { "|c|c|c|c|c|c|c|c|c|c|" } > HL() > for i=1, 6, 1 do > for j=1,10 ,1 do > k= i % 3 > if k==1 then > VL() context(10*(i - k)/3+j) > else > VL() > end > end > VL() > NR() > if k==0 then > HL() > end > end > context.stoptabulate() > \stopluacode > > But it has a fixed column definition as "|c|c|c|c|c|c|c|c|c|c|" and the number of columns. context.starttabulate { string.rep("|c",10+1) } ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl ----------------------------------------------------------------- ___________________________________________________________________________________ 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <mailman.522.1350456904.2084.ntg-context@ntg.nl>]
* Re: making tables with lua [not found] <mailman.522.1350456904.2084.ntg-context@ntg.nl> @ 2012-10-17 8:34 ` Jeong Dal 2012-10-17 9:18 ` Wolfgang Schuster 2012-10-17 9:24 ` Procházka Lukáš Ing. - Pontex s. r. o. 0 siblings, 2 replies; 7+ messages in thread From: Jeong Dal @ 2012-10-17 8:34 UTC (permalink / raw) To: ntg-context Dear Proch?zka Luk?? Ing and Hans, Thank you for the reply. It works fine. I modify your code to write a matrix and it also works too. \startformula \startluacode local NC, NR = context.NC, context.NR local t = {{1,0,3,4},{0,2,-2,5},{0,0,1,2}} context.startmatrix() --"{left={\left (\,},right={\,\right)}}") for _, r in ipairs(t) do for _, c in ipairs(r) do NC() context(c) end NR() end context.stopmatrix() \stopluacode \stopformula But I couldn't put "( )" before and after matrix. If I use context.startmatrix("{left={\left (\,},right={\,\right)}}") then it wrote "left…" as text before the matrix. How to enclose matrix with ( )? Thank you again. Best regards, Dalyoung > 4. Re: making tables with lua > (Proch?zka Luk?? Ing. - Pontex s. r. o.) > > > Once you have such functions prepared, you just select to type: > > printTabulate(mytab) -- via 'tabulate' > > or > > printTABLE(mytab) -- via 'TABLE' > > If you insist on 'tabulate' family, you could use the following snippet for your start: > > ---- > \starttext > \startluacode > local tab = {{1,2},{3,4}} > > printTabulate = function(tab) > context.starttabulate{"|" .. string.rep("c|", #tab[1])} > context.HL() > for _, r in ipairs(tab) do > for _, c in ipairs(r) do > context.VL() > context(c) > end > context.VL() > context.NR() > context.HL() > end > context.stoptabulate() > end > > printTabulate(tab) > \stopluacode > \stoptext > ---- > > You can write a similar function(s) to typeset via 'TABLE'. > > Best regards, > > Lukas > > > On Wed, 17 Oct 2012 03:13:39 +0200, Jeong Dal <haksan@me.com> wrote: > >> Dear all, >> >> I used code which generates the table as following: >> >> \startluacode >> local NC, NR, HL, VL = context.NC, context.NR, context.HL, context.VL >> context.starttabulate { "|c|c|c|c|c|c|c|c|c|c|" } >> HL() >> for i=1, 6, 1 do >> for j=1,10 ,1 do >> k= i % 3 >> if k==1 then >> VL() context(10*(i - k)/3+j) >> else >> VL() >> end >> end >> VL() >> NR() >> if k==0 then >> HL() >> end >> end >> context.stoptabulate() >> \stopluacode >> >> But it has a fixed column definition as "|c|c|c|c|c|c|c|c|c|c|" and the number of columns. >> I wonder it is possible to use the variable for "j" to control the number of columns and the column setting. >> Of course, I may put similar codes which are different only in the number of columns and column settings when I need a table. >> But I have many similar tables whose number of columns are different only. >> If such a method is possible, I'd like to put such a code in \startbuffer?\stopbudffer and call it to generate tables of various number of columns given at each time. >> I also don't know whether it is possible to convey a number from ConTeXt to the variable in Lua code. >> >> I write this email because I saw a hope in recent discussion "Re: Fwd: Need help with \definetabulate" which has a method to vary the column setting. >> >> \definetabulate >> [whatever] >> [|l|r|] >> >> \definetabulate >> [whatever][else] >> [|l|c|r|] >> >> >> It may be a lazy man's question with no need for others. >> >> Thank you for reading. >> >> Best regards, >> >> Dalyoung > > > -- > Ing. Luk?? Proch?zka [mailto:LPr@pontex.cz] > Pontex s. r. o. [mailto:pontex@pontex.cz] [http://www.pontex.cz] > Bezov? 1658 > 147 14 Praha 4 > > Tel: +420 244 062 238 > Fax: +420 244 461 038 > -------------- next part -------------- > A non-text attachment was scrubbed... > Name: t-Tabulate.mkiv > Type: application/octet-stream > Size: 496 bytes > Desc: not available > URL: <http://www.ntg.nl/pipermail/ntg-context/attachments/20121017/d9e8158e/attachment-0001.obj> > -------------- next part -------------- > A non-text attachment was scrubbed... > Name: t-Tabulate.pdf > Type: application/pdf > Size: 5121 bytes > Desc: not available > URL: <http://www.ntg.nl/pipermail/ntg-context/attachments/20121017/d9e8158e/attachment-0001.pdf> > > ------------------------------ > > Message: 5 > Date: Wed, 17 Oct 2012 08:55:01 +0200 > From: luigi scarso <luigi.scarso@gmail.com> > To: mailing list for ConTeXt users <ntg-context@ntg.nl> > Subject: Re: [NTG-context] ConTeXt unofficial test suite stub > Message-ID: > <CAG5iGsB6f+sEzwu6O_p=+TnDzdwFoq4Y3=69z6c5EVbt5_PvaA@mail.gmail.com> > Content-Type: text/plain; charset="utf-8" > > On Wed, Oct 17, 2012 at 8:44 AM, Marco Pessotto <melmothx@gmail.com> wrote: > >> Aditya Mahajan <adityam@umich.edu> writes: >> >>> It may be worthwhile to merge the two repos. >> >> I'm on my way. I'll keep you posted. >> >> >> Can you use graphicsmagick ? > > > -- > luigi > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: <http://www.ntg.nl/pipermail/ntg-context/attachments/20121017/a99aa46a/attachment.html> > > ------------------------------ > > ___________________________________________________________________________________ > 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://tex.aanhet.net > archive : https://foundry.supelec.fr/projects/contextrev/ > wiki : http://contextgarden.net > ___________________________________________________________________________________ > > End of ntg-context Digest, Vol 100, Issue 43 > ******************************************** ___________________________________________________________________________________ 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: making tables with lua 2012-10-17 8:34 ` Jeong Dal @ 2012-10-17 9:18 ` Wolfgang Schuster 2012-10-17 9:24 ` Procházka Lukáš Ing. - Pontex s. r. o. 1 sibling, 0 replies; 7+ messages in thread From: Wolfgang Schuster @ 2012-10-17 9:18 UTC (permalink / raw) To: mailing list for ConTeXt users Am 17.10.2012 um 10:34 schrieb Jeong Dal <haksan@me.com>: > Dear Proch?zka Luk?? Ing and Hans, > > Thank you for the reply. > > It works fine. > > I modify your code to write a matrix and it also works too. > > \startformula > \startluacode > local NC, NR = context.NC, context.NR > local t = {{1,0,3,4},{0,2,-2,5},{0,0,1,2}} > context.startmatrix() --"{left={\left (\,},right={\,\right)}}") > for _, r in ipairs(t) do > for _, c in ipairs(r) do > NC() > context(c) > end > NR() > end > context.stopmatrix() > \stopluacode > \stopformula > > But I couldn't put "( )" before and after matrix. > If I use > context.startmatrix("{left={\left (\,},right={\,\right)}}") > then it wrote "left…" as text before the matrix. > > How to enclose matrix with ( )? context.startmatrix{left="\\left(\\,",right="\\,\\right)"} Wolfgang ___________________________________________________________________________________ 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: making tables with lua 2012-10-17 8:34 ` Jeong Dal 2012-10-17 9:18 ` Wolfgang Schuster @ 2012-10-17 9:24 ` Procházka Lukáš Ing. - Pontex s. r. o. 1 sibling, 0 replies; 7+ messages in thread From: Procházka Lukáš Ing. - Pontex s. r. o. @ 2012-10-17 9:24 UTC (permalink / raw) To: mailing list for ConTeXt users [-- Attachment #1: Type: text/plain, Size: 1440 bytes --] On Wed, 17 Oct 2012 10:34:22 +0200, Jeong Dal <haksan@me.com> wrote: > Dear Proch?zka Luk?? Ing and Hans, > > Thank you for the reply. > > It works fine. > > I modify your code to write a matrix and it also works too. > > \startformula > \startluacode > local NC, NR = context.NC, context.NR > local t = {{1,0,3,4},{0,2,-2,5},{0,0,1,2}} > context.startmatrix() --"{left={\left (\,},right={\,\right)}}") > for _, r in ipairs(t) do > for _, c in ipairs(r) do > NC() > context(c) > end > NR() > end > context.stopmatrix() > \stopluacode > \stopformula > > But I couldn't put "( )" before and after matrix. > If I use > context.startmatrix("{left={\left (\,},right={\,\right)}}") > then it wrote "left…" as text before the matrix. > > How to enclose matrix with ( )? ... See the new sample attached. ---- printMatrix = function(tab) context.startmatrix{left = "\\left(\\,", right = "\\,\\right)"} for _, r in ipairs(tab) do for _, c in ipairs(r) do context.NC(c) end context.NR() end context.stopmatrix() end ---- Best regards, Lukas > Thank you again. > > Best regards, > > Dalyoung -- Ing. Lukáš Procházka [mailto:LPr@pontex.cz] Pontex s. r. o. [mailto:pontex@pontex.cz] [http://www.pontex.cz] Bezová 1658 147 14 Praha 4 Tel: +420 244 062 238 Fax: +420 244 461 038 [-- Attachment #2: t-Tabulate.mkiv --] [-- Type: application/octet-stream, Size: 833 bytes --] \starttext \startluacode local tab = {{1,0,3,4},{0,2,-2,5},{0,0,1,2}} printTabulate = function(tab) context.starttabulate{"|" .. string.rep("c|", #tab[1])} context.HL() for _, r in ipairs(tab) do for _, c in ipairs(r) do context.VL() context(c) end context.VL() context.NR() context.HL() end context.stoptabulate() end printMatrix = function(tab) context.startmatrix{left = "\\left(\\,", right = "\\,\\right)"} for _, r in ipairs(tab) do for _, c in ipairs(r) do context.NC(c) end context.NR() end context.stopmatrix() end printTabulate(tab) printMatrix(tab) \stopluacode \stoptext [-- Attachment #3: t-Tabulate.pdf --] [-- Type: application/pdf, Size: 13731 bytes --] [-- Attachment #4: Type: text/plain, Size: 485 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: making tables with lua @ 2012-10-18 4:43 Jeong Dal 0 siblings, 0 replies; 7+ messages in thread From: Jeong Dal @ 2012-10-18 4:43 UTC (permalink / raw) To: ntg-context Dear Wolfgang and Proch?zka Luk?? Ing, Thank you for the solution. It works nicely. It is so convenient to write many matrices. Best regards, Dalyoung ___________________________________________________________________________________ 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-10-18 4:43 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2012-10-17 1:13 making tables with lua Jeong Dal 2012-10-17 6:49 ` Procházka Lukáš Ing. - Pontex s. r. o. 2012-10-17 7:19 ` Hans Hagen [not found] <mailman.522.1350456904.2084.ntg-context@ntg.nl> 2012-10-17 8:34 ` Jeong Dal 2012-10-17 9:18 ` Wolfgang Schuster 2012-10-17 9:24 ` Procházka Lukáš Ing. - Pontex s. r. o. 2012-10-18 4:43 Jeong Dal
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).