Re: [NTG-context] using variable for subscript in math+lua
· > Dear Hans, Lucas, Wolfgang, Aditya > > Now, I write a matrix using \startluacode by the helps of you. > Also, I can do some operations in matrices which reduced my typing job. > In this code, I have to give all the entries of a matrix as a table. It is > good to use in many cases. > > I have one more question. If the given array is as the following and it works > well. > > However, there might be a better way to do job using "for" iteration. > I tired to use "i, j" in several ways but it doesn't work. Inside a string the variables are just bytes. To print to a string you can interpolate with string.format() [1]. [1] http://www.lua.org/manual/5.1/manual.html#pdf-string.format · \startluacode document = document or { } -- recommended: use namespace document.print_matrix = function (x, y) if not y then y = x end -- default to square context.startmatrix{left = "\\left(\\,", right = "\\,\\right)"} local schema = "a_{%d%d}" -- %d: prints integer part for i=1, x do for j=1, y do --- use the template defined above to print the --- row and column context.NC(string.format(schema, i, j)) end context.NR() end context.stopmatrix() end \stopluacode \starttext \startformula \ctxlua{document.print_matrix(3)} \stopformula \startformula \ctxlua{document.print_matrix(9,4)} \stopformula \startformula \ctxlua{document.print_matrix(9)} \stopformula \stoptext \endinput · > > Is there a way to do such a job using "for" iteration? > > 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 > ___ -- () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments pgpyR7Q10pCRx.pgp Description: PGP signature ___ 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 ___
[NTG-context] using variable for subscript in math+lua
Dear Hans, Lucas, Wolfgang, Aditya Now, I write a matrix using \startluacode by the helps of you. Also, I can do some operations in matrices which reduced my typing job. In this code, I have to give all the entries of a matrix as a table. It is good to use in many cases. I have one more question. If the given array is as the following and it works well. \starttext \startluacode printMatrix = function (t) context.startmatrix{left = "\\left(\\,", right = "\\,\\right)"} for _, r in ipairs(t) do for _, c in ipairs(r) do context.NC(c) end context.NR() end context.stopmatrix() end \stopluacode \startformula \startluacode local mat={{"a_{11}","a_{12}","a_{13}"},{"a_{21}","a_{22}","a_{23}"},{"a_{31}","a_{32}","a_{33}"}} printMatrix(mat) \stopluacode \stopformula \stoptext % However, there might be a better way to do job using "for" iteration. I tired to use "i, j" in several ways but it doesn't work. function printMatrixA() context.startmatrix{left = "\\left(\\,", right = "\\,\\right)"} for i=1,3 do for j=1, 3 do context.NC("a_{ij}") end context.NR() end context.stopmatrix() end %%% Is there a way to do such a job using "for" iteration? 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 ___
Re: [NTG-context] Lua in Ctx: "require()" fails?
On 24-10-2012 11:21, Procházka Lukáš Ing. - Pontex s. r. o. wrote: 1) drive letter is upper-case in my case, lower case in Hans' one, should be ok 2) I'm using backslashes '\' in path description, Hans uses '/', should work out ok too, windows internally accepts both but in the end context normalizes to / (i always use / anyway as that works on all platforma) 3) my LUAINPUTS path contains "?.lua" and "?.clua" strings, which are typical for pure Lua scripts with LUA_PATH (and "?.dll" with LUA_CPATH), whilst Hans' LUAINPUTS doesn't contain these strings. It seems that #3 is fatal - "?.[c]lua" must not be a part of the path; although it's been working so far. So - if anyone interested - I modified slightly my Ctx-initializing batch '_InitCtx.bat': indeed, as LUAINPUTS is a path specification cf web2c/tds It seems also that Ctx accepts both "a/b/c" and "a/b/c/" forms of LUAINPUTS members, i.e. with or without the trailing (back)slash. yes, quite some some cleanup happens deep down Hans - 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 ___
Re: [NTG-context] Lua in Ctx: "require()" fails?
Hello, When I make e:\tmp\whatever.lua (current path) e:\tmp\whatever\something.lua And run \starttext \enabletrackers[resolvers.libraries] \startluacode print("LUAINPUTS",os.getenv("LUAINPUTS")) require("whatever") ; require("something") ; \stopluacode \stoptext i get LUAINPUTS e:/tmp/whatever resolvers > libraries > ! locating "whatever" as "whatever.lua" using formats "texlua" resolvers > libraries > ! checking for "whatever.lua"' using format "tex" resolvers > libraries > ! lib "whatever.lua" located on "whatever.lua" whatever resolvers > libraries > ! locating "something" as "something.lua" using formats "texlua" resolvers > libraries > ! checking for "something.lua"' using format "tex" resolvers > libraries > ! checking for "something.lua"' using format "lua" resolvers > libraries > ! lib "something.lua" located on "e:/tmp/whatever/something.lua" something so it must be something with your path spec it seems that I solved the problem finally. Normally, the LUA_PATH contains members like "D:\Lukas\Lua\?.lua", whilst LUAINPUTS has form of "e:/tmp/whatever", so there are three differences: 1) drive letter is upper-case in my case, lower case in Hans' one, 2) I'm using backslashes '\' in path description, Hans uses '/', 3) my LUAINPUTS path contains "?.lua" and "?.clua" strings, which are typical for pure Lua scripts with LUA_PATH (and "?.dll" with LUA_CPATH), whilst Hans' LUAINPUTS doesn't contain these strings. So I started to check influence of these three differences... It seems that #3 is fatal - "?.[c]lua" must not be a part of the path; although it's been working so far. So - if anyone interested - I modified slightly my Ctx-initializing batch '_InitCtx.bat': set PATH=c:\ConTeXt\tex\texmf-mswin\bin;%PATH% :: The lowercase "c:" if fatally necesssary! set LUAINPUTS=%LUAINPUTS%;%LUA_PATH% :: >= 10/2012 set LUAINPUTS=%LUAINPUTS:?.luac=% set LUAINPUTS=%LUAINPUTS:?.lua=% :: >= 24.10.2012 It seems also that Ctx accepts both "a/b/c" and "a/b/c/" forms of LUAINPUTS members, i.e. with or without the trailing (back)slash. Thanks, Hans, for your detailed testing - the signal "LUAINPUTS e:/tmp/whatever" directed me to the solution. Best regards, Lukas -- Ing. Lukáš Procházka [mailto:l...@pontex.cz] Pontex s. r. o. [mailto:pon...@pontex.cz] [http://www.pontex.cz] Bezová 1658 147 14 Praha 4 Tel: +420 244 062 238 Fax: +420 244 461 038 ___ 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 ___
Re: [NTG-context] Fwd: Re: something about the placelist
在 Wed, 24 Oct 2012 16:43:36 +0800,Hans Hagen 写道: I see. Thank you very much. I think I love the context. It is so good. I think it is better than the latex. Thank you for your job very much. Thanks.!!!(@_@) Original Message Subject: Re: [NTG-context] something about the placelist Date: Wed, 24 Oct 2012 10:43:00 +0200 From: Hans Hagen To: feng On 24-10-2012 10:23, feng wrote: 在 Wed, 24 Oct 2012 16:03:53 +0800,Hans Hagen 写道: sorry, there is still a null string line.But I find that if there is a string before the \placelist the null string is disappear. like this: \setuplist[section][before=] \framed[background=frame_mp,frame=on,align=middle,width=80pt]{% add: strut=no to the \framed command (first run with \showstruts and you see what happens) string %%this is the string % \placelist [section] [alternative=d, % command, % none, maxwidth=\hsize, width=\hsize, maxwidth=75pt, before=, after=, offset=91pt, criterium=all,%important align=meddle, style=\tfa] } the output is like: - |string | |1 ass sss 1.| |2 ass sss 1.| |3 ass sss 1.| -- but if no the "string" the output is like: - | | |1 ass sss 1.| |2 ass sss 1.| |3 ass sss 1.| -- On 24-10-2012 09:53, feng wrote: hi! I am a newer. I am studying the context. I think the context is very good. I had study the latex in past years. I have a question: there is a "null string line" above the \placelist, I don't want it. who can help me? \framed[background=frame_mp,frame=on,align=middle,width=80pt]{% \blank[-12pt] \placelist [section] [alternative=d, maxwidth=\hsize, width=\hsize, maxwidth=75pt, offset=0pt, criterium=all, align=meddle, style=\tfa] } thank you! ps. I am a chinese, my english is poor. \setuplist[section][before=] - 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 - -- 使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/ ___ 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 ___
[NTG-context] Fwd: Re: something about the placelist
Original Message Subject: Re: [NTG-context] something about the placelist Date: Wed, 24 Oct 2012 10:43:00 +0200 From: Hans Hagen To: feng On 24-10-2012 10:23, feng wrote: 在 Wed, 24 Oct 2012 16:03:53 +0800,Hans Hagen 写道: sorry, there is still a null string line.But I find that if there is a string before the \placelist the null string is disappear. like this: \setuplist[section][before=] \framed[background=frame_mp,frame=on,align=middle,width=80pt]{% add: strut=no to the \framed command (first run with \showstruts and you see what happens) string %%this is the string % \placelist [section] [alternative=d, % command, % none, maxwidth=\hsize, width=\hsize, maxwidth=75pt, before=, after=, offset=91pt, criterium=all,%important align=meddle, style=\tfa] } the output is like: - |string | |1 ass sss 1.| |2 ass sss 1.| |3 ass sss 1.| -- but if no the "string" the output is like: - | | |1 ass sss 1.| |2 ass sss 1.| |3 ass sss 1.| -- On 24-10-2012 09:53, feng wrote: hi! I am a newer. I am studying the context. I think the context is very good. I had study the latex in past years. I have a question: there is a "null string line" above the \placelist, I don't want it. who can help me? \framed[background=frame_mp,frame=on,align=middle,width=80pt]{% \blank[-12pt] \placelist [section] [alternative=d, maxwidth=\hsize, width=\hsize, maxwidth=75pt, offset=0pt, criterium=all, align=meddle, style=\tfa] } thank you! ps. I am a chinese, my english is poor. \setuplist[section][before=] - 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 - -- - 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 ___
Re: [NTG-context] math: \text does not scale properly
On 24-10-2012 06:06, Aditya Mahajan wrote: On Sun, 21 Oct 2012, Hans Hagen wrote: On 21-10-2012 04:35, Aditya Mahajan wrote: On Sat, 20 Oct 2012, Aditya Mahajan wrote: On Thu, 4 Oct 2012, Andreas Mang wrote: Hi there, As Aditya mentioned in a former posting (*) that "\text{ ... }" should scale properly when used as super- or subscript, I have prepared a minimal example to demonstrate that it doesn't. In my document I have switched from "\text{ }" to "\normal", which works. There is another bug with \text. How about: [] I don't understand the fix, but it gives the correct output. hm, given your involvement in math you should study it -) it boils down to the fact that in luatex we can actually ask what the upcoming style can be (text, script, scriptscript) normally a choice means 4 times processing and tex will use one only, while in this case i could write \text in a way that processes only once (so, way faster as we only have 1 bodyfont switch now) Hans - 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 ___
Re: [NTG-context] something about the placelist
On 24-10-2012 09:53, feng wrote: hi! I am a newer. I am studying the context. I think the context is very good. I had study the latex in past years. I have a question: there is a "null string line" above the \placelist, I don't want it. who can help me? \framed[background=frame_mp,frame=on,align=middle,width=80pt]{% \blank[-12pt] \placelist [section] [alternative=d, maxwidth=\hsize, width=\hsize, maxwidth=75pt, offset=0pt, criterium=all, align=meddle, style=\tfa] } thank you! ps. I am a chinese, my english is poor. \setuplist[section][before=] - 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 ___
[NTG-context] something about the placelist
hi! I am a newer. I am studying the context. I think the context is very good. I had study the latex in past years. I have a question: there is a "null string line" above the \placelist, I don't want it. who can help me? \framed[background=frame_mp,frame=on,align=middle,width=80pt]{% \blank[-12pt] \placelist [section] [alternative=d, maxwidth=\hsize, width=\hsize, maxwidth=75pt, offset=0pt, criterium=all, align=meddle, style=\tfa] } thank you! ps. I am a chinese, my english is poor. -- 使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/ null string line Description: Binary data ___ 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 ___