Re: [NTG-context] Code document and simpleslides and create in one go the document with simpleslides added
> > > One final question on this one. As per latest comments this works great, > but is there a way so the presentation pages in the appendix are made-up > landscape as they are now, but are rotated 90 degrees so they are created > in the pdf document as the first two pages. \startbuffer[slides] \setuptolerance[ horizontal, tolerant, stretch] \setuppapersize[ A4,landscape] \setuplayout[ width=middle, backspace=35mm, cutspace=35mm, height=middle, topspace=5mm, bottomspace=20mm] \setuppagenumbering[ location={footer,center}] \setuphead [section] [page={yes}] \usetypescript[pagella] \setupbodyfont[pagella,18pt] \setupbodyfontenvironment[ 28pt][ % For body d=36pt, % For title a=12pt, % For author & date ] \setuptype[style=medium] \setuptyping[typing][bodyfont=16pt] \setupwhitespace[medium] \setbreakpoints[compound] \setuphead[chapter][style=\bfd] \setuphead[section][style=\bfc] \setuphead[subsection][style=\bfb] \setuphead[subsubsection][style=\bf] \setupitemize[autointro] % prevent orphan list intro \setupitemize[indentnext=no] \starttext \startsection[title={MySlideTitle},ref={myref1}] Body text \startitemize \item Item 1 \item Item 2 \stopitemize \stopsection \startsection[title={MySlideTitle},ref={myref2}] Body text \startitemize \item Item 1 \item Item 2 \stopitemize \stopsection \stoptext\starttext text \stoptext \stopbuffer \savebuffer[list=slides, file=slides.tex] \starttext \startbodymatter \dorecurse{10}{\input zapf\par} \typesetfile[\jobname-slides.tex][--purgeall][object=no, width=0pt] \stopbodymatter \startappendices \getfiguredimensions[\jobname-slides.pdf] \dorecurse{\noffigurepages} {\startTEXpage \externalfigure[\jobname-slides.pdf][page=\recurselevel] \stopTEXpage} \stopappendices \stoptext ___ 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] Code document and simpleslides and create in one go the document with simpleslides added
On 7/31/21 10:23 PM, Jeroen via ntg-context wrote: > [...] > \savebuffer[list=slides, file=\jobname_slides.tex, prefix=no] Sorry, Jeroen, this was my fault. A simpler approach to the command above reads: \savebuffer[list=slides, file=slides.tex] But then you have to invoke the file as \typesetfile[\jobname-slides.tex][--purgeall][object=no, width=0pt] and the output file would read: \getfiguredimensions[\jobname-slides.pdf] \dorecurse{\noffigurepages} {\startTEXpage \externalfigure[\jobname-slides.pdf][page=\recurselevel] \stopTEXpage} I mean, you get hyphen instead of underscore. I hope it may help, Pablo -- http://www.ousia.tk ___ 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] Code document and simpleslides and create in one go the document with simpleslides added
On 8/1/2021 3:02 PM, Wolfgang Schuster wrote: Hans Hagen via ntg-context schrieb am 01.08.2021 um 13:56: On 7/31/2021 10:23 PM, Jeroen via ntg-context wrote: I worked around it, instead of simpleslides just use larger fonts to with regular pages Tne next version will have this (easy cheap extension): [...] after that you have a file -slide.tex that has the slides that you can process (or include in a wrapper): Is there a way to set a folder for \typesetfile where I can put files similar to \setupexternalfigure[directory=...] or \usepath[...] At the moment I can use \typesetfile only when the processed file is in the same folder as the main tex file. It would be nicer to have a sub folder (e.g. examples) where I can put the files and \typesetfile creates the pdf in this folder to prevent clutter in the main folder. i;ll add support for 'directory' \definesavebuffer[slide] \setupsavebuffer[slide][directory=tempdir] - 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] Code document and simpleslides and create in one go the document with simpleslides added
Hans Hagen via ntg-context schrieb am 01.08.2021 um 13:56: On 7/31/2021 10:23 PM, Jeroen via ntg-context wrote: I worked around it, instead of simpleslides just use larger fonts to with regular pages Tne next version will have this (easy cheap extension): [...] after that you have a file -slide.tex that has the slides that you can process (or include in a wrapper): Is there a way to set a folder for \typesetfile where I can put files similar to \setupexternalfigure[directory=...] or \usepath[...] At the moment I can use \typesetfile only when the processed file is in the same folder as the main tex file. It would be nicer to have a sub folder (e.g. examples) where I can put the files and \typesetfile creates the pdf in this folder to prevent clutter in the main folder. 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] Code document and simpleslides and create in one go the document with simpleslides added
On 7/31/2021 10:23 PM, Jeroen via ntg-context wrote: I worked around it, instead of simpleslides just use larger fonts to with regular pages Tne next version will have this (easy cheap extension): \definesavebuffer[slide] \startslide % styling \stopslide \starttext \startslide \starttext \stopslide \startslide slide 1 \stopslide text 1 \par \startslide slide 2 \stopslide text 2 \par \startslide slide 3 \stopslide text 3 \par \startslide \stoptext \stopslide \stoptext after that you have a file -slide.tex that has the slides that you can process (or include in a wrapper): % styling \starttext slide 1 slide 2 slide 3 \stoptext 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] Code document and simpleslides and create in one go the document with simpleslides added
I worked around it, instead of simpleslides just use larger fonts to with regular pages \startbuffer[slides] \setuptolerance[ horizontal, tolerant, stretch] \setuppapersize[ A4,landscape] \setuplayout[ width=middle, backspace=35mm, cutspace=35mm, height=middle, topspace=5mm, bottomspace=20mm] \setuppagenumbering[ location={footer,center}] \setuphead [section] [page={yes}] \usetypescript[pagella] \setupbodyfont[pagella,18pt] \setupbodyfontenvironment[ 28pt][ % For body d=36pt, % For title a=12pt, % For author & date ] \setuptype[style=medium] \setuptyping[typing][bodyfont=16pt] \setupwhitespace[medium] \setbreakpoints[compound] \setuphead[chapter][style=\bfd] \setuphead[section][style=\bfc] \setuphead[subsection][style=\bfb] \setuphead[subsubsection][style=\bf] \setupitemize[autointro] % prevent orphan list intro \setupitemize[indentnext=no] \starttext \startsection[title={MySlideTitle},ref={myref1}] Body text \startitemize \item Item 1 \item Item 2 \stopitemize \stopsection \startsection[title={MySlideTitle},ref={myref2}] Body text \stopsection \stoptext\starttext text \stoptext \stopbuffer \savebuffer[list=slides, file=\jobname_slides.tex, prefix=no] \starttext \startbodymatter \dorecurse{25}{\input zapf\par} \typesetfile[\jobname_slides.tex][--purgeall][object=no, width=0pt] \stopbodymatter \startappendices \getfiguredimensions[\jobname_slides.pdf] \dorecurse{\noffigurepages} {\startTEXpage \externalfigure[\jobname_slides.pdf][page=\recurselevel] \stopTEXpage} \stopappendices \stoptext Op za 31 jul. 2021 om 16:22 schreef Thomas A. Schmitz via ntg-context < ntg-context@ntg.nl>: > > On 7/31/21 4:06 PM, Pablo Rodriguez via ntg-context wrote: > > BTW, I cannot get simpleslides working with LMTX. > > > I had to make some slight adjustments but have been to lazy to upload a > new and improved version. One reason being that I can't remember my > username and password for the modules section of the garden... I'll have > to ask Taco to reset it for me. > > Thomas > > ___ > 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 > > ___ > ___ 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] Code document and simpleslides and create in one go the document with simpleslides added
On 7/31/21 4:06 PM, Pablo Rodriguez via ntg-context wrote: BTW, I cannot get simpleslides working with LMTX. I had to make some slight adjustments but have been to lazy to upload a new and improved version. One reason being that I can't remember my username and password for the modules section of the garden... I'll have to ask Taco to reset it for me. Thomas ___ 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] Code document and simpleslides and create in one go the document with simpleslides added
On 7/31/21 3:27 PM, Jeroen via ntg-context wrote: Is there an easy way to write a Context document and also code simpleslides in the same document so that the simpleslides are automatically added to the document as for example an appendix? Ie one tex document with Context code, perhaps with some \input and something like a two-pass job. I was thinking if the simpleslides could be saved as a number of png images and then with the recurse add them to the document with placefigure. "Easy" is an ambiguous term... I can tell you how I do this (I use xml, but with a bit of code, this can be adapted to TeX documents): I have the code for the slides and my own comments in the same documents; I pass a --mode to the compilation to filter and select content. When I have my presentation as a file "presentation.pdf," I save it and then have the slides included automatically via a counter, like this: function xml.functions.combined_slide(t) i = i + 1 local textwidth = tex.dimen.textwidth context.page() context.framed( { width=number.todimen(textwidth), frame="off", align="middle", height="10cm" }, function() context.externalfigure( { "presentation.pdf" }, { page=i, width="13cm" } ) end ) context.blank { "line" } end So, as others have said: no need to convert to png. Setting up a workflow takes some time and thought, but once it's in place, it works very well; I have now used my xml-based workflow for 12 years or so, for all my university lectures and talks. Thomas ___ 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] Code document and simpleslides and create in one go the document with simpleslides added
On 7/31/21 3:27 PM, Jeroen via ntg-context wrote: > Is there an easy way to write a Context document and also code > simpleslides in the same document so that the simpleslides are > automatically added to the document as for example an appendix? Ie > one tex document with Context code, perhaps with some \input and > something like a two-pass job. Hi Jeroen, not sure this might help you (I’m not sure you intend a single source file, in addition to a single PDF document), but here you have: \startbuffer[slides] \setuppapersize[CD] \setupbodyfont[60pt] \starttext \dorecurse{25} {\startmakeup[standard][pagestate=start, style={\ss\bf}, align=center] Slide \pagenumber \stopmakeup} \stoptext \stopbuffer \savebuffer[list=slides, file=\jobname_slides.tex, prefix=no] \starttext \startbodymatter \dorecurse{25}{\input zapf\par} \typesetfile[\jobname_slides.tex][--purgeall][object=no, width=0pt] \stopbodymatter \startappendices \getfiguredimensions[\jobname_slides.pdf] \dorecurse{\noffigurepages} {\startTEXpage \externalfigure[\jobname_slides.pdf][page=\recurselevel] \stopTEXpage} \stopappendices \stoptext BTW, I cannot get simpleslides working with LMTX. > I was thinking if the simpleslides could be saved as a number of png > images and then with the recurse add them to the document with > placefigure. \externalfigure is your friend here and there is no need to convert the slides to PNG (see above). Just in case it may help, Pablo -- http://www.ousia.tk ___ 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] Code document and simpleslides and create in one go the document with simpleslides added
> Am 31.07.2021 um 15:27 schrieb Jeroen via ntg-context : > > Is there an easy way to write a Context document and also code simpleslides > in the same document so that the simpleslides are automatically added to the > document as for example an appendix? Ie one tex document with Context code, > perhaps with some \input and something like a two-pass job. I was thinking if > the simpleslides could be saved as a number of png images and then with the > recurse add them to the document with placefigure. Why via PNG? And why recurse? You can include PDFs. Try \copypages or \filterpages. Hraban ___ 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] code 139
On 1/29/2021 6:09 PM, Thomas A. Schmitz wrote: On 29. Jan 2021, at 17:55, Otared Kavian wrote: Out of curiosity I tested your MWE and I get mtx-context | fatal error: return code: 11 Maybe lmtx uses the random number generator to produce its return codes? :-) 139 is gcc mem warning anyway, thomas' MWE wasn't minimal enough {\tracingall\framed[align=right]{\em x}} and even better: {\tracingall\framed[align=right]{x\aftergroup\relax}} it might give you a clue as it did me .. the randomizer is only used to smuggle jokes into your text (only when there are more than 200 pages and 30% of the symbols is greek) 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] code 139
> On 29. Jan 2021, at 17:55, Otared Kavian wrote: > > Out of curiosity I tested your MWE and I get > > mtx-context | fatal error: return code: 11 Maybe lmtx uses the random number generator to produce its return codes? :-) Thomas ___ 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] code 139
Hi Thomas, Out of curiosity I tested your MWE and I get mtx-context | fatal error: return code: 11 with LMTX (version 2021.01.28 18:22), while with mkiv it typesets correctly. Best regards: Otared > On 29 Jan 2021, at 14:42, Thomas A. Schmitz > wrote: > > > On 1/29/21 12:56 PM, Hans Hagen wrote: >> Hard to say (probably some mem/stack issue) ... you can add a \tracingall >> around the place where the last message to the console happens ... i need to >> know where it happens (or you can themn make a mwe of that bit). > > OK, here's a minimal example. I defined this environment some years ago and > have no clue why I did it this particular way (there must have been a > reason), so don't ask me. But it gives the "return code: 139." > > \define[1]\italianpoetry% > {\framed[frame=off,offset=0pt,strut=no,width=10cm]{\framed[frame=off,strut=no,offset=0pt,width=fit,align=right]{\em > #1}}} > > \starttext > > \italianpoetry{ > Morremo. Il velo indegno a terra sparto, > } > > \stoptext > > Thomas > ___ > 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 > ___ ___ 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] code 139
> On 29. Jan 2021, at 16:27, Hans Hagen wrote: > > fixed in next upload Thank you for the fix! Thomas ___ 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] code 139
On 1/29/2021 2:42 PM, Thomas A. Schmitz wrote: On 1/29/21 12:56 PM, Hans Hagen wrote: Hard to say (probably some mem/stack issue) ... you can add a \tracingall around the place where the last message to the console happens ... i need to know where it happens (or you can themn make a mwe of that bit). OK, here's a minimal example. I defined this environment some years ago and have no clue why I did it this particular way (there must have been a reason), so don't ask me. But it gives the "return code: 139." \define[1]\italianpoetry% {\framed[frame=off,offset=0pt,strut=no,width=10cm]{\framed[frame=off,strut=no,offset=0pt,width=fit,align=right]{\em #1}}} \starttext \italianpoetry{ Morremo. Il velo indegno a terra sparto, } \stoptext fixed in next upload - 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] code 139
On 1/29/21 12:56 PM, Hans Hagen wrote: Hard to say (probably some mem/stack issue) ... you can add a \tracingall around the place where the last message to the console happens ... i need to know where it happens (or you can themn make a mwe of that bit). OK, here's a minimal example. I defined this environment some years ago and have no clue why I did it this particular way (there must have been a reason), so don't ask me. But it gives the "return code: 139." \define[1]\italianpoetry% {\framed[frame=off,offset=0pt,strut=no,width=10cm]{\framed[frame=off,strut=no,offset=0pt,width=fit,align=right]{\em #1}}} \starttext \italianpoetry{ Morremo. Il velo indegno a terra sparto, } \stoptext Thomas ___ 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] code 139
On 1/29/2021 12:15 PM, Thomas A. Schmitz wrote: Hi all, a complex file with a metafun background does not compile anymore with lmtx. It compiles fine with mkiv. Compilation breaks off after 10 pages (maybe that's significant) with this message: pages > flushing realpage 10, userpage 10, subpage 10 mtx-context | fatal error: return code: 139 What is code: 139? Where should I start looking for the culprit? Hard to say (probably some mem/stack issue) ... you can add a \tracingall around the place where the last message to the console happens ... i need to know where it happens (or you can themn make a mwe of that bit). 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] Code lua in a table
Hello, I am making progress and I almost get what I want to achieve but I still have two problems : how to color cells not containing numbers with the same color as the others ? how to color in salmon, for example, cells 1 2 ? 3 Thank you Fabrice \usecolors[X11] \startuseMPgraphic{DiagonalRule} rulethickness := \frameddimension{rulethickness}; drawoptions( withpen pencircle scaled rulethickness withcolor \MPcolor{\framedparameter{framecolor}}); pair leftcorner, rightcorner; leftcorner := (rulethickness, \overlayheight-rulethickness); rightcorner := (\overlaywidth-rulethickness, rulethickness); draw leftcorner -- rightcorner; \stopuseMPgraphic \defineoverlay [DiagonalRule] [\useMPgraphic{DiagonalRule}] \define[2]\DiagonalLabel{% \setuptabulate [after={\blank[\frameddimension{offset}]}] \starttabulate [|p|r|] \NC\NC #2 \NC\NR \NC #1 \NC\NC\NR \stoptabulate } \starttext \startluacode function Binom(n,k) if k > n then return "" elseif (n == 0 or k == 0) then return 1 else return math.round((n*Binom(n-1,k-1))/k) end end context.startxtable({"align={middle,lohi}, width=1cm,offset=0.8ex,bodyfont=9pt,framecolor=cyan"}) context.startxrow() context.startxcell({"background=DiagonalRule,background=color,backgroundcolor=thistle2"}) context("\\DiagonalLabel{\\m{n}}{\\m{k}}") context.stopxcell() for j = 0, 7 do context.startxcell({"background=color,backgroundcolor=thistle2"}) context(j) context.stopxcell() end context.startxcell({"background=color,backgroundcolor=thistle2"}) context("\\dots") context.stopxcell() context.stopxrow() for i = 0, 7 do context.startxrow() context.startxcell({"background=color,backgroundcolor=thistle2"}) context(i) context.stopxcell() for j = 0, 8 do context.startxcell() context(Binom(i,j)) context.stopxcell() end context.stopxrow() end context.startxrow() context.startxcell({"background=color,backgroundcolor=thistle2"}) context("\\dots") context.stopxcell() for i = 0, 8 do context.startxcell({"background=color,backgroundcolor=thistle2"}) context("") context.stopxcell() end context.stopxrow() context.stopxtable() \stopluacode \stoptext Le lun. 20 juil. 2020 à 14:55, Hans Hagen a écrit : > On 7/20/2020 2:40 PM, Jeong Dal wrote: > > > I also wonder where is the boundary of ConTeXt. > The boundaries are set and shift by users (the mailing list) and > curiosity (personal). > > 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 > > ___ > ___ 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] Code lua in a table
Dear Hans, Thank you for new methods! It would take some time for me to understand them fully. Learning Lua, metafun, lmtx, wiki is always a challenge for me. I also wonder where is the boundary of ConTeXt. I hope that you and all members in this list are well from COVID-19. Thank you again. Best regards, Dalyoung > 2020. 7. 20. 오후 5:36, Hans Hagen 작성: > > On 7/20/2020 7:56 AM, Jeong Dal wrote: >> Dear Fabrice, >> You may split Binom(n,k) function into two functions as following: > > see original mail > > >> Dalyoung > Best stay in a protected namespace ... > > \startluacode > >local function fact (n) >if n <= 0 then >return 1 >else >return n * fact(n-1) >end >end > >local function ncr(n,r) >return fact(n)/(fact(r)*fact(n-r)) >end > >userdata.P = { >fact = fact, >ncr = ncr, >} > >function MP.pascal_ncr(n, r) >mp.print(ncr(n,r)) >end > > \stopluacode > > Watch the last definition. This permits > > % tt := lua("mp.print(userdata.P.ncr(" & decimal n & "," & decimal r & " > ))"); > > replaced by > >tt := lua.MP.pascal_ncr(n,r); > > which looks nicer. > > \startbuffer[pt1] >numeric n, r, s, u, dx, dy, tt; >path p, q; >pair A, B, start, now; >u := 1.8cm; >A := dir(210)*u; >B := dir(-30)*u; >dy := sind(30)*u; >dx := 2*cosd(30)*u; >for n=0 upto 4: >start := n*dir(210)*u; >for r=0 upto n: >s := n-r; > % tt := lua("mp.print(userdata.P.ncr(" & decimal n & "," & decimal r > & " ))"); > tt := lua.MP.pascal_ncr(n,r); >now := start+r*right*dx; >dotlabel.top(textext("$\displaystyle {" & decimal n & "\choose" & > decimal r & "} = "& decimal tt & "$"),now); >draw (now+A) -- now -- (now+B); >endfor; >endfor; > \stopbuffer > > Now, in context lmtx we can have a different kind of abstraction. We can do > this: > >function MP.pascal_ncr_x() >mp.print(ncr(mp.scan.pair())) >end > > and then use: > >tt := runscript("MP.pascal_ncr_x()") (n,r) ; > > Of course one can decide to pick to two numerics instead, like > >tt := runscript("MP.pascal_ncr_x()") n r ; > > but i leave that as exercise. > > % tt := runscript mp_pascal_ncr (n,r) ; >tt := pascal_ncr (n,r) ; > > However, we still have the rather verbose runscript here, so we go further, > we register pascal as script: > > \startluacode >metapost.registerscript("pascal_ncr",MP.pascal_ncr_x) > \stopluacode > > And then define an alias at the metafun end: > > \startMPextensions >newinternal mp_pascal_ncr ; mp_pascal_ncr := scriptindex "pascal_ncr" ; > >def pascal_ncr = >runscript mp_pascal_ncr >enddef ; > \stopMPextensions > > The internal permits this: > > tt := runscript mp_pascal_ncr (n,r) ; > > while the additional def permits > >tt := pascal_ncr (n,r) ; > > Now watch out, because we define pascal_ncr here, something > lua.MP.pascal_ncr(n,r) won't work because the last part gets expanded because > that is what mp does (i'll probably cook something for that some day). > > Now, to come back to > > "I couldn’t wikify it at that time because I don’t know >how to. I’ll do it soon." > > looks like you suddenly have an additional challenge, > > 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] Code lua in a table
On 7/20/2020 2:40 PM, Jeong Dal wrote: I also wonder where is the boundary of ConTeXt. The boundaries are set and shift by users (the mailing list) and curiosity (personal). 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] Code lua in a table
Hi all, Thank you for your contributions, it allows me to progress. @Hans and Deal The code is impressive but does not correspond to the shape of the triangle that I have to make (by convention). Fabrice Le lun. 20 juil. 2020 à 10:36, Hans Hagen a écrit : > On 7/20/2020 7:56 AM, Jeong Dal wrote: > > Dear Fabrice, > > > > You may split Binom(n,k) function into two functions as following: > > > > see original mail > > > > Dalyoung > Best stay in a protected namespace ... > > \startluacode > > local function fact (n) > if n <= 0 then > return 1 > else > return n * fact(n-1) > end > end > > local function ncr(n,r) > return fact(n)/(fact(r)*fact(n-r)) > end > > userdata.P = { > fact = fact, > ncr = ncr, > } > > function MP.pascal_ncr(n, r) > mp.print(ncr(n,r)) > end > > \stopluacode > > Watch the last definition. This permits > >% tt := lua("mp.print(userdata.P.ncr(" & decimal n & "," & > decimal r & " ))"); > > replaced by > > tt := lua.MP.pascal_ncr(n,r); > > which looks nicer. > > \startbuffer[pt1] > numeric n, r, s, u, dx, dy, tt; > path p, q; > pair A, B, start, now; > u := 1.8cm; > A := dir(210)*u; > B := dir(-30)*u; > dy := sind(30)*u; > dx := 2*cosd(30)*u; > for n=0 upto 4: > start := n*dir(210)*u; > for r=0 upto n: > s := n-r; >% tt := lua("mp.print(userdata.P.ncr(" & decimal n & "," & > decimal r & " ))"); >tt := lua.MP.pascal_ncr(n,r); > now := start+r*right*dx; > dotlabel.top(textext("$\displaystyle {" & decimal n & > "\choose" & decimal r & "} = "& decimal tt & "$"),now); > draw (now+A) -- now -- (now+B); > endfor; > endfor; > \stopbuffer > > Now, in context lmtx we can have a different kind of abstraction. We can > do this: > > function MP.pascal_ncr_x() > mp.print(ncr(mp.scan.pair())) > end > > and then use: > > tt := runscript("MP.pascal_ncr_x()") (n,r) ; > > Of course one can decide to pick to two numerics instead, like > > tt := runscript("MP.pascal_ncr_x()") n r ; > > but i leave that as exercise. > >% tt := runscript mp_pascal_ncr (n,r) ; > tt := pascal_ncr (n,r) ; > > However, we still have the rather verbose runscript here, so we go > further, we register pascal as script: > > \startluacode > metapost.registerscript("pascal_ncr",MP.pascal_ncr_x) > \stopluacode > > And then define an alias at the metafun end: > > \startMPextensions > newinternal mp_pascal_ncr ; mp_pascal_ncr := scriptindex "pascal_ncr" > ; > > def pascal_ncr = > runscript mp_pascal_ncr > enddef ; > \stopMPextensions > > The internal permits this: > > tt := runscript mp_pascal_ncr (n,r) ; > > while the additional def permits > > tt := pascal_ncr (n,r) ; > > Now watch out, because we define pascal_ncr here, something > lua.MP.pascal_ncr(n,r) won't work because the last part gets expanded > because that is what mp does (i'll probably cook something for that some > day). > > Now, to come back to > > "I couldn’t wikify it at that time because I don’t know > how to. I’ll do it soon." > > looks like you suddenly have an additional challenge, > > 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 > > ___ > ___ 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] Code lua in a table
Dear Fabrice, You may split Binom(n,k) function into two functions as following: * \startluacode P={} combi = P function P.fact (n) if n <= 0 then return 1 else return n * P.fact(n-1) end end function P.ncr(n,r) return P.fact(n)/(P.fact(r)*P.fact(n-r)) end combi = { fact = fact, ncr = ncr, } \stopluacode ** Your table is actually Pascal’d triangle. Using the above function, I was able to draw Pascal’s triangles. Hans helped me to complete it. I couldn’t wikify it at that time because I don’t know how to. I’ll do it soon. Here is the whole code for Pascal’s triangle in two different ways using Lua, Metafun and ConTeXt. You may enhance the code. \startbuffer[pt1] numeric n,r,s,u,dx,dy,tt; u := 1.8cm; path p, q; pair A,B,start,now; A := dir(210)*u; B := dir(-30)*u; dy := sind(30)*u; dx := 2*cosd(30)*u; for n=0 upto 4: start := n*dir(210)*u; for r=0 upto n: s := n-r; tt := lua("mp.print(P.ncr(" & decimal n & "," & decimal r & " ))"); now := start+r*right*dx; dotlabel.top(textext("$\displaystyle {" & decimal n & "\choose" & decimal r & "} = "& decimal tt & "$"),now); draw (now+A) -- now -- (now+B); endfor; endfor; \stopbuffer \startbuffer[pt2] numeric n,r,s,u,dx,dy,tt; u := 1cm; path p, q; pair A,B,start,now; A := dir(210)*u; B := dir(-30)*u; dy := sind(30)*u; dx := 2*cosd(30)*u; for n=0 upto 8: start := n*dir(210)*u; for r=0 upto n: s := n-r; tt := lua("mp.print(P.ncr(" & decimal n & "," & decimal r & " ))"); now := start+r*right*dx; label(textext("$" & decimal tt & "$"),now); endfor; endfor; \stopbuffer \startluacode P={} combi = P function P.fact (n) if n <= 0 then return 1 else return n * P.fact(n-1) end end function P.ncr(n,r) return P.fact(n)/(P.fact(r)*P.fact(n-r)) end combi = { fact = fact, ncr = ncr, } \stopluacode \starttext \processMPbuffer[pt1] \blank[big] \processMPbuffer[pt2] \stoptext I hope that it helps. 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] Code lua in a table
On 7/20/2020 7:56 AM, Jeong Dal wrote: Dear Fabrice, You may split Binom(n,k) function into two functions as following: > see original mail > Dalyoung Best stay in a protected namespace ... \startluacode local function fact (n) if n <= 0 then return 1 else return n * fact(n-1) end end local function ncr(n,r) return fact(n)/(fact(r)*fact(n-r)) end userdata.P = { fact = fact, ncr = ncr, } function MP.pascal_ncr(n, r) mp.print(ncr(n,r)) end \stopluacode Watch the last definition. This permits % tt := lua("mp.print(userdata.P.ncr(" & decimal n & "," & decimal r & " ))"); replaced by tt := lua.MP.pascal_ncr(n,r); which looks nicer. \startbuffer[pt1] numeric n, r, s, u, dx, dy, tt; path p, q; pair A, B, start, now; u := 1.8cm; A := dir(210)*u; B := dir(-30)*u; dy := sind(30)*u; dx := 2*cosd(30)*u; for n=0 upto 4: start := n*dir(210)*u; for r=0 upto n: s := n-r; % tt := lua("mp.print(userdata.P.ncr(" & decimal n & "," & decimal r & " ))"); tt := lua.MP.pascal_ncr(n,r); now := start+r*right*dx; dotlabel.top(textext("$\displaystyle {" & decimal n & "\choose" & decimal r & "} = "& decimal tt & "$"),now); draw (now+A) -- now -- (now+B); endfor; endfor; \stopbuffer Now, in context lmtx we can have a different kind of abstraction. We can do this: function MP.pascal_ncr_x() mp.print(ncr(mp.scan.pair())) end and then use: tt := runscript("MP.pascal_ncr_x()") (n,r) ; Of course one can decide to pick to two numerics instead, like tt := runscript("MP.pascal_ncr_x()") n r ; but i leave that as exercise. % tt := runscript mp_pascal_ncr (n,r) ; tt := pascal_ncr (n,r) ; However, we still have the rather verbose runscript here, so we go further, we register pascal as script: \startluacode metapost.registerscript("pascal_ncr",MP.pascal_ncr_x) \stopluacode And then define an alias at the metafun end: \startMPextensions newinternal mp_pascal_ncr ; mp_pascal_ncr := scriptindex "pascal_ncr" ; def pascal_ncr = runscript mp_pascal_ncr enddef ; \stopMPextensions The internal permits this: tt := runscript mp_pascal_ncr (n,r) ; while the additional def permits tt := pascal_ncr (n,r) ; Now watch out, because we define pascal_ncr here, something lua.MP.pascal_ncr(n,r) won't work because the last part gets expanded because that is what mp does (i'll probably cook something for that some day). Now, to come back to "I couldn’t wikify it at that time because I don’t know how to. I’ll do it soon." looks like you suddenly have an additional challenge, 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] Code lua in a table
> On 18 Jul 2020, at 23:35, Otared Kavian wrote: > > > >> On 18 Jul 2020, at 22:25, Fabrice Couvreur >> wrote: >> >> Hi Wolfgang, >> >> It works but why did you ask this question since I finally use context ? >> Are you sure you want to use context(...) here? >> How not to display the .0 ? Or even better, you can return an integer in your Binom function: return math.round((n*Binom(n-1,k-1))/k) Best regards: Otared ___ 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] Code lua in a table
> On 18 Jul 2020, at 22:25, Fabrice Couvreur > wrote: > > Hi Wolfgang, > > It works but why did you ask this question since I finally use context ? > Are you sure you want to use context(...) here? > How not to display the .0 ? Besides what Wolfgang suggested, ou can also use context(math.round(Binom(i,j))) to have integers instead of real numbers. Best regards: Otared ___ 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] Code lua in a table
Fabrice Couvreur schrieb am 18.07.2020 um 22:25: Hi Wolfgang, It works but why did you ask this question since I finally use context ? Are you sure you want to use context(...) here? In your first version you used the context function in the loop to print the output of the Binom but the Binom function used context as well, this could result in context(context(...)). How not to display the .0 ? Format the content of the context function to show only integer values, e.g. context("%d",Binom(...)). For more information search for formatter in cld-mkiv.pdf. 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] Code lua in a table
Small correction : \starttext \startluacode function Binom(n,k) if k > n then return 0 elseif (n == 0 or k == 0) then return 1 else return (n*Binom(n-1,k-1))/k end end context.startxtable({"align={middle,lohi}, width=1cm,offset=0.8ex,bodyfont=9pt"}) for i = 0, 9 do context.startxrow({"background=color,backgroundcolor=cyan"}) for j = 0, i do context.startxcell() context(Binom(i,j)) context.stopxcell() end context.stopxrow() end context.stopxtable() \stopluacode \stoptext Le sam. 18 juil. 2020 à 22:25, Fabrice Couvreur a écrit : > Hi Wolfgang, > > It works but why did you ask this question since I finally use context ? > >> Are you sure you want to use context(...) here? >> > How not to display the .0 ? > Fabrice > > Le sam. 18 juil. 2020 à 22:22, Wolfgang Schuster < > wolfgang.schuster.li...@gmail.com> a écrit : > >> Fabrice Couvreur schrieb am 18.07.2020 um 22:09: >> > Hi, >> > I improved the code to be able to display the grid but I cannot display >> > the coefficients. >> > Thank you >> > Fabrice >> > >> > \starttext >> > >> > \startluacode >> > function Binom(n,k) >> > if k > n then >> > return 0 >> > elseif (n == 0 or k == 0) then >> > return 1 >> > else >> > return (n*Binom(n-1,k-1))/k >> > end >> > >> > end >> > >> > context.startxtable({"align={middle,lohi}, >> > width=1.2cm,offset=0.8ex,bodyfont=9pt"}) >> > for i = 1, 10 do >> >context.startxrow({"background=color,backgroundcolor=cyan"}) >> > for j = 1, i do >> >context.startxcell() >> > \ctxlua{context(Binom(i,j))} >> >> Remove \ctxlua: >> >> context(Binom(i,j)) >> >> 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://context.aanhet.net >> archive : https://bitbucket.org/phg/context-mirror/commits/ >> wiki : http://contextgarden.net >> >> ___ >> > ___ 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] Code lua in a table
Hi Wolfgang, It works but why did you ask this question since I finally use context ? > Are you sure you want to use context(...) here? > How not to display the .0 ? Fabrice Le sam. 18 juil. 2020 à 22:22, Wolfgang Schuster < wolfgang.schuster.li...@gmail.com> a écrit : > Fabrice Couvreur schrieb am 18.07.2020 um 22:09: > > Hi, > > I improved the code to be able to display the grid but I cannot display > > the coefficients. > > Thank you > > Fabrice > > > > \starttext > > > > \startluacode > > function Binom(n,k) > > if k > n then > > return 0 > > elseif (n == 0 or k == 0) then > > return 1 > > else > > return (n*Binom(n-1,k-1))/k > > end > > > > end > > > > context.startxtable({"align={middle,lohi}, > > width=1.2cm,offset=0.8ex,bodyfont=9pt"}) > > for i = 1, 10 do > >context.startxrow({"background=color,backgroundcolor=cyan"}) > > for j = 1, i do > >context.startxcell() > > \ctxlua{context(Binom(i,j))} > > Remove \ctxlua: > > context(Binom(i,j)) > > 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://context.aanhet.net > archive : https://bitbucket.org/phg/context-mirror/commits/ > wiki : http://contextgarden.net > > ___ > ___ 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] Code lua in a table
Fabrice Couvreur schrieb am 18.07.2020 um 22:09: Hi, I improved the code to be able to display the grid but I cannot display the coefficients. Thank you Fabrice \starttext \startluacode function Binom(n,k) if k > n then return 0 elseif (n == 0 or k == 0) then return 1 else return (n*Binom(n-1,k-1))/k end end context.startxtable({"align={middle,lohi}, width=1.2cm,offset=0.8ex,bodyfont=9pt"}) for i = 1, 10 do context.startxrow({"background=color,backgroundcolor=cyan"}) for j = 1, i do context.startxcell() \ctxlua{context(Binom(i,j))} Remove \ctxlua: context(Binom(i,j)) 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] Code lua in a table
Hi, I improved the code to be able to display the grid but I cannot display the coefficients. Thank you Fabrice \starttext \startluacode function Binom(n,k) if k > n then return 0 elseif (n == 0 or k == 0) then return 1 else return (n*Binom(n-1,k-1))/k end end context.startxtable({"align={middle,lohi}, width=1.2cm,offset=0.8ex,bodyfont=9pt"}) for i = 1, 10 do context.startxrow({"background=color,backgroundcolor=cyan"}) for j = 1, i do context.startxcell() \ctxlua{context(Binom(i,j))} context.stopxcell() end context.stopxrow() end context.stopxtable() \stopluacode \stoptext Le sam. 18 juil. 2020 à 20:32, Wolfgang Schuster < wolfgang.schuster.li...@gmail.com> a écrit : > Fabrice Couvreur schrieb am 18.07.2020 um 20:05: > > Hello, > I want to display the values of Pascal's triangle in a table. > Unfortunately my knowledge of Lua is not sufficient to run this code. > Thank you. > Fabrice > > \starttext > > \startluacode > function Binom(n,k) >if k > n then > return 0 >elseif (n == 0 or k == 0) then > return 1 >else > return (n*Binom(n-1,k-1))/k > end > context(Binom(n,k)) > > Are you sure you want to use context(...) here? > > end > > context.startxtable({"align={middle,lohi}, > width=1.2cm,offset=0.8ex,bodyfont=9pt"}) > context.startxrow({"background=color,backgroundcolor=green"}) > for i = 0, 10 do > for j = 0, i do > context.startxcell() > context(Binom(i,j)) > context.stopxcell() > end > end > context.stopxrow() > > context.stopxtable() > > 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://context.aanhet.net > archive : https://bitbucket.org/phg/context-mirror/commits/ > wiki : http://contextgarden.net > > ___ > ___ 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] Code lua in a table
Fabrice Couvreur schrieb am 18.07.2020 um 20:05: Hello, I want to display the values of Pascal's triangle in a table. Unfortunately my knowledge of Lua is not sufficient to run this code. Thank you. Fabrice \starttext \startluacode function Binom(n,k) if k > n then return 0 elseif (n == 0 or k == 0) then return 1 else return (n*Binom(n-1,k-1))/k end context(Binom(n,k)) Are you sure you want to use context(...) here? end context.startxtable({"align={middle,lohi}, width=1.2cm,offset=0.8ex,bodyfont=9pt"}) context.startxrow({"background=color,backgroundcolor=green"}) for i = 0, 10 do for j = 0, i do context.startxcell() context(Binom(i,j)) context.stopxcell() end end context.stopxrow() context.stopxtable() 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] Code that run in Metapost but not in starMPcode enviroment
On 2/1/2015 12:29 PM, DesdeChaves wrote: I'm trying to draw some random arrows using Metapost. For that I use a piece of code from fpast that in found at stackexchange http://tex.stackexchange.com/questions/179745/generating-random-arrows-in-tikz/180111#180111 Unfortunately this code does not work in context (request for a solution http://tex.stackexchange.com/questions/225864/metapost-error-related-with-context) because the freelabel() function. If I disable it the result is the expected. What is wrong with this code? \starttext \startMPcode numeric u, nb_vectors, wd; u := 1cm; % unit length nb_vectors := 20; wd = .5; boolean intersect; pair random_origin; color random_color; path candidate, random_vector[]; % vardef bb(expr p) = save orig, extr; pair orig, extr; orig = point 0 of p; extr = point 1 of p; pair v,w; v = wd*unitvector(extr-orig)*u; w = v rotated 90; (orig - v + w) -- (extr + v + w) -- (extr + v - w) -- (orig - v - w) -- cycle enddef; % pickup pencircle scaled 2bp; numeric i ; i = 1 ; i = 1; or i := 1 ; % never assume variable is not set global (such is mp) forever: exitunless (i = nb_vectors); intersect := false; random_length := u*(2+uniformdeviate(1)); random_angle := uniformdeviate(359); random_origin := u*(uniformdeviate(wd*nb_vectors), uniformdeviate(wd*nb_vectors)); random_color := (uniformdeviate(1), uniformdeviate(1), uniformdeviate(1)); candidate := random_origin -- (random_origin + random_length*dir(random_angle)); j := 1; forever: exitif (j = i) or (intersect = true); if bb(random_vector[j]) intersectiontimes bb(candidate) (-1, -1): intersect := true; fi; j := j+1; endfor; if intersect = false: random_vector[i] = candidate; drawarrow candidate withcolor random_color; freelabel(btex $v$ etex, point .5 of candidate, point .5 of candidate + dir (random_angle + 90)); i := i+1; fi; endfor; \stopMPcode \stoptext ___ 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 ___ -- - 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] Code that run in Metapost but not in starMPcode enviroment
Interestingly it seems to work in mkii, probably because mkii calls external metafun: Sorry, I didn't notice explanation by Hans. Best, Akira ___ 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] Code that run in Metapost but not in starMPcode enviroment
On 2/1/2015 3:31 PM, Akira Kakuto wrote: Interestingly it seems to work in mkii, probably because mkii calls external metafun: Sorry, I didn't notice explanation by Hans. The problem with variables in metapost is that they are global by default (unless 'save'd in a group or vardef). This means that one can best explicitly declare variables that are used. Of course one can also use a dedicated instance. 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] Code Called Twice?
···date: 2013-10-10, Thursday···from: Thangalin··· I noticed something unexpected with the following code: \enabletrackers[metapost.showlog] \startuseMPgraphic{heading:ThemeTitleStyle} show HEADING:THEMETITLESTYLE; show \MPstring{heading:title}; draw textext( \MPstring{heading:title} ) rotated 5 withcolor blue; \stopuseMPgraphic \defineframed[ThemeTitleStyle][ background=\useMPgraphic{ThemeTitleStyle}, ] \def\processword#1{% \setMPtext{heading:title}{#1}% \useMPgraphic{heading:ThemeTitleStyle} } \define[1]\ThemeChapterTitle{\applytosplitstringword\processword{#1}} \setuphead[chapter][deeptextcommand={\ThemeChapterTitle}] \starttext \startchapter[title=Why Is heading:ThemeTitleStyle Called Twice?] \input knuth \stopchapter \stoptext It appears as though heading:ThemeTitleStyle is being called twice: metapost info: HEADING:THEMETITLESTYLE Why metapost info: HEADING:THEMETITLESTYLE Why I am trying to produce a random number that is not equal to the previous random number. However, if the code is called twice, then I'd have to add code to ignore one of the calls. Any ideas why the code seems to be called twice and what can be done to ensure that it is only called once? Don’t use text ;-) That’s a known issue: as soon as your Metapost code contains text, it will be processed twice. E.g.: \starttext \setMPtext{heading:title}{foo} \startMPcode show This gets printed twice.; draw textext( \MPstring{heading:title} ); \stopMPcode \stoptext Same for labels, {b,e}tex. See also this thread: http://www.ntg.nl/pipermail/ntg-context/2011/056047.html Best regards, Philipp pgpClW2rfjEVB.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 ___
Re: [NTG-context] Code Called Twice?
On 2013–10–10 Thangalin wrote: I noticed something unexpected with the following code: \enabletrackers[metapost.showlog] \startuseMPgraphic{heading:ThemeTitleStyle} show HEADING:THEMETITLESTYLE; show \MPstring{heading:title}; draw textext( \MPstring{heading:title} ) rotated 5 withcolor blue; \stopuseMPgraphic […] It appears as though heading:ThemeTitleStyle is being called twice: If I'm not mistaken that's the way MP works when text is involved, it's a two-pass approach. In graphics without text MP has all information it needs to create the image. The text in MP graphics is typeset using TeX. After it's typeset MP picks it up in a second run. I am trying to produce a random number that is not equal to the previous random number. However, if the code is called twice, then I'd have to add code to ignore one of the calls. Maintain a vector with the last two elements to check against. Marco signature.asc Description: Digital 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 ___
Re: [NTG-context] Code Called Twice?
Hi, typeset using TeX. After it's typeset MP picks it up in a second run. That also explains why the spacing between words is correct (I didn't think MP could typeset text). Maintain a vector with the last two elements to check against. An interesting approach; I used a Boolean flag as per this thread: http://www.ntg.nl/pipermail/ntg-context/2011/056078.html Works as expected. Thank you for the all help! ___ 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] Code Called Twice?
On 10/11/2013 1:00 PM, Philipp Gesang wrote: ···date: 2013-10-10, Thursday···from: Thangalin··· I noticed something unexpected with the following code: \enabletrackers[metapost.showlog] \startuseMPgraphic{heading:ThemeTitleStyle} show HEADING:THEMETITLESTYLE; show \MPstring{heading:title}; draw textext( \MPstring{heading:title} ) rotated 5 withcolor blue; \stopuseMPgraphic \defineframed[ThemeTitleStyle][ background=\useMPgraphic{ThemeTitleStyle}, ] \def\processword#1{% \setMPtext{heading:title}{#1}% \useMPgraphic{heading:ThemeTitleStyle} } \define[1]\ThemeChapterTitle{\applytosplitstringword\processword{#1}} \setuphead[chapter][deeptextcommand={\ThemeChapterTitle}] \starttext \startchapter[title=Why Is heading:ThemeTitleStyle Called Twice?] \input knuth \stopchapter \stoptext It appears as though heading:ThemeTitleStyle is being called twice: metapost info: HEADING:THEMETITLESTYLE Why metapost info: HEADING:THEMETITLESTYLE Why I am trying to produce a random number that is not equal to the previous random number. However, if the code is called twice, then I'd have to add code to ignore one of the calls. Any ideas why the code seems to be called twice and what can be done to ensure that it is only called once? Don’t use text ;-) That’s a known issue: as soon as your Metapost code contains text, it will be processed twice. E.g.: \starttext \setMPtext{heading:title}{foo} \startMPcode show This gets printed twice.; draw textext( \MPstring{heading:title} ); \stopMPcode \stoptext Same for labels, {b,e}tex. See also this thread: http://www.ntg.nl/pipermail/ntg-context/2011/056047.html you can check for it: \enabletrackers[metapost.showlog] and in the mp code: message(if mfun_first_run : first run else : final run fi) ; message(if mfun_trial_run : trial run else : final run fi) ; 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] Code Called Twice?
···date: 2013-10-11, Friday···from: Hans Hagen··· On 10/11/2013 1:00 PM, Philipp Gesang wrote: ···date: 2013-10-10, Thursday···from: Thangalin··· I noticed something unexpected with the following code: \enabletrackers[metapost.showlog] \startuseMPgraphic{heading:ThemeTitleStyle} show HEADING:THEMETITLESTYLE; show \MPstring{heading:title}; draw textext( \MPstring{heading:title} ) rotated 5 withcolor blue; \stopuseMPgraphic \defineframed[ThemeTitleStyle][ background=\useMPgraphic{ThemeTitleStyle}, ] \def\processword#1{% \setMPtext{heading:title}{#1}% \useMPgraphic{heading:ThemeTitleStyle} } \define[1]\ThemeChapterTitle{\applytosplitstringword\processword{#1}} \setuphead[chapter][deeptextcommand={\ThemeChapterTitle}] \starttext \startchapter[title=Why Is heading:ThemeTitleStyle Called Twice?] \input knuth \stopchapter \stoptext It appears as though heading:ThemeTitleStyle is being called twice: metapost info: HEADING:THEMETITLESTYLE Why metapost info: HEADING:THEMETITLESTYLE Why I am trying to produce a random number that is not equal to the previous random number. However, if the code is called twice, then I'd have to add code to ignore one of the calls. Any ideas why the code seems to be called twice and what can be done to ensure that it is only called once? Don’t use text ;-) That’s a known issue: as soon as your Metapost code contains text, it will be processed twice. E.g.: \starttext \setMPtext{heading:title}{foo} \startMPcode show This gets printed twice.; draw textext( \MPstring{heading:title} ); \stopMPcode \stoptext Same for labels, {b,e}tex. See also this thread: http://www.ntg.nl/pipermail/ntg-context/2011/056047.html you can check for it: \enabletrackers[metapost.showlog] and in the mp code: message(if mfun_first_run : first run else : final run fi) ; message(if mfun_trial_run : trial run else : final run fi) ; Hans That’s handy! I added a section on dealing with multi-pass to the “gotchas” page: http://wiki.contextgarden.net/Unexpected_behavior#Multipass There is a subsection about MP at the end. Btw. the behavior of mfun_trial_run is not very intuitive. I’d expect it to work like \iftrialtypesetting, but in a single-pass context it evaluates to true: \enabletrackers[metapost.showlog] \starttext \startMPcode if mfun_trial_run : show This should be printed during the trial pass.; else : show This should be printed during the final pass.; fi; fill unitcircle scaled 1cm withcolor blue; %label (btex Some label text etex, (0,0)); \stopMPcode \stoptext Uncommenting the label yields two passes, as expected. Best regards, Philipp pgpgZd0xBOdkD.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 ___
Re: [NTG-context] Code Called Twice?
On 10/12/2013 2:09 AM, Philipp Gesang wrote: Btw. the behavior of mfun_trial_run is not very intuitive. I’d expect it to work like \iftrialtypesetting, but in a single-pass context it evaluates to true: keep in mind that one really needs to process the text in order to get the dimensions right ... so trialtypesetting is something else so, the trial run flag has to be used with care also, texts are cached, so if you typeset for instance labels, 500 times a '1' or '2' will only be typeset once (over the years lots of small optimizations took place) 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] code after \stopbuffer
Thanks, got the following now working: \def\startxmlbuffer{\grabbufferdata[xmlbuffer][startxmlbuffer][stopxmlbuffer]} \def\stopxmlbuffer{\endinput} .. \xmlprocessbuffer{dvd}{xmlbuffer}{} Hans van der Meer On 13 feb. 2013, at 22:34, Wolfgang Schuster wolfgang.schus...@gmail.com wrote: Am 13.02.2013 um 17:49 schrieb H. van der Meer h.vanderm...@uva.nl: Is it possible to have a command automatically executed each time \stopbuffer has been read? Preferably coupled to a specific named \startbuffer[this_one], iff possible at all of course. Thus: \startbuffer[this_one] ..contents.. \stopbuffer % in execution followed by \command \def\startmybuffer {\grabbufferdata[mybuffer][startmybuffer][stopmybuffer]} \def\stopmybuffer {\startframedtext[width=max] \getbuffer[mybuffer] \stopframedtext} \starttext \startmybuffer \input knuth \stopmybuffer \stoptext 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 ___ ___ 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] code after \stopbuffer
Am 13.02.2013 um 17:49 schrieb H. van der Meer h.vanderm...@uva.nl: Is it possible to have a command automatically executed each time \stopbuffer has been read? Preferably coupled to a specific named \startbuffer[this_one], iff possible at all of course. Thus: \startbuffer[this_one] ..contents.. \stopbuffer % in execution followed by \command \def\startmybuffer {\grabbufferdata[mybuffer][startmybuffer][stopmybuffer]} \def\stopmybuffer {\startframedtext[width=max] \getbuffer[mybuffer] \stopframedtext} \starttext \startmybuffer \input knuth \stopmybuffer \stoptext 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 ___
Re: [NTG-context] Code in contextref-env.tex
On Wed, 22 Aug 2012, john Culleton wrote: In the file contextref-env.tex I find code like the following: \setupsectionblock[\v!frontpart] [\c!page=\v!yes] \setupsectionblock[\v!bodypart] [\c!page=\v!yes] \setupsectionblock[\v!appendix] [\c!page=\v!yes] \setupsectionblock[\v!frontpart] [\c!before=,\c!after=] I have no idea what the sequences like \v!and \c! etc. mean. Are they references to modes? Search for multi-lingual on this page: http://wiki.contextgarden.net/System_Macros/Key_Value_Assignments 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Code in contextref-env.tex
I have no idea what the sequences like \v!and \c! etc. mean. Are they references to modes? I asked much the same question on tex.stackexchange.com two months ago, except mine was not so nice and focused. Aditya gave a very nice explanation of what the letters do; clearer than the one on the wiki, I thought. Here's a link straight to his answer: http://tex.stackexchange.com/a/58716/2229 They are used as language-agnostic forms. Using ConTeXt's English format, you'd type \startmarginblock Using ConTeXt's French format, you'd type \demarreblocmarge So to accomodate both, we define variables \s!start -- start or demarre, and \e!marginblock -- marginblock or blocmarge, depending on the language, and then we tell TeX we want to run the command named with the string \s!start\e!marginblock -- startmarginblock or demarreblocmarge. (Example not entirely accurate, I believe the variable for startmarginblock is define holisticaly. But you get my point.) Example of the need for the letter codes, paraphrased from mult-ini.mkiv: Where English uses 'left', in Dutch one finds both 'links' for '(on) the left' and 'linker' for 'the left one'. Hence the letter codes, so we can have \v!left -- links and \c!left -- linker. \c! is for keywords \v! is for value names \s! is for system bits \e! is for elements Hope this helps you in reading the sources! Cheers, Sietse ___ 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] Code in contextref-env.tex
On 22-8-2012 23:02, Sietse Brouwer wrote: I have no idea what the sequences like \v!and \c! etc. mean. Are they references to modes? I asked much the same question on tex.stackexchange.com two months ago, except mine was not so nice and focused. Aditya gave a very nice explanation of what the letters do; clearer than the one on the wiki, I thought. Here's a link straight to his answer: http://tex.stackexchange.com/a/58716/2229 They are used as language-agnostic forms. Using ConTeXt's English format, you'd type \startmarginblock Using ConTeXt's French format, you'd type \demarreblocmarge So to accomodate both, we define variables \s!start -- start or demarre, and \e!marginblock -- marginblock or blocmarge, depending on the language, and then we tell TeX we want to run the command named with the string \s!start\e!marginblock -- startmarginblock or demarreblocmarge. (Example not entirely accurate, I believe the variable for startmarginblock is define holisticaly. But you get my point.) Example of the need for the letter codes, paraphrased from mult-ini.mkiv: Where English uses 'left', in Dutch one finds both 'links' for '(on) the left' and 'linker' for 'the left one'. Hence the letter codes, so we can have \v!left -- links and \c!left -- linker. \c! is for keywords \v! is for value names \s! is for system bits \e! is for elements Hope this helps you in reading the sources! In practice users don't have to use that convention in their files, unless they are meant to be multilingual. Btw, there is a nice story behind this: - left= 4 tokens - \c!left = 1 token so, when context grew harder than tex's string space (we're talking emtex times) it was also a way to save memory. To some extend it's also faster (less tokens to pass as argument) but at the same time there is a penalty of expanding the 1 into 4. So, in a single lingual interface there is not much gain. Some of the 'struggles with too small engines' has been removed in mkiv as nowadays we have no such constraints. When I introduced the \c! and \v! prefixes context was still dutch and when there came interest from abroad, it had the nice side effect that I could make an (first german, later also english) interface in just a couple of hours (context was smaller at that time). The first module to actually be multilingual was 'ppchtex'. 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] code
On Sat, 17 Apr 2010 06:37:02 +0200 Wolfgang Schuster schuster.wolfg...@googlemail.com scribit: [...] the sign | (vertical bar) seems to be a special char (context/mkiv) it is only compiled if present in pairs |text | the message: File ended while use of \next \type{|} works To keep the current font use \| or \letterbar Wolfgang what is the sense of | text | ? ___ 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 ___ -- René Bastian www.pythoneon.org www.musiques-rb.org http://www.soundsurvey.org.uk/ ___ 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] code
Am 17.04.10 10:51, schrieb R. Bastian: what is the sense of |text | ? http://wiki.contextgarden.net/Composed_words 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 ___
Re: [NTG-context] code
On Fri, 09 Apr 2010 12:00:05 +0200 Wolfgang Schuster schuster.wolfg...@googlemail.com scribit: Am 09.04.10 11:20, schrieb R. Bastian: Hello, how to translate in context the following plain tex: \font\fgras = cmbtt10 {\tt {\obeylines {\fgras def} ra(): \ \ \ \ a = 3 \ \ \ \ b = 4 } } MkII: \setuplines[space=on] \starttext \startlines\tt %\startlines[style=mono] % works only in MkIV {\bf def} ra(): a = 3 b = 4 \stoplines \stoptext Wolfgang ___ 1. I use 'context -result=y source.tex'; is this mkii or mkiv ? (mkii seems to be an optional flag) 2. what is the Context font for cmitt10 ? -- René Bastian www.pythoneon.org www.musiques-rb.org http://www.soundsurvey.org.uk/ ___ 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] code
On Fri, Apr 16, 2010 at 11:31 AM, R. Bastian rbast...@free.fr wrote: 1. I use 'context -result=y source.tex'; is this mkii or mkiv ? It's mkiv For mkii use $ texexec source.tex -- luigi ___ 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] code
On Fri, 16 Apr 2010 11:31:00 +0200 R. Bastian rbast...@free.fr scribit: On Fri, 09 Apr 2010 12:00:05 +0200 Wolfgang Schuster schuster.wolfg...@googlemail.com scribit: Am 09.04.10 11:20, schrieb R. Bastian: Hello, how to translate in context the following plain tex: \font\fgras = cmbtt10 {\tt {\obeylines {\fgras def} ra(): \ \ \ \ a = 3 \ \ \ \ b = 4 } } MkII: \setuplines[space=on] \starttext \startlines\tt %\startlines[style=mono] % works only in MkIV {\bf def} ra(): a = 3 b = 4 \stoplines \stoptext Wolfgang ___ 1. I use 'context -result=y source.tex'; is this mkii or mkiv ? (mkii seems to be an optional flag) 2. what is the Context font for cmitt10 ? {\it{} ...} works - but i would the same as \bold{} -- René Bastian www.pythoneon.org www.musiques-rb.org http://www.soundsurvey.org.uk/ ___ 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 ___ -- René Bastian www.pythoneon.org www.musiques-rb.org http://www.soundsurvey.org.uk/ ___ 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] code
Am 16.04.10 11:31, schrieb R. Bastian: 2. what is the Context font for cmitt10 ? ConTeXt use Latin Modern by default, to get italic typewriter you can write \tt\it ... or \ttit ... or \definefont[italictypewriter][MonoItalic] and use the font with \italictypewriter ... or \definedfont[MonoItalic]... 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 ___
Re: [NTG-context] code
On Fri, 16 Apr 2010 11:36:47 +0200 luigi scarso luigi.sca...@gmail.com scribit: On Fri, Apr 16, 2010 at 11:31 AM, R. Bastian rbast...@free.fr wrote: 1. I use 'context -result=y source.tex'; is this mkii or mkiv ? It's mkiv For mkii use $ texexec source.tex ok, but there is a bug in mkii: texte \input f.tex another text \input f.tex does not work (the second time, f.tex is not input) so i use context -- luigi ___ 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 ___ -- René Bastian www.pythoneon.org www.musiques-rb.org http://www.soundsurvey.org.uk/ ___ 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] code
Am 16.04.10 11:46, schrieb R. Bastian: 2. what is the Context font for cmitt10 ? {\it{} ...} works - but i would the same as \bold{} \italic{...} 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 ___
Re: [NTG-context] code
On Fri, Apr 16, 2010 at 11:49 AM, R. Bastian rbast...@free.fr wrote: On Fri, 16 Apr 2010 11:36:47 +0200 luigi scarso luigi.sca...@gmail.com scribit: On Fri, Apr 16, 2010 at 11:31 AM, R. Bastian rbast...@free.fr wrote: 1. I use 'context -result=y source.tex'; is this mkii or mkiv ? It's mkiv For mkii use $ texexec source.tex ok, but there is a bug in mkii: texte \input f.tex another text \input f.tex does not work (the second time, f.tex is not input) so i use context sorry, I don't understand --- can you post a minimal example ? -- luigi ___ 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] code
On Fri, 16 Apr 2010 11:54:57 +0200 luigi scarso luigi.sca...@gmail.com scribit: On Fri, Apr 16, 2010 at 11:49 AM, R. Bastian rbast...@free.fr wrote: On Fri, 16 Apr 2010 11:36:47 +0200 [...] so i use context sorry, I don't understand --- can you post a minimal example ? no, _i_ was the error :-) -- luigi ___ 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 ___ -- René Bastian www.pythoneon.org www.musiques-rb.org http://www.soundsurvey.org.uk/ ___ 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] code
On Fri, 09 Apr 2010 12:00:05 +0200 Wolfgang Schuster schuster.wolfg...@googlemail.com scribit: \setuplines[space=on] \starttext \startlines\tt %\startlines[style=mono] % works only in MkIV compiled by context (== mak iv ?) \startlines[style=mono] prints [style=mono] {\bf def} ra(): a = 3 b = 4 \stoplines \stoptext Wolfgang - the sign | (vertical bar) seems to be a special char (context/mkiv) it is only compiled if present in pairs | text | the message: File ended while use of \next \type{|} works - -- René Bastian www.pythoneon.org www.musiques-rb.org http://www.soundsurvey.org.uk/ ___ 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] code
Am 16.04.10 23:41, schrieb R. Bastian: %\startlines[style=mono] % works only in MkIV compiled by context (== mak iv ?) \startlines[style=mono] prints [style=mono] Direct setups are now gone because they produced unwanted side effects. What you can in Mark 4 (MkIV) is to define you own lines environment. \definelines[code][style=mono,space=on] \startcode \bold{def} ra() ... \stopcode the sign | (vertical bar) seems to be a special char (context/mkiv) it is only compiled if present in pairs |text | the message: File ended while use of \next \type{|} works To keep the current font use \| or \letterbar 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 ___
Re: [NTG-context] code
On Fri, Apr 9, 2010 at 11:20 AM, R. Bastian rbast...@free.fr wrote: Hello, how to translate in context the following plain tex: \font\fgras = cmbtt10 {\tt {\obeylines {\fgras def} ra(): \ \ \ \ a = 3 \ \ \ \ b = 4 } } not a solution, but this works \starttext \font\fgras = lmmonolt10-bold.otf {\tt {\obeylines {\fgras def} ra(): \ \ \ \ a = 3 \ \ \ \ b = 4 } } \stoptext -- luigi ___ 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] code
Am 09.04.10 11:20, schrieb R. Bastian: Hello, how to translate in context the following plain tex: \font\fgras = cmbtt10 {\tt {\obeylines {\fgras def} ra(): \ \ \ \ a = 3 \ \ \ \ b = 4 } } MkII: \setuplines[space=on] \starttext \startlines\tt %\startlines[style=mono] % works only in MkIV {\bf def} ra(): a = 3 b = 4 \stoplines \stoptext 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 ___
Re: [NTG-context] code
On Fri, 9 Apr 2010 11:27:38 +0200 luigi scarso luigi.sca...@gmail.com scribit: On Fri, Apr 9, 2010 at 11:20 AM, R. Bastian rbast...@free.fr wrote: Hello, how to translate in context the following plain tex: \font\fgras = cmbtt10 {\tt {\obeylines {\fgras def} ra(): \ \ \ \ a = 3 \ \ \ \ b = 4 } } not a solution, but this works \starttext \font\fgras = lmmonolt10-bold.otf {\tt {\obeylines {\fgras def} ra(): \ \ \ \ a = 3 \ \ \ \ b = 4 } } \stoptext -- luigi thanks luigi, it compiles with 'context 2010.01.26' but: - the def is not in bold - context adds \n between every line. my 76 pages of Python code rewritten in plain tex by a python script are accetabile (compile by pdftex) - so i will try to ___ 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 ___ -- René Bastian www.pythoneon.org www.musiques-rb.org http://www.soundsurvey.org.uk/ ___ 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] code
On Fri, 09 Apr 2010 12:00:05 +0200 Wolfgang Schuster schuster.wolfg...@googlemail.com scribit: Am 09.04.10 11:20, schrieb R. Bastian: Hello, how to translate in context the following plain tex: \font\fgras = cmbtt10 {\tt {\obeylines {\fgras def} ra(): \ \ \ \ a = 3 \ \ \ \ b = 4 } } MkII: \setuplines[space=on] \starttext \startlines\tt %\startlines[style=mono] % works only in MkIV {\bf def} ra(): a = 3 b = 4 \stoplines \stoptext Wolfgang Thanks Wolfhang. It goes better, but there is still a little bug: {\bf def} inserts a white space in front of the line Compare: {\bf def} ra(): def ra(): a = 3 b = 4 -- René Bastian www.pythoneon.org www.musiques-rb.org http://www.soundsurvey.org.uk/ ___ 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] code
On Fri, Apr 9, 2010 at 1:35 PM, R. Bastian rbast...@free.fr wrote: On Fri, 9 Apr 2010 11:27:38 +0200 luigi scarso luigi.sca...@gmail.com scribit: On Fri, Apr 9, 2010 at 11:20 AM, R. Bastian rbast...@free.fr wrote: Hello, how to translate in context the following plain tex: \font\fgras = cmbtt10 {\tt {\obeylines {\fgras def} ra(): \ \ \ \ a = 3 \ \ \ \ b = 4 } } not a solution, but this works \starttext \font\fgras = lmmonolt10-bold.otf {\tt {\obeylines {\fgras def} ra(): \ \ \ \ a = 3 \ \ \ \ b = 4 } } \stoptext -- luigi thanks luigi, it compiles with 'context 2010.01.26' but: - the def is not in bold def is bold (you can see it with pdffonts) only it's loaded at 10pt, while body font is 12pt (I believe) - context adds \n between every line. hmm, If I cut-and-paste to vim I see the same as pdf , ie no extra \n anyway you can play with interlinespace \starttext \font\fgras = lmmonolt10-bold.otf at 12pt {\tt\setupinterlinespace[line=1ex] {\obeylines {\fgras def} ra(): \ \ \ \ a = 3 \ \ \ \ b = 4 } } \stoptext my 76 pages of Python code rewritten in plain tex by a python script are accetabile (compile by pdftex) - so i will try to thank you to remember me that I'm always on late with python pretty printer ... -- luigi ___ 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] code
On Fri, 9 Apr 2010 14:32:08 +0200 luigi scarso luigi.sca...@gmail.com scribit: On Fri, Apr 9, 2010 at 1:35 PM, R. Bastian rbast...@free.fr wrote: On Fri, 9 Apr 2010 11:27:38 +0200 luigi scarso luigi.sca...@gmail.com scribit: On Fri, Apr 9, 2010 at 11:20 AM, R. Bastian rbast...@free.fr wrote: Hello, how to translate in context the following plain tex: \font\fgras = cmbtt10 {\tt {\obeylines {\fgras def} ra(): \ \ \ \ a = 3 \ \ \ \ b = 4 } } not a solution, but this works \starttext \font\fgras = lmmonolt10-bold.otf {\tt {\obeylines {\fgras def} ra(): \ \ \ \ a = 3 \ \ \ \ b = 4 } } \stoptext -- luigi thanks luigi, it compiles with 'context 2010.01.26' but: - the def is not in bold def is bold (you can see it with pdffonts) only it's loaded at 10pt, while body font is 12pt (I believe) it is true - i saw it just after sending the mail. - context adds \n between every line. hmm, If I cut-and-paste to vim I see the same as pdf , ie no extra \n anyway you can play with interlinespace ok \interlinespace works \starttext \font\fgras = lmmonolt10-bold.otf at 12pt {\tt\setupinterlinespace[line=1ex] {\obeylines {\fgras def} ra(): \ \ \ \ a = 3 \ \ \ \ b = 4 } } \stoptext but remains that every {\bf } introduces a white space; how to force context to make a backspace ? my 76 pages of Python code rewritten in plain tex by a python script are accetabile (compile by pdftex) - so i will try to thank you to remember me that I'm always on late with python pretty printer .. it would be fine -- luigi ___ 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 ___ -- René Bastian www.pythoneon.org www.musiques-rb.org http://www.soundsurvey.org.uk/ ___ 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] code
On Fri, Apr 09 2010, R. Bastian wrote: but remains that every {\bf } introduces a white space; how to force context to make a backspace ? \setuplines[space=on] \starttext \startlines[style=mono] {\bf{}def} ra(): a = 3 b = 4 \stoplines \stoptext Cheers, Peter -- Contact information: http://pmrb.free.fr/contact/ ___ 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] code
On Fri, Apr 9, 2010 at 5:24 PM, Peter Münster pmli...@free.fr wrote: On Fri, Apr 09 2010, R. Bastian wrote: but remains that every {\bf } introduces a white space; how to force context to make a backspace ? \setuplines[space=on] \starttext \startlines[style=mono] {\bf{}def} ra(): a = 3 b = 4 \stoplines \stoptext Cheers, Peter I'm not able to see any white space in mkiv \showframe \starttext \font\fgras = lmmonolt10-bold.otf at 12pt \ruledvbox{\tt\setupinterlinespace[line=1ex] {\obeylines {\fgras def} ra(): \ \ \ \ a = 3 \ \ \ \ b = 4 \vskip1\lineheight {\fgras def} ra(): \ \ \ \ a = 3 \ \ \ \ b = 4 } } \stoptext -- luigi ___ 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] code
On Fri, Apr 09 2010, luigi scarso wrote: On Fri, Apr 09 2010, R. Bastian wrote: but remains that every {\bf } introduces a white space; I'm not able to see any white space in mkiv Bastian refers to Wolfgang's solution with \setuplines[space=on]. Cheers, Peter -- Contact information: http://pmrb.free.fr/contact/ ___ 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] code
Am 09.04.10 13:35, schrieb R. Bastian Thanks Wolfhang. It goes better, but there is still a little bug: {\bf def} inserts a white space in front of the line Compare: {\bf def} ra(): def ra(): a = 3 b = 4 \startlines \bold{def} ra(): ... \stoplines 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 ___
Re: [NTG-context] code with reserved words
On Tue, Mar 23, 2010 at 1:17 PM, R. Bastian rbast...@free.fr wrote: Hello, is there a way to get Python code with reserved words highlighted ? Not colored as in http://wiki.contextgarden.net/Verbatim_with_LuaTeX but {\bf ...} I use context 2010.01.26 Mk IV or texexec well, I'm working to a pretty-printer for Python with low priority -- luigi ___ 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] code with reserved words
On Tue, 23 Mar 2010 13:24:09 +0100 luigi scarso luigi.sca...@gmail.com scribit: On Tue, Mar 23, 2010 at 1:17 PM, R. Bastian rbast...@free.fr wrote: Hello, is there a way to get Python code with reserved words highlighted ? Not colored as in http://wiki.contextgarden.net/Verbatim_with_LuaTeX but {\bf ...} I use context 2010.01.26 Mk IV or texexec well, I'm working to a pretty-printer for Python with low priority Attendo ;-) -- luigi ___ 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 ___ -- René Bastian www.pythoneon.org www.musiques-rb.org http://www.soundsurvey.org.uk/ ___ 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] code with reserved words
Based on the pretty printer in the wiki, I wrote my own. If I understood you well, you want a b/w pretty printer with reserved words bold. The pretty printer is capable of doing both. An example is attached. Probably missing is the functionality to control the typesetting of reserved words in TeX. This is done in the lua code. I didn't mind up to now. Any feedback is welcome. Erik 2010/3/23 R. Bastian rbast...@free.fr On Tue, 23 Mar 2010 13:24:09 +0100 luigi scarso luigi.sca...@gmail.com scribit: On Tue, Mar 23, 2010 at 1:17 PM, R. Bastian rbast...@free.fr wrote: Hello, is there a way to get Python code with reserved words highlighted ? Not colored as in http://wiki.contextgarden.net/Verbatim_with_LuaTeX but {\bf ...} I use context 2010.01.26 Mk IV or texexec well, I'm working to a pretty-printer for Python with low priority Attendo ;-) -- luigi ___ 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 ___ -- René Bastian www.pythoneon.org www.musiques-rb.org http://www.soundsurvey.org.uk/ ___ 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 ___ sample.tex Description: TeX document if not modules then modules = { } end modules ['pret-py'] = { version = 0.001, comment = companion to buff-ver.mkiv, author= Erik Margraf, copyright = PRAGMA ADE / ConTeXt Development Team, license = see context related readme files } local utf = unicode.utf8 local utfcharacters, utfvalues = string.utfcharacters, string.utfvalues local utfbyte, utffind = utf.byte, utf.find local byte, sub, find, match = string.byte, string.sub, string.find, string.match local texsprint, texwrite = tex.sprint, tex.write local ctxcatcodes = tex.ctxcatcodes local visualizer = buffers.newvisualizer(py) visualizer.identifiers = { } visualizer.identifiers.core = { and, as, assert, break, class, continue, def, del, elif, else, except,exec, finally, for, from, global, if, import, in, is, lambda, not, or, pass, print, raise, return, try, while, with, yield } visualizer.identifiers.base = { False, None, True } visualizer.identifiers.delimiters = { @, %, ^, , *, (, ), -, +, =, |, \\, /, {, }, [, ], :, ;, \, \', , , ,, ., ?, , # } local known_words = { } for k,v in pairs(visualizer.identifiers) do for _,w in pairs(v) do known_words[w] = k end end visualizer.styles = { core = \\bf\\ss , base = \\sl , } local styles = visualizer.styles local declarations = { [def]=1, [class]=1 } local colors = { prettyone, prettytwo, prettythree, prettyfour, } local change_state, finish_state = buffers.change_state, buffers.finish_state local function flush_python_word(state, word) if word then local id = known_words[word] if id then state = change_state(1,state) if styles[id] then texsprint(ctxcatcodes,styles[id]) end texwrite(word) state = finish_state(state) if declarations[word] then state = change_state(3,state) end else texwrite(word) state = finish_state(state) -- ? end else state = finish_state(state) end return state end local in_py_long_string = false function visualizer.flush_line(str,nested) local i, result , word = 1, { }, local state = 0 local delimiters=visualizer.identifiers.delimiters local is_delimiter = false local in_string = false local string_end = buffers.currentcolors = colors while i = #str do c=string.sub(str,i,i) if in_py_long_string then state = buffers.change_state(2,state) if c==\' and string.sub(str,i,i+2)==\'\'\' then texwrite(string.sub(str,i,i+2)) i=i+2 in_py_long_string=false elseif c==\ and string.sub(str,i,i+2)==\\\ then texwrite(string.sub(str,i,i+2)) i=i+2 in_py_long_string=false elseif
Re: [NTG-context] Code to product several versions PDF with different fonts
VnPenguin said this at Sun, 20 Feb 2005 18:58:41 +0100: I dont know how to organize it : is there simple structure if-then-else ? could I use ConTeXt's mode or environment for this goal ? These are all possibilities. It depends on how you want to change them. Modes sound promising if you want to change them from the command line. Taking the time to set up typescripts/typefaces so that you can change one line/word won't hurt, in any case... So what kind of interface were you imagining? adam -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Adam T. Lindsay, Computing Dept. [EMAIL PROTECTED] Lancaster University, InfoLab21+44(0)1524/510.514 Lancaster, LA1 4WA, UK Fax:+44(0)1524/510.492 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] Code to product several versions PDF with different fonts
On Sun, 20 Feb 2005 18:09:47 +, Adam Lindsay [EMAIL PROTECTED] wrote: VnPenguin said this at Sun, 20 Feb 2005 18:58:41 +0100: I dont know how to organize it : is there simple structure if-then-else ? could I use ConTeXt's mode or environment for this goal ? These are all possibilities. It depends on how you want to change them. Modes sound promising if you want to change them from the command line. Taking the time to set up typescripts/typefaces so that you can change one line/word won't hurt, in any case... So what kind of interface were you imagining? Thank you for your reply. I would like to use command line. Could you give me a simple example please. For example I would like to make 3 PDF: The 1st: \usetypescript[berry][t5] \usetypescript[palatino][t5] \setupbodyfont[palatino,12pt] The 2nd with: \usetypescript[berry][t5] \usetypescript[postscript][t5] \setupbodyfont[postscript,12pt] The 3rd with my typescript Thank you, Q. ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] Code to product several versions PDF with different fonts
VnPenguin said this at Sun, 20 Feb 2005 19:17:41 +0100: I'm preparing a document and I would like to product several versions PDF with different fonts. I would like to use command line. Could you give me a simple example please. % I've adapted this for gwTeX default encodings. % Convert back to t5 as appropriate! \doifmode{palatino} {\usetypescript[adobekb][8r] \usetypescript[palatino][8r] \setupbodyfont[palatino,12pt]} \doifmode{times} {\usetypescript[adobekb][8r] \usetypescript[postscript][8r] \setupbodyfont[postscript,12pt]} \starttext \input knuth \showfontstrip \stoptext ...and run with: texexec --pdf --mode=palatino filename texexec --pdf --mode=timesfilename -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Adam T. Lindsay, Computing Dept. [EMAIL PROTECTED] Lancaster University, InfoLab21+44(0)1524/510.514 Lancaster, LA1 4WA, UK Fax:+44(0)1524/510.492 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] Code to product several versions PDF with different fonts
On Sun, 20 Feb 2005 18:34:20 +, Adam Lindsay [EMAIL PROTECTED] wrote: VnPenguin said this at Sun, 20 Feb 2005 19:17:41 +0100: I'm preparing a document and I would like to product several versions PDF with different fonts. I would like to use command line. Could you give me a simple example please. % I've adapted this for gwTeX default encodings. % Convert back to t5 as appropriate! ... Thank you very much ! Q. ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] Code to product several versions PDF with different fonts
If you have the modes defined in a layout.tex you can say in the main file: \enablemode[times] %\enablemode[palatino] %\enablemode[..] \environment layout. So by adding the appropriate \enablemode you even do not need to run the commandline ... Willi Adam Lindsay wrote: VnPenguin said this at Sun, 20 Feb 2005 19:17:41 +0100: I'm preparing a document and I would like to product several versions PDF with different fonts. I would like to use command line. Could you give me a simple example please. % I've adapted this for gwTeX default encodings. % Convert back to t5 as appropriate! \doifmode{palatino} {\usetypescript[adobekb][8r] \usetypescript[palatino][8r] \setupbodyfont[palatino,12pt]} \doifmode{times} {\usetypescript[adobekb][8r] \usetypescript[postscript][8r] \setupbodyfont[postscript,12pt]} \starttext \input knuth \showfontstrip \stoptext ...and run with: texexec --pdf --mode=palatino filename texexec --pdf --mode=timesfilename ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context