Re: [NTG-context] How to exclude certain figures from list of figures in ConTeXt?
Hi Wolfgang, Thank you very much for your suggestion! Can you explain a bit the trick behind this mechanism? Regards, Gerard On 13-04-15 21:02, Wolfgang Schuster wrote: Am 12.04.2015 um 20:53 schrieb Geert Verhaag verhaagg...@ziggo.nl: Hi, I was wondering whether it is possible to exclude certain figures of a document using the \placelistoffigures command in ConTeXt? For example those that start having a reference like ['fig:figure:exclude‘]? You can create a new float environment which inherits all values (including the counter) from the figure environment. \setupexternalfigures[location=default] \definefloat[nofigure][nofigures][figure] \starttext \placelist[figure] \blank[4*line] \startplacefigure[title=A duth cow] \externalfigure[cow][width=6cm] \stopplacefigure \startplacenofigure[title=A duth mill] \externalfigure[mill][width=6cm] \stopplacenofigure \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] How to exclude certain figures from list of figures in ConTeXt?
Hi Wolfgang, Thank you very much for your clarification! It just does the job very well, and this list completes my book (written in Dutch!) entirely typeset using ConTeXt! And this is of course mentioned in the colophon of the book. Regards, Gerard On 16-04-15 22:33, Wolfgang Schuster wrote: Am 15.04.2015 um 22:12 schrieb Geert Verhaag verhaagg...@ziggo.nl: Hi Wolfgang, Thank you very much for your suggestion! Can you explain a bit the trick behind this mechanism? I created only a new float environment which copies all values from the figure environment but it saves all caption entries in its own nofigure list and when you show only the figure entries in the list the others are hidden. \setupexternalfigures[location=default] \definefloat[nofigure][nofigures][figure] \starttext \subject{Figure entries} \placelist[figure] \subject{Figure and nofigure entries} \placelist[figure,nofigure] \blank[4*line] \startplacefloat[figure][title=A dutch cow] \externalfigure[cow][width=6cm] \stopplacefloat \startplacefloat[nofigure][title=A dutch mill] \externalfigure[mill][width=6cm] \stopplacefloat \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 ___
[NTG-context] How to exclude certain figures from list of figures in ConTeXt?
Hi, I was wondering whether it is possible to exclude certain figures of a document using the \placelistoffigures command in ConTeXt? For example those that start having a reference like ['fig:figure:exclude']? Gerard ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
[NTG-context] Duplex printing problem!
Hi, I try something like this: *\definepapersize[BOOK][width=270mm,height=195mm]** **\setuppapersize[BOOK][A4,landscape]* while my *\setuplayout* command contains: *location={doublesided,left}* among other settings. I would expect that the BOOK-page on the front and back side would move to the correct corner, but that doesn't seem to happen. Both on the front and back are shifted to the left!? I'would expect them to alter position between left and right! What am I doing wrong? Regards, Gerard Verhaag By the way running context --version yields the following info: mtx-context | ConTeXt Process Management 0.60 mtx-context | mtx-context | main context file: /home/verhaag/context/tex/texmf-context/tex/context/base/context.mkiv mtx-context | current version: 2013.08.11 20:23 ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
[NTG-context] Font installation help needed!
Hi, I'm currently using ConTeXt version: mtx-context | ConTeXt Process Management 0.60 mtx-context | mtx-context | main context file: /home/verhaag/context/tex/texmf-context/tex/context/base/context.mkiv mtx-context | current version: 2013.08.11 20:23 I'd like to use the Advent Pro font, so I downloaded the font and have 7 ttf files available. After looking around for some manual I found: "Integrating TrueType Fonts into ConTEXt" by Thomas A. Schmitz. Immediately I run into problems when trying to run the texfont command. My Linux (ubuntu 14.04) says: The program 'texfont' is currently not installed. I did a standalone installation years ago of this version of ConTeXt, and don't dare to upgrade because I might run into other issues, sorry! Any hints on how to procede installing the Advent Pro font to this version of ConTeXt are very much welcomed! Regards, Gerard -- ___ 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] Font installation help needed!
On 01-10-18 01:49, Aditya Mahajan wrote: On Sun, 30 Sep 2018, Geert Verhaag wrote: Hi, I'm currently using ConTeXt version: mtx-context | ConTeXt Process Management 0.60 mtx-context | mtx-context | main context file: /home/verhaag/context/tex/texmf-context/tex/context/base/context.mkiv mtx-context | current version: 2013.08.11 20:23 You should update your context installation. This is more than 5 year old! I'd like to use the Advent Pro font, so I downloaded the font and have 7 ttf files available. After looking around for some manual I found: "Integrating TrueType Fonts into ConTEXt" by Thomas A. Schmitz. That is meant for MkII. Unless there is a specific reason for you to use MkII (like working with an old setup being used in production), you should use MkIV. One of the advantage of MkIV is that it is MUCH easier to work with TTF and OTF fonts. I did a standalone installation years ago of this version of ConTeXt, and don't dare to upgrade because I might run into other issues, sorry! You can install standalone in a parallel directory. If something goes wrong with the installation, you can continue using your current installation. 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 ___ Hi, Thanks for your advice; but what is the correct MkIV procedure? Is it the one described at: https://wiki.contextgarden.net/Fonts_in_LuaTeX? I understand that the texfont way of doing it is out-dated! Regards, Gerard -- ___ 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] Write your own module?
Hi, I'd like to start writing a module, and test it using ConTeXt MkIV standalone installation. Dived into wiki.contextgarden.net but was unable to find a basic tutorial on how to tackle this. Yes, I did find a module template, but can't figure out where the module should go such that ConTeXt can find and load it. Any hint would be very helpful. Thanks in advance! Regards, Gerard ___ 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] XML xmldoif struggle!
Hi, I've the following XML tag in my XML file: EURO . with invoice being the root tag! Now I have a setup defined as below (only part!): \startxmlsetups xml:invoice:invoice \xmlfirst{#1}{currency} \par \xmldoif{\xmlfirst{#1}{currency}}{contains(text(),'EURO')} { Euro set! \par } . The \xmlfirst{#1}{currency} command prints EURO as expected. But the xmldoif command doesn't cause the Euro set be printed?! What's wrong here? The manual xml-mkiv.pdf doesn't give me any hint on how to make this work! Regards, Gerard -- ___ 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] XML xmldoif struggle!
Hoi Pablo, Thanks for your prompt reply! The output Euro set! is printed always, it doesn't matter whether I put EURO or DOLLAR first?! Also I can't find any clue on the suggested page 49 of xml-mkiv.pdf manual, sorry! By the way, in my document it still doesn't seem to work! I'm afraid all this is far too complex for me! The documentation simply isn't meant for beginners like me, sorry! Regards, Gerard On 01-05-19 13:20, Pablo Rodriguez wrote: On 4/30/19 9:58 PM, Geert Verhaag wrote: [...] \startxmlsetups xml:invoice:invoice \xmlfirst{#1}{currency} \par \xmldoif{\xmlfirst{#1}{currency}}{contains(text(),'EURO')} { Euro set! \par } [...] But the xmldoif command doesn't cause the Euro set be printed?! What's wrong here? The manual xml-mkiv.pdf doesn't give me any hint on how to make this work! Hi Geert, the syntax reads \xmldoif{#1}{lpath}{action}. So your conditional may read: \xmldoif{#1}{currency[first() and contains(text(),'EURO')]} {Euro set!} In a complete sample (with dollar set first [it won’t show the result unless you set EURO first]): \startbuffer[demo] DOLLAR EURO \stopbuffer \startxmlsetups xml:initialize \xmlsetsetup{#1}{doc}{xml:*} \stopxmlsetups \xmlregistersetup{xml:initialize} \startxmlsetups xml:doc \xmlfirst{#1}{currency} \par \xmldoif{#1}{currency[first() and contains(text(),'EURO')]} {Euro set!} \stopxmlsetups \setuppapersize[A8] \starttext \xmlprocessbuffer{main}{demo}{} \stoptext It is all in xml-mkiv.pdf (http://www.pragma-ade.com/general/manuals/xml-mkiv.pdf#page=49). I have just discovered it . Just in case it helps, 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 ___ ___ 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] XML xmldoif struggle!
Hi Pablo, Yes, I got it working! It is somewhat tricky. Trying to understanding the concepts behind all this isn't easy for me, but I'm bashing on. Thanks! Regards, Gerard On 02-05-19 14:47, Pablo Rodriguez wrote: On 5/1/19 9:28 PM, Geert Verhaag wrote: Hoi Pablo, Thanks for your prompt reply! The output Euro set! is printed always, it doesn't matter whether I put EURO or DOLLAR first?! Hi Geert, my fault, the conditional should read: \xmldoif{#1}{currency[position()==1 and contains(text(),'EURO')]} {Euro set!} I hope it works fine now. 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 ___ ___ 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] XML xmldoif struggle!
Hi Aditya, The ConTeXt team did a great job in writing the manual xml-mkiv.pdf, but I think it is not meant for a beginner. Its contents is rather overwhelming when trying it for the first time. For me, I don't use luatex a lot, so that adds to the difficulty of trying it out. Regards, Gerard On 03-05-19 00:51, Aditya Mahajan wrote: On Thu, 2 May 2019, Geert Verhaag wrote: Yes, I got it working! It is somewhat tricky. Trying to understanding the concepts behind all this isn't easy for me, but I'm bashing on. I also find understanding XML processing rules to be complicated. I simply convert the XML to a lua table, and then use all the processing in lua using CLD (context lua documents). 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 ___ ___ 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] Request for xml.filter explanation!
Hi, I've the following xml file: * a paragraph of text 40.2 another paragraph of text 10.7 still another paragraph! 20.5 * And want to calculate the total value of all the objects: like so: *\startxmlsetups xml:example:base \xmlsetsetup{#1}{content|object}{xml:example:*} \stopxmlsetups \xmlregisterdocumentsetup{example}{xml:example:base} \startxmlsetups xml:example:content totalvalue: \xmlfunction{#1}{totalvalue} \xmlflush{#1} \endgraf \stopxmlsetups \startxmlsetups xml:example:object attribute : \xmlatt{#1}{mid} \par \stopxmlsetups % LUA \startluacode function xml.functions.totalvalue(root) local score = 0 for e in xml.collected(root,"/object") do tex.write('Okay!') --score = score + xml.filter(e,"xml:///value/number()") or 0 end tex.write(score) end \stopluacode \starttext \xmlprocessfile{example}{content.xml}{} \stoptext* * * When I run this example I get: *totalvalue: Okay!Okay!Okay!0 attribute : a attribute : b attribute : c* That looks allright! But when I incorporate the line: *score = score + xml.filter(e,"xml:///value/number()") or 0* the following Lua error is thrown: ** *! LuaTeX error [string "\directlua "]:5: attempt to perform arithmetic on a nil value* Has anybody any idea what I'm doing wrong here? The manual *xml-mkiv.pdf* doesn't give any clue about this! Regards, Gerard -- ___ 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] How to get attribute value from xml tag?
Hi, Struggling with XML in ConTeXt. I'have the following tag in my xml file: ... 20 ... \startxmlsetups xml:invoice:travel \xmlfirst{#1}{distance} \stopxmlsetups The \xmlfirst{#1}{distance} yields /20/, but how can the unit attribute value /km/ be accessed? Gerard -- ___ 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] How to get attribute value from xml tag?
On 20-10-19 16:38, Thomas A. Schmitz wrote: On 20. Oct 2019, at 16:05, Geert Verhaag wrote: The \xmlfirst{#1}{distance} yields 20, but how can the unit attribute value km be accessed? Gerard \xmlattribute{#1}{/distance}{unit} (probably, you need to make a real example. See xml-mkiv.pdf, chapter 3.6) 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 ___ -- Hi, Thomas, thanks a lot, and it is fairly simple if you know how to read the following (taken from page 22, chapter 3.6): \xmlattribute {...} {...} {...} finds a first match for LPATH at NODE and returns the value of attribute NAME or empty if no such attribute exists But now I get it, thanks! Regards, Gerard ___ 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] Struggling with startuseMPgraphic and string argument!
Hi ConTeXt users, That's indeed magic and it works! Hans, thanks for your prompt answer! But I would like to take this a step further, by introducing a macro within the start/stopuseMPgraphic structure like so: \startuseMPgraphic{name}{s::lbl} def mymacro (text lb) = pair a ; a := (3cm,3cm) ;label.top("String: " & str lb,a) ; enddef ; mymacro(\MPvariable{lbl}) ; \stopuseMPgraphic and this works too, but what if I introduce another text argument like: \startuseMPgraphic{name}{s::lbl,s::label} def mymacro (text lb,lbx) = pair a ; a := (3cm,3cm) ;label.top("String: " & str lb & ", " & str lbx,a) ; enddef ; mymacro(\MPvariable{lbl},\MPvariable{label}) ; \stopuseMPgraphic However this doesn't work! It gives the following error: ! Missing argument to mymacro. Isn't that weird? But perhaps it has to do with me not understanding argument passing properly within METAPOST macros! Can someone please explain why this 2 argument example doesn't work? (But maybe this isn't the proper list to ask questions like these. If so, I'm sorry for bothering you!) Regards, Gerard On 16-09-2020 16:32, Geert Verhaag wrote: Hi, I'm trying to pass a string argument value to an MPgraphic but it doesn't seem to work: Tried the following: \startuseMPgraphic{name}{lbl} pair a ; a := (3cm,3cm) ;label.top("\MPvariable{lbl}",a) ; \stopuseMPgraphic \starttext \useMPgraphic{name}{lbl=1} \stoptext The above works as expected! But the following doesn't: \startuseMPgraphic{name}{lbl} pair a ; a := (3cm,3cm) ;label.top("\MPvariable{lbl}",a) ; \stopuseMPgraphic \starttext \useMPgraphic{name}{lbl=abc} \stoptext It yields: 1 \startuseMPgraphic{name}{lbl} 2 pair a ; a := (3cm,3cm) ;label.top("\MPvariable{lbl}",a) ; 3 \stopuseMPgraphic 4 5 %\startuseMPgraphic{name}fill fullcircle scaled 200pt withcolor .625yellow ;\stopuseMPgraphic 6 7 \starttext 8 Example: 9 >> \useMPgraphic{name}{lbl=abc} 10 \stoptext 11 a \m_meta_current_variable a-a bc ... \hbox {\scratchdimen \m_meta_current_variable sp}\ifzeropt \wd \b_meta_v... \secondoftwoarguments #1#2b-#2 \9>>1 #1,2-\meta_prepare_instance_variable {#1} \syst_helpers_do_process_comm... \syst_helpers_do_process_comma_list ...rgument #1, ]\relax \global \advance \... ... l.9 \useMPgraphic{name}{lbl=abc} So it seems that only numbers can be passed not character strings! Why is that? Is there a possibility to achieve this functionality? Regards, Gerard ___ 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 ___ -- Sender:G.C.H.M. Verhaag St. Jorisstraat 29 5954 AN Beesel NETHERLANDS Tel.: +31-(0)619502702, E-mail: verhaagg...@ziggo.nl Ik vertrouw erop dat de persoonlijke gegevens, te vinden in deze mail, uitsluitend voor correspondentie met ondergetekende worden gebruikt en beslist niet voor reclamedoeleinden of welke andere wijze dan ook. Het opnemen van deze gegevens, in welk soort van opslagsysteem dan ook, evenals het doorgeven ervan aan derden, zie ik als een schending van mijn privacy. ___ 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] Struggling with startuseMPgraphic and string argument!
Hi, I'm trying to pass a string argument value to an MPgraphic but it doesn't seem to work: Tried the following: \startuseMPgraphic{name}{lbl} pair a ; a := (3cm,3cm) ;label.top("\MPvariable{lbl}",a) ; \stopuseMPgraphic \starttext \useMPgraphic{name}{lbl=1} \stoptext The above works as expected! But the following doesn't: \startuseMPgraphic{name}{lbl} pair a ; a := (3cm,3cm) ;label.top("\MPvariable{lbl}",a) ; \stopuseMPgraphic \starttext \useMPgraphic{name}{lbl=abc} \stoptext It yields: 1 \startuseMPgraphic{name}{lbl} 2 pair a ; a := (3cm,3cm) ;label.top("\MPvariable{lbl}",a) ; 3 \stopuseMPgraphic 4 5 %\startuseMPgraphic{name}fill fullcircle scaled 200pt withcolor .625yellow ;\stopuseMPgraphic 6 7 \starttext 8 Example: 9 >> \useMPgraphic{name}{lbl=abc} 10 \stoptext 11 a \m_meta_current_variable a-a bc ... \hbox {\scratchdimen \m_meta_current_variable sp}\ifzeropt \wd \b_meta_v... \secondoftwoarguments #1#2b-#2 \9>>1 #1,2-\meta_prepare_instance_variable {#1} \syst_helpers_do_process_comm... \syst_helpers_do_process_comma_list ...rgument #1, ]\relax \global \advance \... ... l.9 \useMPgraphic{name}{lbl=abc} So it seems that only numbers can be passed not character strings! Why is that? Is there a possibility to achieve this functionality? Regards, Gerard ___ 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] Struggling with startuseMPgraphic and string argument!
On 18-09-2020 09:03, Hans Hagen wrote: On 9/17/2020 9:41 PM, Geert Verhaag wrote: Hi ConTeXt users, That's indeed magic and it works! Hans, thanks for your prompt answer! But I would like to take this a step further, by introducing a macro within the start/stopuseMPgraphic structure like so: \startuseMPgraphic{name}{s::lbl} def mymacro (text lb) = pair a ; a := (3cm,3cm) ;label.top("String: " & str lb,a) ; enddef ; mymacro(\MPvariable{lbl}) ; \stopuseMPgraphic and this works too, but what if I introduce another text argument like: \startuseMPgraphic{name}{s::lbl,s::label} def mymacro (text lb,lbx) = pair a ; a := (3cm,3cm) ;label.top("String: " & str lb & ", " & str lbx,a) ; enddef ; mymacro(\MPvariable{lbl},\MPvariable{label}) ; \stopuseMPgraphic However this doesn't work! It gives the following error: ! Missing argument to mymacro. Isn't that weird? But perhaps it has to do with me not understanding argument passing properly within METAPOST macros! Can someone please explain why this 2 argument example doesn't work? (But maybe this isn't the proper list to ask questions like these. If so, I'm sorry for bothering you!) Regards, Gerard On 16-09-2020 16:32, Geert Verhaag wrote: Hi, I'm trying to pass a string argument value to an MPgraphic but it doesn't seem to work: Tried the following: \startuseMPgraphic{name}{lbl} pair a ; a := (3cm,3cm) ;label.top("\MPvariable{lbl}",a) ; \stopuseMPgraphic \starttext \useMPgraphic{name}{lbl=1} \stoptext The above works as expected! But the following doesn't: \startuseMPgraphic{name}{lbl} pair a ; a := (3cm,3cm) ;label.top("\MPvariable{lbl}",a) ; \stopuseMPgraphic \starttext \useMPgraphic{name}{lbl=abc} \stoptext It yields: 1 \startuseMPgraphic{name}{lbl} 2 pair a ; a := (3cm,3cm) ;label.top("\MPvariable{lbl}",a) ; 3 \stopuseMPgraphic 4 5 %\startuseMPgraphic{name}fill fullcircle scaled 200pt withcolor .625yellow ;\stopuseMPgraphic 6 7 \starttext 8 Example: 9 >> \useMPgraphic{name}{lbl=abc} 10 \stoptext 11 a \m_meta_current_variable a-a bc ... \hbox {\scratchdimen \m_meta_current_variable sp}\ifzeropt \wd \b_meta_v... \secondoftwoarguments #1#2b-#2 \9>>1 #1,2-\meta_prepare_instance_variable {#1} \syst_helpers_do_process_comm... \syst_helpers_do_process_comma_list ...rgument #1, ]\relax \global \advance \... ... l.9 \useMPgraphic{name}{lbl=abc} So it seems that only numbers can be passed not character strings! Why is that? Is there a possibility to achieve this functionality? \startuseMPgraphic{name}{s::lbl,s::label} def mymacro(expr a, b) = label.top("str:(" & a & "," & b & ")",(3cm,3cm)) ; enddef ; mymacro("\MPvariable{lbl}","\MPvariable{label}") \stopuseMPgraphic \starttext \useMPgraphic{name}{lbl=abc,label=pqr} \useMPgraphic{name}{lbl=def,label=xyz} \stoptext - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl - Hi Hans, It really is in the details!!! I was convinced that I did something wrong somewhere, but couldn't figure out what. Thanks very much for your kind help! Regards, Gerard ___ 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 ___