Re: [NTG-context] Can I share METAPOST vardefs over multiple pages?
On Mon, 16 Mar 2020, Gerben Wierda wrote: This worked when I was just doing METAPOST. Now, I am using my lua code to produce the METAPOST code that produces the pictures. And the picture itself is put in a file for METAPOST as follows: File test4-mplib-run-001.mp: % begin graphic: n=0 ; beginfig(1) ; defaultfont:="name:dejavuserif*default"; CurrentLayout:="article"; def OverlayLineColor=black enddef; def OverlayColor =black enddef; ;picture pic; x:=80.000; y:=200.000; w:=133.000; h:=53.000;pic := ApplicationComponentLogo( w, h, typeString) shifted (x, -y); draw pic;picture pic; x:=273.000; y:=253.000; w:=133.000; h:=53.000;pic := Function( w, h, typeString) shifted (x, -y); draw pic;picture pic; x:=380.000; y:=133.000; w:=133.000; h:=53.000;pic := Service( w, h, typeString) shifted (x, -y); draw pic;path p; p := (200.000,-227.000)--(333.000,-227.000)--(333.000,-273.000); draw p;path p; p := (393.000,-253.000)--(393.000,-180.000); draw p;;; endfig ; % end graphic This apparently is tried to get run through METAPOST separately and that clearly doesn’t work, because ApplicationComponentLogo isn’t defined. This is the result of the following setup: \starttext \startMPdefinitions (or inclusions, no difference) % ApplicationComponentLogo is defined here with a vardef \stopMPdefinitions \ctxlua{foo(“filename”)}% produces a series of %context.startMPpage { instance = "doublefun” } %several of: % context( METAPOST statements in a string) %context.stopMPpage() \stoptext How do I get my MPdefinitions available in those METAPOST runs? Since you are using \startMPpage[instace=doublefun], you need to do the definitions for doublefun instance: so use \startMPdefinitions{doublefun} ... \stopMPdefinitions Aditya___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] (bug?) wrong interline in \placelist[alternative=d] with Pagella italics
On 3/16/20 7:00 PM, Wolfgang Schuster wrote: > [...] > A way to fix the wrong spacing here is to add a strut option to > \setuplist (or use always the upright font to set the strut values). Any of these ones would be great to avoid the corner cases. 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] Quizz
> On 16 Mar 2020, at 11:14, Hans Hagen wrote: > > On 3/15/2020 10:34 AM, Fabrice Couvreur wrote: >> […] > > there are some examples of form stuff in the test suite (widgets) > > i'll send you a file from 2000 that does some mpc magic (including feedback > and score calculations) but it's mkii (so you need to run pdftex). Maybe I > should check it with mkiv too. Could you please tell us where to find that file, even if it is only with mkii? (I need to prepare some material for my students, for the same reason as Fabrice…). Thanks in advance: Otared K. ___ 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] (bug?) wrong interline in \placelist[alternative=d] with Pagella italics
Hans Hagen schrieb am 16.03.2020 um 18:42: On 3/16/2020 6:01 PM, Wolfgang Schuster wrote: Henning Hraban Ramm schrieb am 16.03.2020 um 15:42: Am 2020-03-16 um 14:35 schrieb Hans Hagen : Yes, pagella is a extreme case but when you use bold text the vertical spacing is also messed up. You can avoid this when you use a fixed lineheight (e.g. \setupinterlinespace[line=14pt]) because the default distance is font dependant (default: 2.8 * ex-height). or one can play with these parameters, that default to: \setupinterlinespace [height=.72, depth=.28] (maybe we should have recomended values for specific fonts) I had similar problems in the past and got to 2.9ex for Alegreya 3.2ex for Adobe Jenson (Just tried, didn’t calculate anything.) How would this help for the original problem? Some fonts have a different ratio (I forgot what font i did .7 / .3) but indeed an all-bold or whatever style change sometimes demands a local \setupinterlinespace (no argument). I know there are cases where changing the height/depth ration can help but in this case the problem is caused by \strut which is bigger for the italic font. A way to fix the wrong spacing here is to add a strut option to \setuplist (or use always the upright font to set the strut values). Of course one could also tweak the ht/dp of a specific style using one of the pseudo features. Also possible because the larger value for the ex-height of the italic font causes the bigger strut dimensions. 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] Quizz
On 3/16/2020 4:26 PM, Fabrice Couvreur wrote: Thank you, I will try to use your file. i'll add a mkiv variant to the distribution (a few minor tweaks) 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] (bug?) wrong interline in \placelist[alternative=d] with Pagella italics
On 3/16/2020 6:01 PM, Wolfgang Schuster wrote: Henning Hraban Ramm schrieb am 16.03.2020 um 15:42: Am 2020-03-16 um 14:35 schrieb Hans Hagen : Yes, pagella is a extreme case but when you use bold text the vertical spacing is also messed up. You can avoid this when you use a fixed lineheight (e.g. \setupinterlinespace[line=14pt]) because the default distance is font dependant (default: 2.8 * ex-height). or one can play with these parameters, that default to: \setupinterlinespace [height=.72, depth=.28] (maybe we should have recomended values for specific fonts) I had similar problems in the past and got to 2.9ex for Alegreya 3.2ex for Adobe Jenson (Just tried, didn’t calculate anything.) How would this help for the original problem? Some fonts have a different ratio (I forgot what font i did .7 / .3) but indeed an all-bold or whatever style change sometimes demands a local \setupinterlinespace (no argument). Of course one could also tweak the ht/dp of a specific style using one of the pseudo features. 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] (bug?) wrong interline in \placelist[alternative=d] with Pagella italics
Henning Hraban Ramm schrieb am 16.03.2020 um 15:42: Am 2020-03-16 um 14:35 schrieb Hans Hagen : Yes, pagella is a extreme case but when you use bold text the vertical spacing is also messed up. You can avoid this when you use a fixed lineheight (e.g. \setupinterlinespace[line=14pt]) because the default distance is font dependant (default: 2.8 * ex-height). or one can play with these parameters, that default to: \setupinterlinespace [height=.72, depth=.28] (maybe we should have recomended values for specific fonts) I had similar problems in the past and got to 2.9ex for Alegreya 3.2ex for Adobe Jenson (Just tried, didn’t calculate anything.) How would this help for the original problem? 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] Quizz
Hi Hans, Thank you, I will try to use your file. Fabrice Le lun. 16 mars 2020 à 11:32, luigi scarso a écrit : > > > On Mon, Mar 16, 2020 at 11:14 AM Hans Hagen wrote: > >> On 3/15/2020 10:34 AM, Fabrice Couvreur wrote: >> > Hi, >> > With the Coronavirus pandemic, my school will close like all the >> others. >> > We chose to work with Microsoft Teams. I know how to file Math >> exercises >> > written with ConteXt and export to pdf format. Is it possible with >> > ConteXt to create interactive Quizz? >> it should be doable (in the past we've made those with choice, fill in >> etc questions) but one problem with pdf is that there has been >> introduced some restrictions, for instance one cannot save in the reader >> so one then need to run a server that picks up the filled in stuff and >> regenerates a pdf file ... no big deal but i must admit that i don't >> have that code (if at all) around in loadable module form >> > > In google chrome this seems to work, apart the choice fields (the choice > selected has the red frame but it has no mark inside): > https://martin-thoma.com/images/2012/02/pdf-form.pdf > > -- > 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://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] (bug?) wrong interline in \placelist[alternative=d] with Pagella italics
> Am 2020-03-16 um 14:35 schrieb Hans Hagen : >> Yes, pagella is a extreme case but when you use bold text the vertical >> spacing is also messed up. You can avoid this when you use a fixed >> lineheight (e.g. \setupinterlinespace[line=14pt]) because the default >> distance is font dependant (default: 2.8 * ex-height). > or one can play with these parameters, that default to: > > \setupinterlinespace > [height=.72, > depth=.28] > > (maybe we should have recomended values for specific fonts) I had similar problems in the past and got to 2.9ex for Alegreya 3.2ex for Adobe Jenson (Just tried, didn’t calculate anything.) All the best, 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] (bug?) wrong interline in \placelist[alternative=d] with Pagella italics
On 3/16/2020 1:27 PM, Wolfgang Schuster wrote: Pablo Rodriguez schrieb am 16.03.2020 um 10:01: On 3/15/20 10:56 PM, Wolfgang Schuster wrote: Pablo Rodriguez schrieb am 15.03.2020 um 20:32: [...] Everthing is fine when italic fonts aren’t used. It can be fixed with a strut option for lists, e.g. \setuplist[strut=no]. The problem in this case is that the ex-height for the italic font is larger than the ex-height for the upright font which pushes the text down because add a strut at the begin and end of the entries. Many thanks for your reply, Wolfgang. I don’t get \setuplist[strut=no] working in the minimal sample I sent yesterday. The key isn't supported yet but it could help to avoid the spacing problem. Below is a minimal example of the problem, the \setstrut setting changes the height of the strut for the italic font. I must admit that I don’t understand how to handle struts (I’m not sure I understand what they actually are.) The simple answer is that a strut is a invisible vertical line with the height and depth of a line. When you look at the example below you can see the text in the first box touches the top and bottom boundaries. When we add a strut at the begin and end of the text we ensure the last line has the depth of a normal line and the first line gets the complete height of a line. begin example \starttext \ruledvbox{\samplefile{weisman}} \blank \ruledvbox{\begstrut\samplefile{weisman}\endstrut} \stoptext end example Most fonts (I checked only a small number) don't have such a big difference between the ex-height of the upright and italic styles which makes it hard to notice the problem. Yesterday I realized that Pagella was an extreme case, because I tried to report this issue before, but Latin Modern didn’t show the issue (so I thought I was doing something wrong). Yes, pagella is a extreme case but when you use bold text the vertical spacing is also messed up. You can avoid this when you use a fixed lineheight (e.g. \setupinterlinespace[line=14pt]) because the default distance is font dependant (default: 2.8 * ex-height). or one can play with these parameters, that default to: \setupinterlinespace [height=.72, depth=.28] (maybe we should have recomended values for specific fonts) 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] (bug?) wrong interline in \placelist[alternative=d] with Pagella italics
Pablo Rodriguez schrieb am 16.03.2020 um 10:01: On 3/15/20 10:56 PM, Wolfgang Schuster wrote: Pablo Rodriguez schrieb am 15.03.2020 um 20:32: [...] Everthing is fine when italic fonts aren’t used. It can be fixed with a strut option for lists, e.g. \setuplist[strut=no]. The problem in this case is that the ex-height for the italic font is larger than the ex-height for the upright font which pushes the text down because add a strut at the begin and end of the entries. Many thanks for your reply, Wolfgang. I don’t get \setuplist[strut=no] working in the minimal sample I sent yesterday. The key isn't supported yet but it could help to avoid the spacing problem. Below is a minimal example of the problem, the \setstrut setting changes the height of the strut for the italic font. I must admit that I don’t understand how to handle struts (I’m not sure I understand what they actually are.) The simple answer is that a strut is a invisible vertical line with the height and depth of a line. When you look at the example below you can see the text in the first box touches the top and bottom boundaries. When we add a strut at the begin and end of the text we ensure the last line has the depth of a normal line and the first line gets the complete height of a line. begin example \starttext \ruledvbox{\samplefile{weisman}} \blank \ruledvbox{\begstrut\samplefile{weisman}\endstrut} \stoptext end example Most fonts (I checked only a small number) don't have such a big difference between the ex-height of the upright and italic styles which makes it hard to notice the problem. Yesterday I realized that Pagella was an extreme case, because I tried to report this issue before, but Latin Modern didn’t show the issue (so I thought I was doing something wrong). Yes, pagella is a extreme case but when you use bold text the vertical spacing is also messed up. You can avoid this when you use a fixed lineheight (e.g. \setupinterlinespace[line=14pt]) because the default distance is font dependant (default: 2.8 * ex-height). 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] Quizz
On Mon, Mar 16, 2020 at 11:14 AM Hans Hagen wrote: > On 3/15/2020 10:34 AM, Fabrice Couvreur wrote: > > Hi, > > With the Coronavirus pandemic, my school will close like all the others. > > We chose to work with Microsoft Teams. I know how to file Math exercises > > written with ConteXt and export to pdf format. Is it possible with > > ConteXt to create interactive Quizz? > it should be doable (in the past we've made those with choice, fill in > etc questions) but one problem with pdf is that there has been > introduced some restrictions, for instance one cannot save in the reader > so one then need to run a server that picks up the filled in stuff and > regenerates a pdf file ... no big deal but i must admit that i don't > have that code (if at all) around in loadable module form > In google chrome this seems to work, apart the choice fields (the choice selected has the red frame but it has no mark inside): https://martin-thoma.com/images/2012/02/pdf-form.pdf -- 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] Can I share METAPOST vardefs over multiple pages?
This worked when I was just doing METAPOST. Now, I am using my lua code to produce the METAPOST code that produces the pictures. And the picture itself is put in a file for METAPOST as follows: File test4-mplib-run-001.mp: % begin graphic: n=0 ; beginfig(1) ; defaultfont:="name:dejavuserif*default"; CurrentLayout:="article"; def OverlayLineColor=black enddef; def OverlayColor =black enddef; ;picture pic; x:=80.000; y:=200.000; w:=133.000; h:=53.000;pic := ApplicationComponentLogo( w, h, typeString) shifted (x, -y); draw pic;picture pic; x:=273.000; y:=253.000; w:=133.000; h:=53.000;pic := Function( w, h, typeString) shifted (x, -y); draw pic;picture pic; x:=380.000; y:=133.000; w:=133.000; h:=53.000;pic := Service( w, h, typeString) shifted (x, -y); draw pic;path p; p := (200.000,-227.000)--(333.000,-227.000)--(333.000,-273.000); draw p;path p; p := (393.000,-253.000)--(393.000,-180.000); draw p;;; endfig ; % end graphic This apparently is tried to get run through METAPOST separately and that clearly doesn’t work, because ApplicationComponentLogo isn’t defined. This is the result of the following setup: \starttext \startMPdefinitions (or inclusions, no difference) % ApplicationComponentLogo is defined here with a vardef \stopMPdefinitions \ctxlua{foo(“filename”)}% produces a series of %context.startMPpage { instance = "doublefun” } %several of: % context( METAPOST statements in a string) %context.stopMPpage() \stoptext How do I get my MPdefinitions available in those METAPOST runs? G > On 13 Mar 2020, at 14:59, Hans Hagen wrote: > > On 3/13/2020 2:33 PM, Aditya Mahajan wrote: >> On Fri, 13 Mar 2020, Taco Hoekwater wrote: >>> Hi, >>> >>> >>> On 13 Mar 2020, at 12:53, Gerben Wierda wrote: Suppose I have this code: Can I reuse that varied across follow-up MPPages? >>> >>> Sure, put the vardef inside \startMPinclusions: >> or \startMPdefinitions ... \stopMPdefinitions (don't remember what is the >> difference between inclusions and definitions, now). > definitions: once > inclusions : every time > > - > 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] Quizz
On 3/15/2020 10:34 AM, Fabrice Couvreur wrote: Hi, With the Coronavirus pandemic, my school will close like all the others. We chose to work with Microsoft Teams. I know how to file Math exercises written with ConteXt and export to pdf format. Is it possible with ConteXt to create interactive Quizz? it should be doable (in the past we've made those with choice, fill in etc questions) but one problem with pdf is that there has been introduced some restrictions, for instance one cannot save in the reader so one then need to run a server that picks up the filled in stuff and regenerates a pdf file ... no big deal but i must admit that i don't have that code (if at all) around in loadable module form there are some examples of form stuff in the test suite (widgets) i'll send you a file from 2000 that does some mpc magic (including feedback and score calculations) but it's mkii (so you need to run pdftex). Maybe I should check it with mkiv too. 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] METAPOST vardef returning multiple and non-numeric types as a single answer?
Maybe a nice little explanation (educational with good examples) of ‘how to use pass by reference’ and ‘building and using complex data structures’ would be useful for people. Say, some ‘patterns’. G > On 16 Mar 2020, at 10:38, Hans Hagen wrote: > > that said, after muy share of mp programming i would not have thought about > the text y as pass by reference, also because it's only true for these pseudo > arrays (maybe suffixes also work) ___ 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] METAPOST vardef returning multiple and non-numeric types as a single answer?
> On 16 Mar 2020, at 10:23, Taco Hoekwater wrote: > > > >> On 16 Mar 2020, at 10:10, Taco Hoekwater wrote: >> >> >> >>> On 16 Mar 2020, at 09:53, Gerben Wierda wrote: >>> >>> Hola! So, the arguments passed to macros are by reference and not by value? >>> I could have known of course, they are simple expansions, but I’d like to >>> be sure. IfI assign to a variable inside a vardef macro and that variable >>> is not ’save’d I’m changing the original? >> >> Yes. (A simple test would have confirmed that) > > Oops, sorry, no! I was wrong on that… it must be too early for me. Coffee! Thanks anyway, Taco, your help is really appreciated. > > vardef Foo(text y) = >scantokens(y&":=5”); > enddef; > Foo("x"); > > This would work, but that is weird. Which is somewhat intuitive to parse as a human. I understand it as that after the last statement x has the value 5. > This also works, and that is why > I had the erroneous memory that it would work always: > > vardef Foo(expr a)(text y) = >y[a] := 5; > enddef; > numeric foo[]; > foo[1] = 6; > Foo(1,foo); This was initially complete gobbledegook to me. But I now think that after the last statement foo[1] equals 5. Very weird/counterintuitive that y[a] := 5 works here without the use of scantokens. The first one is less weird to me because scantokens actually calls the METAPOST parser on a string as if read from a file. > or you could use global variables, of course. > > Main point: Metapost is not an easy language to grasp. If you want to > really understand how it works, you should study the Metafont book by DEK. I actually have that book and did a try small bit of METAFONT long, long ago to create a logo in it. Maybe that explains things better. (Unearthing the book for later use…) > As you can clearly see, even experienced users are likely to make mistakes. The main problem with all of this (ConTeXt, METAPOST, etc.) remains the learning curve and the lack of good and up-to-date educational materials. I.e. the METAPOST manual is terse, probably because it relies on people understanding the background that is in the METAFONT book. And, if one is used to thinking in terms of functional programming, all that ‘expansion’ stuff (‘replacement’ programming?) is very counterintuitive for me. Lua then adds a functional model to the mix (or I think it does). Very hard to make progress. I learned Python in a day and produced a complex program in a matter of weeks. This is far less easy. And not being able so far to see what intermediate results lea to errors adds to the slow going. I.e., the whole chapter on vardef in the METAFONT book is G > > > Best wishes, > Taco > > > > > ___ > 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] METAPOST vardef returning multiple and non-numeric types as a single answer?
On 3/16/2020 10:23 AM, Taco Hoekwater wrote: On 16 Mar 2020, at 10:10, Taco Hoekwater wrote: On 16 Mar 2020, at 09:53, Gerben Wierda wrote: Hola! So, the arguments passed to macros are by reference and not by value? I could have known of course, they are simple expansions, but I’d like to be sure. IfI assign to a variable inside a vardef macro and that variable is not ’save’d I’m changing the original? Yes. (A simple test would have confirmed that) Oops, sorry, no! I was wrong on that… it must be too early for me. vardef Foo(text y) = scantokens(y&":=5”); enddef; Foo("x"); This would work, but that is weird. This also works, and that is why I had the erroneous memory that it would work always: vardef Foo(expr a)(text y) = y[a] := 5; enddef; numeric foo[]; foo[1] = 6; Foo(1,foo); or you could use global variables, of course. Main point: Metapost is not an easy language to grasp. If you want to really understand how it works, you should study the Metafont book by DEK. > As you can clearly see, even experienced users are likely to make mistakes. it's the mixture of delayed parsing and expansion and ... no other language like that i guess (which at the same time is its charm) passing "text y" is (i think) not that that far from the scantokens (running over already tokenized vs running over a string while tokenizing it ... but these input models (are we in scanning file input, string input, tokenlist) can be kind of confusing that said, after muy share of mp programming i would not have thought about the text y as pass by reference, also because it's only true for these pseudo arrays (maybe suffixes also work) 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] Can is somehow inspect the intermediate results of an mtxrun?
On 3/16/2020 10:16 AM, Gerben Wierda wrote: I have an mtxrun on a .tex file that has problems I need to debug. The .tex file handles well, but whenMETAPOST has a go, it crashes. But after the run, I cannot inspect what source was fed to METAPOST. Can I inspect that (outside of what the log tells me)? In this case, I know METAPOST is fed: picture pic; x:=80.000; y:=200.000; w:=133.000; h:=53.000;pic := ApplicationComponentLogo( w, h, typeString) shifted (x, -y); draw pic; but the log says this is wrong: metapost log > >> unknown picture pic metapost log > >> ApplicationComponentLogo metapost log > ! Equation cannot be performed (unknown picture=numeric). metapost log > metapost log > ( metapost log > <*> ... h:=53.000;pic := ApplicationComponentLogo( metapost log > w, h, typeString) shifted... SoI need to inspect what is fed to METAPOST to see why METAPOST thinks pic or ApplicationComponentLogo have not been defined. you can enable trackers, like metapost.lua metapost.runs metapost.textexts metapost.scripts metapost.graphics metapost.tracingall metapost.terminal - 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] Quizz
On 3/15/2020 10:46 AM, Henning Hraban Ramm wrote: Am 15.03.20 um 10:34 schrieb Fabrice Couvreur: Hi, With the Coronavirus pandemic, my school will close like all the others. We chose to work with Microsoft Teams. I know how to file Math exercises written with ConteXt and export to pdf format. Is it possible with ConteXt to create interactive Quizz? You can create forms that work in Adobe Reader, but Radiobuttons are broken in ConTeXt, and if you want to add validation, then good luck getting JavaScript functions to work. radiobuttons are broken by design: initialization, default rendering, synchronization over pages (we have a parent child model for which support seem to differ per viewer/version) ... it's hard to support all the features (default rendering + appearances and such) maybe i should implement it from scratch and only support the real minimal set of options (so that what is not supported can also not fail) i really spent a lot of time on this and once you get 'this' working, some side effect 'there' pops up (i probably made a remark in the source someplace but for instance some widgets have the build in default appeances that then depend on for instance dingbats overload user appeances) .. i think in the end one should maybe not implement any owhat the 'standard' permits and just emulate what acrobat does, and exactly that (it's the only browser that does them anyway) (the static part of pdf is ok, in the dynamic part is there is much crap, and i'm not even talking of dependencies on javascript or flash) 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] METAPOST vardef returning multiple and non-numeric types as a single answer?
> On 16 Mar 2020, at 10:10, Taco Hoekwater wrote: > > > >> On 16 Mar 2020, at 09:53, Gerben Wierda wrote: >> >> Hola! So, the arguments passed to macros are by reference and not by value? >> I could have known of course, they are simple expansions, but I’d like to be >> sure. IfI assign to a variable inside a vardef macro and that variable is >> not ’save’d I’m changing the original? > > Yes. (A simple test would have confirmed that) Oops, sorry, no! I was wrong on that… it must be too early for me. vardef Foo(text y) = scantokens(y&":=5”); enddef; Foo("x"); This would work, but that is weird. This also works, and that is why I had the erroneous memory that it would work always: vardef Foo(expr a)(text y) = y[a] := 5; enddef; numeric foo[]; foo[1] = 6; Foo(1,foo); or you could use global variables, of course. Main point: Metapost is not an easy language to grasp. If you want to really understand how it works, you should study the Metafont book by DEK. As you can clearly see, even experienced users are likely to make mistakes. Best wishes, Taco ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
[NTG-context] Can is somehow inspect the intermediate results of an mtxrun?
I have an mtxrun on a .tex file that has problems I need to debug. The .tex file handles well, but whenMETAPOST has a go, it crashes. But after the run, I cannot inspect what source was fed to METAPOST. Can I inspect that (outside of what the log tells me)? In this case, I know METAPOST is fed: picture pic; x:=80.000; y:=200.000; w:=133.000; h:=53.000;pic := ApplicationComponentLogo( w, h, typeString) shifted (x, -y); draw pic; but the log says this is wrong: metapost log> >> unknown picture pic metapost log> >> ApplicationComponentLogo metapost log> ! Equation cannot be performed (unknown picture=numeric). metapost log> metapost log>( metapost log> <*> ... h:=53.000;pic := ApplicationComponentLogo( metapost log>w, h, typeString) shifted... SoI need to inspect what is fed to METAPOST to see why METAPOST thinks pic or ApplicationComponentLogo have not been defined. G___ 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] METAPOST vardef returning multiple and non-numeric types as a single answer?
> On 16 Mar 2020, at 09:53, Gerben Wierda wrote: > > Hola! So, the arguments passed to macros are by reference and not by value? I > could have known of course, they are simple expansions, but I’d like to be > sure. IfI assign to a variable inside a vardef macro and that variable is not > ’save’d I’m changing the original? Yes. (A simple test would have confirmed that) Taco ___ 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] METAPOST vardef returning multiple and non-numeric types as a single answer?
Hola! So, the arguments passed to macros are by reference and not by value? I could have known of course, they are simple expansions, but I’d like to be sure. IfI assign to a variable inside a vardef macro and that variable is not ’save’d I’m changing the original? G > On 16 Mar 2020, at 09:31, Taco Hoekwater wrote: > > > >> On 15 Mar 2020, at 11:22, Gerben Wierda wrote: >> >> I would like a vardef macro to return the pair of a picture and a bounding >> box. I don't want to use the setbound operator, because as soon as I do >> that, I cannot access the components of the picture anymore with pathpart. >> >> I found metapost vardef returning multiple values on StackExchange but that >> is about returning multiple values of the same numeric type. Is it possible >> to have vardef return a set of (picture, path) or (picture, picture) in some >> way? If not, I need to make two vardef macros for each result type. > > Sure, using that same endgroup,begingroup trick. But since there is no > multi-assignment in metapost that doesn’t you help much. > Either two separate vardefs or passing the to-be-assigned variable(s) as an > extra argument(s) are generally more practical. > > Best wishes, > Taco > > > > ___ > 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] (bug?) wrong interline in \placelist[alternative=d] with Pagella italics
On 3/15/20 10:56 PM, Wolfgang Schuster wrote: > Pablo Rodriguez schrieb am 15.03.2020 um 20:32: >> [...] >> Everthing is fine when italic fonts aren’t used. > > It can be fixed with a strut option for lists, e.g. > \setuplist[strut=no]. The problem in this case is that the ex-height for > the italic font is larger than the ex-height for the upright font which > pushes the text down because add a strut at the begin and end of the > entries. Many thanks for your reply, Wolfgang. I don’t get \setuplist[strut=no] working in the minimal sample I sent yesterday. > Below is a minimal example of the problem, the \setstrut setting changes > the height of the strut for the italic font. I must admit that I don’t understand how to handle struts (I’m not sure I understand what they actually are.) > Most fonts (I checked only a small number) don't have such a big > difference between the ex-height of the upright and italic styles which > makes it hard to notice the problem. Yesterday I realized that Pagella was an extreme case, because I tried to report this issue before, but Latin Modern didn’t show the issue (so I thought I was doing something wrong). Many thanks for your 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] Why do I see the outline of the green box in this METAPOST code?
Move the fills to within the image(), and build it up in stacking order. > On 14 Mar 2020, at 16:29, Gerben Wierda wrote: > > Code: > > vardef Foo(expr w, h, lh) = >save pth; path pth; >save pthtwo; path pthtwo; >save pththree; path pththree; >save pic; picture pic; >pth = fullsquare xysized (w, h); >pthtwo = fullsquare xysized (2*lh, lh) shifted (-w/2, 2.5*lh); >pththree = fullsquare xysized (2*lh, lh) shifted (-w/2, lh); >fill pth withcolor green; >fill pthtwo withcolor yellow; >fill pththree withcolor yellow; >pic := image ( >draw pth; >draw pthtwo; >draw pththree; >); >% setbounds pic to pth; >pic > enddef ; > > > Call: > > \startMPpage > > picture s ; s := Foo(8cm, 2cm, 0.25cm); > > draw s; > > drawdot center leftboundary s withpen pencircle scaled 2 withcolor green; > drawdot center rightboundary s withpen pencircle scaled 2 withcolor blue; > drawdot point .25 along topboundary s withpen pencircle scaled 2 withcolor > yellow; > drawdot .25[llcorner s, lrcorner s] withpen pencircle scaled 2 withcolor > magenta; > drawdot origin withpen pencircle scaled 4 withcolor red; > > \stopMPpage > > > Output: > > > > Why is the outline of the green box visible in the yellow boxes? And how can > I prevent this from happening? > ___ > 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 > ___ Taco Hoekwater Elvenkind BV ___ 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] METAPOST vardef returning multiple and non-numeric types as a single answer?
> On 15 Mar 2020, at 11:22, Gerben Wierda wrote: > > I would like a vardef macro to return the pair of a picture and a bounding > box. I don't want to use the setbound operator, because as soon as I do that, > I cannot access the components of the picture anymore with pathpart. > > I found metapost vardef returning multiple values on StackExchange but that > is about returning multiple values of the same numeric type. Is it possible > to have vardef return a set of (picture, path) or (picture, picture) in some > way? If not, I need to make two vardef macros for each result type. Sure, using that same endgroup,begingroup trick. But since there is no multi-assignment in metapost that doesn’t you help much. Either two separate vardefs or passing the to-be-assigned variable(s) as an extra argument(s) are generally more practical. Best wishes, Taco ___ 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 ___