[NTG-context] changes of color
Hi everybody After some part of a tex file where there is some startMPcode section the color of the text (e.g. blue) changes to black up until the next page in the pdf. Is there something I am missing ? Thank you. Thierry ___ 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 ___
[NTG-context] io.loaddata() or buffer.assigns()
Hi everybody Are there any type of files that is required by io.loaddata or/and buffers.assign ? The following code works pretty well if there is no compilation problem by g++. But it fails, i.e. \typebuffer[Mybuffer], does not produce anything if g++ fails (due to some errors in the cpp) I have checked that err.cpp is well and truly created when g++ fails. \startluacode io.savedata("complx.h",buffers.getcontent("MyBuffer1")) io.savedata("complx.cpp",buffers.getcontent("MyBuffer2")) io.savedata("testcomplx.cpp",buffers.getcontent("MyBuffer3")) local l=os.execute("g++ -O3 -Wall -o testcomplx testcomplx.cpp complx.cpp 2> err.cpp") if l==0 then os.execute("./testcomplx > testcomplx.tmp") buffers.assign("MyBuffer",io.loaddata("testcomplx.tmp")) else buffers.assign("Mybuffer",io.open("err.cpp","r")) end \stopluacode Many thanks Thierry ___ 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 ___
Re: [NTG-context] getting line numbers
Thank you Hans. For what I had in mind (compiling some c++ inside a tex file) it seems to work. Anyway for this I am currently using the buffer and typebuffer solution you provide. T. Le Saturday 04 Sep 2021 à 10:35:34 (+0200), Hans Hagen a écrit : > there has always been > > \the\inputlineno > > but it is not always accurate (because content can come from anyplace, e.g. > lua) > > > - > Hans Hagen | PRAGMA ADE > Ridderstraat 27 | 8061 GH Hasselt | The Netherlands >tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] getting line numbers
Hi and thank you Aditaya and again Hans. By the way, just for fun , is there a(n easy) way to get the linenumber in the tex file ? Thanks On 03/09/2021 18:04, ntg-context-requ...@ntg.nl wrote: -- Message: 4 Date: Fri, 3 Sep 2021 14:16:40 +0200 From: Hans Hagen To: mailing list for ConTeXt users Cc: Thierry Horsin Subject: Re: [NTG-context] getting line numbers Message-ID: <807e4b7c-97ae-e20e-3207-28393544c...@xs4all.nl> Content-Type: text/plain; charset=utf-8; format=flowed in this case, thinking a bit different is easier ... \starttext \startbuffer[MyBuffer] #include using namespace std; int mysum(int,int); int a; int b; int main () { a=2; b=9; cout << mysum(a,b) << endl; return 0; } int mysum(int a, int b) { return a+b; } \stopbuffer We compile and run: \typebuffer[MyBuffer][option=C] \startluacode io.savedata("test.cpp",buffers.getcontent("MyBuffer")) --os.execute("g++ -o test test.cpp") --os.execute("./test > test.tmp") os.execute("echo done > test.tmp") buffers.assign("MyBuffer",io.loaddata("test.tmp")) \stopluacode And get: \typebuffer[MyBuffer] Or just: \typefile{test.tmp} \stoptext - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl - -- ------ Message: 6 Date: Fri, 3 Sep 2021 09:53:58 -0400 (EDT) From: Aditya Mahajan To: Thierry Horsin via ntg-context Subject: Re: [NTG-context] getting line numbers Message-ID: Content-Type: text/plain; charset=US-ASCII On Fri, 3 Sep 2021, Thierry Horsin via ntg-context wrote: https://github.com/adityam/filter Behind the scenes, it works by saving the content in an external file and then running it through any external program. It also allows for caching the result, and has many options for customizing the behavior. 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 ___
Re: [NTG-context] getting line numbers
Many thanks Hans. Thierry Le Friday 03 Sep 2021 à 14:16:40 (+0200), Hans Hagen a écrit : > in this case, thinking a bit different is easier ... > > \starttext > > \startbuffer[MyBuffer] > #include > > using namespace std; > int mysum(int,int); > int a; int b; > int main () { > a=2; b=9; > cout << mysum(a,b) << endl; > return 0; > } > int mysum(int a, int b) { > return a+b; > } > \stopbuffer > > We compile and run: > > \typebuffer[MyBuffer][option=C] > > \startluacode > io.savedata("test.cpp",buffers.getcontent("MyBuffer")) > --os.execute("g++ -o test test.cpp") > --os.execute("./test > test.tmp") > os.execute("echo done > test.tmp") > buffers.assign("MyBuffer",io.loaddata("test.tmp")) > \stopluacode > > And get: > > \typebuffer[MyBuffer] > > Or just: > > \typefile{test.tmp} > > \stoptext > > > - > Hans Hagen | PRAGMA ADE > Ridderstraat 27 | 8061 GH Hasselt | The Netherlands >tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
[NTG-context] getting line numbers
Hi everybody Is there a way to have an automatic access to the current line number of a specific place inside a tex file ? To be more precise, here is what I would like to do. I am currently trying to have some automatic external compilation by g++ of some portion of my tex file as in the following example below. \startC \stopC defines a framed part of text written between lines 538 and 549. Of course, if I add something before or inbetween my framed code, 538 and/or 549 will change. Thus I would like to get these two numbers automatically. Thank you. Thierry \startC #include using namespace std; int mysum(int,int); int a; int b; int main () { a=2; b=9; cout << mysum(a,b) << endl; return 0; } int mysum(int a, int b) { return a+b; } \stopC \startluacode myout = io.open("test.cpp", "w") myin = io.open(tex.jobname..".tex", "r") local n=0 for line in myin:lines() do n=n+1 if n>539 and n<550 then myout:write(line.."\n") end end myout:close() myin:close() os.execute("g++ -o test test.cpp") os.execute("./test > tmp") local file=assert(io.open("tmp","r")) local t = file:read("*all") tex.print(t) \stopluacode ___ 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 ___
Re: [NTG-context] No formula in the pdf (Ursula Hermann)
Hi Ursula, I tried your formula. The reason might be because you have two \starttext... Thierry ___ 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 ___
Re: [NTG-context] Curiosity about math.random in LuaTeX
Hi again, Many thanks to Hans and Hans and Henri. The solution (going to low level) provided by Hans works fine. Best Thierry Le Monday 23 Aug 2021 à 17:13:00 (+0200), Hans Hagen a écrit : > On 8/23/2021 4:46 PM, Thierry Horsin via ntg-context wrote: > > Hi everybody. > > > > I wonder how does math.random() work in context. I found that this subject > > was discussed more than ten years ago by Otared and Taco and Thomas. It is > > clear to me how to obtain new results upon typesetting the same file by > > changing the value of math.randomseed (with os.time()). > > > > If you don't change the seed, you get the same result upon each > > typesetting, and a seed is given in the .tuc file. > > > > For example I have this: > > ["randomseed"]=0x1.0741c18b8a4ep-6 > > > > How do I use (and is it possible to) this value to have the same result of > > math.random() upon typesetting another file (with a different name) ? > > > > I could provide a same fixed seed in both files, but for some reasons I > > would like to re-use some previous results of math.random() for which no > > seed was initially given in another .tex file. > You have to go low level ... > > % \ctxlua{utilities.randomizer.setseed(0x1.0741c18b8a4ep-6)} > % \ctxlua{utilities.randomizer.setseed(0x1.6822232009d5p-5)} > > \setrandomseed{123} > > \starttext > test \randomnumber{1}{100} > test \randomnumber{1}{100} > test \randomnumber{1}{100} > \stoptext > > btw, the 0x representation is lua's low level binary representation of a > double. > > Hans > > - > Hans Hagen | PRAGMA ADE > Ridderstraat 27 | 8061 GH Hasselt | The Netherlands >tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] Curiosity about math.random in LuaTeX
Hi everybody. I wonder how does math.random() work in context. I found that this subject was discussed more than ten years ago by Otared and Taco and Thomas. It is clear to me how to obtain new results upon typesetting the same file by changing the value of math.randomseed (with os.time()). If you don't change the seed, you get the same result upon each typesetting, and a seed is given in the .tuc file. For example I have this: ["randomseed"]=0x1.0741c18b8a4ep-6 How do I use (and is it possible to) this value to have the same result of math.random() upon typesetting another file (with a different name) ? I could provide a same fixed seed in both files, but for some reasons I would like to re-use some previous results of math.random() for which no seed was initially given in another .tex file. Thank you Thierry ___ 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 ___