Re: [NTG-context] Translation of ConTeXt interface
Math. I get the following error : fonts > preloading latin modern fonts (second stage) fonts > defining > font with asked name 'fichier' is not found using lookup 'file' fonts > defining > unknown font 'fichier', loading aborted I suppose that due to the translation of "file" to "fichier". It's OK when I switch back to - setupstrings cd:file ==> file You can translate these string because they are only used in the command list to provide the texts which are shown in uppercase letter, e.g. NUMBER. - variables file ==> file Constants (\c!...) and variables (\v!...) can be changed, only parameters which use the form \s!... have to be english in all cases (saves memory and improves performance). How can I translate the variable "file" into fichier, without messing with fonts (and maybe other file related functions) There shouldn't be a problem with fonts because they use \s!file or \s!name which aren't translated (unless you made the mistake and have \c!file in your typescripts). It's possible there is a bug somewhere but you have to provide a minimal example. My understanding: I translated \setupbodyfont into \configurerfonteprincipale. But I didn't specify any font in the input file. As soon as I specified \configurerfonteprincipale[pagella,10pt] in the input file, font messages "'fichier' is not found" disappear. Is there an additionnal thing to do in order to enable the loading of a default math font, without any font specification, but still with translations of "file" into "fichier" ? ___ 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] Translation of ConTeXt interface
So, I'm still doing something wrong, because changing the translation of "figure" in "mult-def.lua" (in the part "variables"), only affect : 1- command "\startfigure \stopfigure" 2- "figure" in "\setuppageinjection" > alternative = figure buffer... You have to provide your modified mult-def.lua file, otherwise there is no way to check what's wrong. Patch file : mult-def.lua.test1_figure.diff context --make fr context --interface=fr --global --result=setup-fr x-setups-overview.mkiv Then the pdf file shows - \demarrefigurefr as expected (p62) but - \placefigure instead of \placefigurefr (p190) - \demarreplacefigure instead of \demarreplacefigurefr (p72) the translation of the variable "itemize" has no impact on the setup-fr.pdf file produced But, I just found that if I actually use the translated commands in a test.tex file, it just works. Same as above, provide your translations. Patch file : mult-def.lua.test2_itemize.diff Input file : test2_itemize.tex context --make fr context --interface=fr --global --result=setup-fr x-setups-overview.mkiv context test2_itemize.tex setup-fr.pdf shows "\debutitemize ... \finitemize" page 41 instead of "\debutlister ... \finlister" but the input file, with "\debutlister ... \finlister", works great. There shouldn't be a problem with fonts because they use \s!file or \s!name which aren't translated (unless you made the mistake and have \c!file in your typescripts). It's possible there is a bug somewhere but you have to provide a minimal example. Understood, I am going to check. --- mult-def.lua.initial 2020-06-26 10:40:39.0 +0200 +++ mult-def.lua 2020-06-26 14:21:55.598929654 +0200 @@ -13522,7 +13522,7 @@ ["cs"]="obrazek", ["de"]="abbildung", ["en"]="figure", - ["fr"]="figure", + ["fr"]="figurefr", ["it"]="figura", ["nl"]="figuur", ["pe"]="شکل", --- mult-def.lua.initial 2020-06-26 10:40:39.0 +0200 +++ mult-def.lua 2020-06-26 23:16:25.039895542 +0200 @@ -5444,7 +5444,7 @@ ["cs"]="starttext", ["de"]="starttext", ["en"]="starttext", - ["fr"]="demarretexte", + ["fr"]="debuttexte", ["it"]="iniziatesto", ["nl"]="starttekst", ["pe"]="شروعمتن", @@ -5846,7 +5846,7 @@ ["cs"]="stoptext", ["de"]="stoptext", ["en"]="stoptext", - ["fr"]="stoppetexte", + ["fr"]="fintexte", ["it"]="terminatesto", ["nl"]="stoptekst", ["pe"]="پایانمتن", @@ -10758,7 +10758,7 @@ ["cs"]="start", ["de"]="start", ["en"]="start", - ["fr"]="demarre", + ["fr"]="debut", ["it"]="inizia", ["nl"]="start", ["pe"]="شروع", @@ -10792,7 +10792,7 @@ ["cs"]="stop", ["de"]="stop", ["en"]="stop", - ["fr"]="stoppe", + ["fr"]="fin", ["it"]="termina", ["nl"]="stop", ["pe"]="پایان", @@ -11861,7 +11861,7 @@ ["cs"]="start", ["de"]="start", ["en"]="start", - ["fr"]="demarre", + ["fr"]="debut", ["it"]="inizia", ["nl"]="start", ["pe"]="شروع", @@ -11871,7 +11871,7 @@ ["cs"]="stop", ["de"]="stop", ["en"]="stop", - ["fr"]="stoppe", + ["fr"]="fin", ["it"]="termina", ["nl"]="stop", ["pe"]="پایان", @@ -14398,7 +14398,7 @@ ["cs"]="polozka", ["de"]="pos", ["en"]="item", - ["fr"]="element", + ["fr"]="elem", ["it"]="elemento", ["nl"]="som", ["pe"]="آیتم", @@ -14407,7 +14407,7 @@ ["itemize"]={ ["cs"]="vycet", ["de"]="aufzaehlung", - ["en"]="itemize", + ["en"]="lister", ["fr"]="lister", ["it"]="elenco", ["nl"]="opsomming", @@ -16505,7 +16505,7 @@ ["cs"]="start", ["de"]="start", ["en"]="start", - ["fr"]="demarre", + ["fr"]="debut", ["it"]="inizia", ["nl"]="start", ["pe"]="شروع", @@ -16529,7 +16529,7 @@ ["cs"]="stop", ["de"]="stop", ["en"]="stop", - ["fr"]="stoppe", + ["fr"]="fin", ["it"]="termina", ["nl"]="stop", ["pe"]="پایان", % interface=fr \debuttexte texte avant \debutlister \elem premier \elem second \finlister texte ensuite \fintexte ___ 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] pagecolumns: get the current column
On 6/26/2020 5:39 PM, mf wrote: Hello list, I'm using a 2-columns layout and I'd like to put some information in the margin. I should put that information in the left margin when I'm in the left column, and in the right margin when I'm in the right column, to prevent the extra information overlapping the main text in the other column. I found a useful counter in page-pcl.mkiv: \c_page_col_current. Here's a MWE: \unprotect \def\curCol{\c_page_col_current} \protect \def\InfoInMargin#1{\doifelse{\the\curCol}{1}{\inmargin{#1}}{\inothermargin{#1}}} \def\TestText{\InfoInMargin{\bf \the\curCol}\input ward \InfoInMargin{\bf \the\curCol} \input ward} \starttext \startpagecolumns[n=2,distance=25mm] \dorecurse{5}{\TestText\par} \stoppagecolumns \stoptext \c_page_col_current works most of the time, but unfortunately it tells you the current column before the lines of a paragraph get distributed over columns. So sometimes it fails. You can see that in the MWE: the bold "1" between columns in the upper part of the page. It should be a bold "2" in the right margin. Is there a better way to read the current column? Because I want you to run the usual stress test on the latest greatest, here's your reward: \usemodule[article-basic] \setupalign[verytolerant,stretch] \dontcomplain \newcounter\MyCounter \def\InfoInMargin#1% {\doglobal\increment\MyCounter \ifodd\MPcolumn{\MPregion{MyPos:\MyCounter}}\relax \inmargin{\xypos{MyPos:\MyCounter}#1}% \else \inothermargin{\xypos{MyPos:\MyCounter}#1}% \fi} \starttext \startpagecolumns[n=2,distance=10mm] \dorecurse {50} { \InfoInMargin{\bf#1}\input ward \InfoInMargin{\sl#1}\input ward \par } \stoppagecolumns \stoptext - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] error running wiki example with labels
On 6/26/2020 4:30 PM, Jan-Erik Hägglöf wrote: function call [844]: ...-64/tex/texmf-context/tex/context/base/mkiv/node-syn.lua:435: attempt to index a nil value (upvalue 'filehandle') i'll add a catch there but the issue is likely that you enable synctex while at the same time enable page imposition which reshuffles pages in ways that can interfere you can try to add \setupsynctex[state=stop] at the top of that file 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 ___
[NTG-context] pagecolumns: get the current column
Hello list, I'm using a 2-columns layout and I'd like to put some information in the margin. I should put that information in the left margin when I'm in the left column, and in the right margin when I'm in the right column, to prevent the extra information overlapping the main text in the other column. I found a useful counter in page-pcl.mkiv: \c_page_col_current. Here's a MWE: \unprotect \def\curCol{\c_page_col_current} \protect \def\InfoInMargin#1{\doifelse{\the\curCol}{1}{\inmargin{#1}}{\inothermargin{#1}}} \def\TestText{\InfoInMargin{\bf \the\curCol}\input ward \InfoInMargin{\bf \the\curCol} \input ward} \starttext \startpagecolumns[n=2,distance=25mm] \dorecurse{5}{\TestText\par} \stoppagecolumns \stoptext \c_page_col_current works most of the time, but unfortunately it tells you the current column before the lines of a paragraph get distributed over columns. So sometimes it fails. You can see that in the MWE: the bold "1" between columns in the upper part of the page. It should be a bold "2" in the right margin. Is there a better way to read the current column? Thanks, Massi ___ 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] error running wiki example with labels
The issue is the same after update of lmtx but the complaint differs. I’m not sure the full command sequence that runs by vim, anyone else who knows the internal default by vim in context mode? However the result from commandline in vim :!context % works fine but not when I run :ConTeXt The thing is also when I do the example code on wiki with page command commented out Errorlog with mtxrun inside vim open source > level 1, order 1, name 'cont-yes.mkiv' system > system > ConTeXt ver: 2020.06.25 11:23 MKIV beta fmt: 2020.6.25 int: english/english system > system > 'cont-new.mkiv' loaded open source > level 2, order 2, name '/Users/janneman/context-osx-64/tex/texmf-context/tex/context/base/mkiv/cont-new.mkiv' system > beware: some patches loaded from cont-new.mkiv close source> level 2, order 2, name '/Users/janneman/context-osx-64/tex/texmf-context/tex/context/base/mkiv/cont-new.mkiv' system > files > jobname 'labels3', input './labels3', result 'labels3' fonts > latin modern fonts are not preloaded languages > language 'en' is active system > synctex functionality is enabled, expect 5-10 pct runtime overhead! open source > level 2, order 3, name './labels3.tex' open source > level 3, order 4, name '/Users/janneman/context-osx-64/tex/texmf-context/tex/context/fonts/mkiv/type-imp-texgyre.mkiv' close source> level 3, order 4, name '/Users/janneman/context-osx-64/tex/texmf-context/tex/context/fonts/mkiv/type-imp-texgyre.mkiv' open source > level 3, order 5, name '/Users/janneman/context-osx-64/tex/texmf-context/tex/context/base/mkiv/meta-imp-dum.mkiv' close source> level 3, order 5, name '/Users/janneman/context-osx-64/tex/texmf-context/tex/context/base/mkiv/meta-imp-dum.mkiv' metapost> library 'dum' is loaded metapost> initializing instance 'metafun:1' using format 'metafun' and method 'default' metapost> loading 'metafun' as '/Users/janneman/context-osx-64/tex/texmf-context/metapost/context/base/mpiv/metafun.mpxl' using method 'default' metapost> initializing number mode 'scaled' metapost log> metapost log> loading metafun, including plain.mp version 1.004 for metafun iv and xl metapost log> fonts > bodyfont '14pt' is defined (can better be done global) fonts > bodyfont '16.8pt' is defined (can better be done global) fonts > bodyfont '11.2pt' is defined (can better be done global) lua error > lua error on line 1 in file ./labels3.tex: function call [844]: ...-64/tex/texmf-context/tex/context/base/mkiv/node-syn.lua:435: attempt to index a nil value (upvalue 'filehandle') 1 >> \newdimen\LWidth 2 \newdimen\LHeight 3 \newdimen\LDistanceX 4 \newdimen\LDistanceY 5 6 \LWidth=75mm 7 \LHeight=30mm 8 \LDistanceX=0mm 9 \LDistanceY=0mm 10 11 \define[1]\Name{{\switchtobodyfont[14pt]#1}} And the code was as following \newdimen\LWidth \newdimen\LHeight \newdimen\LDistanceX \newdimen\LDistanceY \LWidth=75mm \LHeight=30mm \LDistanceX=0mm \LDistanceY=0mm \define[1]\Name{{\switchtobodyfont[14pt]#1}} \define[1]\Title{#1} \mainlanguage[sv] %\usetypescriptfile [plex] \setupbodyfont [palatino,ss,11pt] \setupinterlinespace[16pt] \useMPlibrary[dum] \useexternalfigure[logo][cow][size=art] \definepapersize[Label][width=\LWidth,height=\LHeight] \setuppapersize[Label][A4] \setuppaper[ nx=2, ny=9, topspace=1cm, backspace=1cm, %dx=\LDistanceX, %dy=\LDistanceY, ] % must come before \setuparranging! \setuparranging [XY] \setuplayout[ location=middle, marking=on, topspace=5mm, backspace=5mm, width=68mm, header=0mm, footer=0mm, ] \setuppagenumbering[state=stop] \definelayer[BG][ x=0mm,y=0mm, width=\LWidth,height=\LHeight, state=repeat] \setupbackgrounds[page][background=BG,] \setlayerframed[BG][ frame=on, framecolor=yellow, width=\LWidth,height=\LHeight, align=flushleft, ]{\strut} \setlayer[BG][ preset=rightbottom, hoffset=3mm, voffset=3mm]{% \externalfigure[logo][height=0.75\LHeight]} \setlayer[BG][ preset=leftbottom, hoffset=5mm, voffset=3mm]{% the context group} \starttext \startlines \Name{Hans Hägar} \Title{CEO · R \& D} %\page \stoplines %\Name{Wolf Schmidt} %\Title{0th Level Support} %\page[yes] %\Name{Mocca Bob} %\Title{the Builder} %\page[yes] %\Name{A. Rockefeller} %\Title{Mad Hatter} %\page[yes] %\Name{Ali Breslau} %\Title{MetaPost Manager} %\page[yes] %\Name{Taco Bellman} %\Title{CFO} %\page[yes] %\stoplines \stoptext Then I issued the regular context command via terminal inside vim And the result went just fine open source > level 1, order 1, name 'cont-yes.mkiv' system > system > ConTeXt ver: 2020.06.25 11:23 MKIV beta fmt: 2020.6.25 int: english/english system > system > 'cont-new.mkiv' loaded open source > level 2, order
Re: [NTG-context] Translation of ConTeXt interface
Garulfo schrieb am 26.06.2020 um 12:27: Thanks a lot Wolfang for your answer. I have 5 additional questions... sorry. --- >> \placeFLOAT becomes \placerFLOAT >> \startplaceFLOAT becomes \debutplacerFLOAT >> \placerchemical becomes \placerchemical >> \startplacerchemical becomes \debutplacerchemical >\placefigure is a combination of the element "place" (\e!place) and the > variable "figure" (\v!figure) >\startplacefigure is a combination of the elements "start" (\e!start) >and "place" (\e!place) and the variable "figure" (\v!figure.) So, I'm still doing something wrong, because changing the translation of "figure" in "mult-def.lua" (in the part "variables"), only affect : 1- command "\startfigure \stopfigure" 2- "figure" in "\setuppageinjection" > alternative = figure buffer... You have to provide your modified mult-def.lua file, otherwise there is no way to check what's wrong. I get another difficulty with \startitemize and \stopitemize the translation of the variable "itemize" has no impact on the setup-fr.pdf file produced with : context --interface=fr --global --result=setup-fr x-setups-overview.mkiv But, I just found that if I actually use the translated commands in a test.tex file, it just works. % interface=fr \debuttexte \debutlister \elem first \elem second \finlister \fintexte What should I do in order to have a setup-fr.pdf file that shows the translations actually available ? Same as above, provide your translations. With the translation of the command textwidth, I can use "largeur=0.5\largeurtexte" (cool !) But this command is not listed in setup-fr.pdf. Is there a way to add these basic commands to setup-fr.pdf ? \textwidth is the name of a dimen register and no register names are listed. Math. I get the following error : fonts > preloading latin modern fonts (second stage) fonts > defining > font with asked name 'fichier' is not found using lookup 'file' fonts > defining > unknown font 'fichier', loading aborted I suppose that due to the translation of "file" to "fichier". It's OK when I switch back to - setupstrings cd:file ==> file You can translate these string because they are only used in the command list to provide the texts which are shown in uppercase letter, e.g. NUMBER. - variables file ==> file Constants (\c!...) and variables (\v!...) can be changed, only parameters which use the form \s!... have to be english in all cases (saves memory and improves performance). How can I translate the variable "file" into fichier, without messing with fonts (and maybe other file related functions) There shouldn't be a problem with fonts because they use \s!file or \s!name which aren't translated (unless you made the mistake and have \c!file in your typescripts). It's possible there is a bug somewhere but you have to provide a minimal example. 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] Which lua XML library is embedded in LMTX?
Hi, > On 25 Jun 2020, at 12:37, Gerben Wierda wrote: > > According to the XML manual: > > << 2.1 >> TEX versus LUA > > It will not come as a surprise that we can access xml files from TEX as well > as from Lua. In fact there are two methods to deal with xml in Lua. First > there are the low level xml functions in the xml namespace. On top of those > functions there is a set of functions in the lxml namespace that deals with > xml in a more TEXie way. > > << 3.7 >> manipulation > > Having read that, I was loooking for the documentation of the commands that > are available in the xml namespace. I want to manipulate a XML tree in LMTX > lua. But looking online gives me all kinds of different XML-solutions that > are proposed for lua. Which one is embedded in LMTX and available in the xml > namespace? But then I get confused because other elements like xml.first, > xml.collected are in the xml namespace and mentioned. None of the prefab solutions are used. The XML parser in ConTeXt is hand-written by Hans. Most (all?) of the TeX macros like \xmlfirst are in fact thin wrappers around lua code, see https://source.contextgarden.net/tex/context/base/mkiv/lxml-ini.lua However, these are currently not documented. Hans wrote the xml-mkiv manual with TeX users in mind, so there is very little documentation on the Lua side of things. I have plans myself to write that ‘missing chapter’ but there are a lot of other things on my list of todos as well. > What I need (in LMTX lua) to add (sub)nodes to the XML node (that I read with > xml.first()) because the data I get is broken and I need to fix it before I > can use it (and I cannot get good data) The easiest way is to add the correct > data to the XML and then use it in my code. If I cannot do that I need to > write parallel code that largely does the same as what I already have (ugh).. Regardless of whether it is doable in principle, this is not the intended use of the xml processing in ConTeXT. ConTeXt XML support is for Formatting, not Transformation. If you need to actually change the XML structure, I strongly advice to find a solution elsewhere. ConTeXt not only does formatting, but it tries to do this as efficiently and fast as possible. That means that if you want to modify a parsed tree, you will almost certainly also have to fix up external indices into that tree and you probably will have to write the lua mutation functions yourself as well. So, better look at some binding for libxml2 to some language you like, and then transform the XML beforehand into something you can confidently use as source for typesetting. Again: ConTeXt XML support is not meant for XML Transformations. (my two cents, at least) 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] Translation of ConTeXt interface
Thanks a lot Wolfang for your answer. I have 5 additional questions... sorry. --- >> \placeFLOAT becomes \placerFLOAT >> \startplaceFLOAT becomes \debutplacerFLOAT >> \placerchemical becomes \placerchemical >> \startplacerchemical becomes \debutplacerchemical >\placefigure is a combination of the element "place" (\e!place) and the > variable "figure" (\v!figure) >\startplacefigure is a combination of the elements "start" (\e!start) >and "place" (\e!place) and the variable "figure" (\v!figure.) So, I'm still doing something wrong, because changing the translation of "figure" in "mult-def.lua" (in the part "variables"), only affect : 1- command "\startfigure\stopfigure" 2- "figure" in "\setuppageinjection" > alternative = figure buffer... --- I get another difficulty with \startitemize and \stopitemize the translation of the variable "itemize" has no impact on the setup-fr.pdf file produced with : context --interface=fr --global --result=setup-fr x-setups-overview.mkiv But, I just found that if I actually use the translated commands in a test.tex file, it just works. % interface=fr \debuttexte \debutlister \elem first \elem second \finlister \fintexte What should I do in order to have a setup-fr.pdf file that shows the translations actually available ? --- With the translation of the command textwidth, I can use "largeur=0.5\largeurtexte" (cool !) But this command is not listed in setup-fr.pdf. Is there a way to add these basic commands to setup-fr.pdf ? --- Math. I get the following error : fonts > preloading latin modern fonts (second stage) fonts > defining > font with asked name 'fichier' is not found using lookup 'file' fonts > defining > unknown font 'fichier', loading aborted I suppose that due to the translation of "file" to "fichier". It's OK when I switch back to - setupstrings cd:file ==> file - variables file==> file How can I translate the variable "file" into fichier, without messing with fonts (and maybe other file related functions) --- > Delimited command are problematic (especially when they change > catcodes), e.g. \startluacode use \stopluacode as hard coded delimiter > for the environment. While it is easy to create a synonym for > \startluacode this isn't the case for \stopluacode because the > environment always look for \stopluacode as stopper and alternative > names are ignored. \startsection \stopsection and \startformula \stopformula seem OK. How can I identify the delimited commands that should not be translated in order to avoid this issue. --- Thanks again ___ 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] Macros which scan subscripts/superscripts in ConTeXt
On 6/26/2020 3:47 AM, Aditya Mahajan wrote: On Thu, 25 Jun 2020, Jairo A. del Rio wrote: Hi, list! I've seen the following in Stack Exchange: https://tex.stackexchange.com/questions/503208/define-macro-that-scans-ahead-for-super-and-or-subscript-absorbs-them-and-mo The answer is: \documentclass{article}\usepackage{amsmath}\usepackage{xparse} \NewDocumentCommand{\mymathsym}{e{^_}}{% x^{\mathrm{foo}\IfValueT{#1}{,#1}}_{\mathrm{bar}\IfValueT{#2}{,#2}}%} \begin{document} \begin{gather}\mymathsym \\\mymathsym^{\mathrm{extrasup}} \\\mymathsym_{\mathrm{extrasub}} \\\mymathsym^{\mathrm{extrasup}}_{\mathrm{extrasub}} \\\mymathsym_{\mathrm{extrasub}}^{\mathrm{extrasup}} \end{gather} \end{document} Such a macro contextually defines a behavior for a subscript and a superscript even if they aren't displayed in a specific order, so \mymacro_{a}^{b} \mymacro^{b}_{a} have the same output, even if the intended behavior is not the typical one (I could redefine it so subscripts change colors, for instance). Although I could just port the macro using xparse-generic because it works in ConTeXt too, how to define a macro like that the ConTeXt way, i.e., using only ConTeXt macros? Return of the dodo :-) % Must be outside \unprotect .. \protect so that _ has usual catcodes \def\capturemathoplimits#1% {\doifnextcharelse _% {\docapturemathoplimitsA{#1}} {\doifnextcharelse ^% {\docapturemathoplimitsB{#1}} {\redocapturemathoplimits{#1 \def\docapturemathoplimitsA#1#2#3% {\doifnextcharelse ^% {\dodocapturemathoplimitsA{#1}{#2}{#3}} {\dodocapturemathoplimitsA{#1}{#2}{#3}\empty\empty}} \def\dodocapturemathoplimitsA#1#2#3#4#5{#1{#5}{#3}} \def\docapturemathoplimitsB#1#2#3% {\doifnextcharelse _% {\dodocapturemathoplimitsB{#1}{#2}{#3}} {\dodocapturemathoplimitsB{#1}{#2}{#3}\empty\empty}} \def\dodocapturemathoplimitsB#1#2#3#4#5{#1{#3}{#5}} \def\redocapturemathoplimits#1{#1\empty\empty\empty\empty\empty} % Usage: \define\mymacro{\capturemathoplimits\domymacro} \def\domymacro#1#2% % #1 is supscript, #2 is subscript {x^{\mathrm{foo}\doifsomething{#1}{,#1}}_{\mathrm{bar}\doifsomething{#2}{,#2}}} \starttext \startlines $\mymacro$ $\mymacro^{\mathrm{extrasup}}$ $\mymacro_{\mathrm{extrasub}}$ $\mymacro^{\mathrm{extrasup}}_{\mathrm{extrasub}}$ $\mymacro_{\mathrm{extrasub}}^{\mathrm{extrasup}}$ \stoplines \stoptext We could have this: \unexpanded\def\scripts {\scratchtoksone\emptytoks \scratchtokstwo\emptytoks \doscriptscheck} \def\doscriptscheck {\doifnextcharelse _% \doscriptssub {\doifnextcharelse ^% \doscriptssup \doscriptsflush}} \def\doscriptsflush {\doifsometoks\scratchtoksone{^{\the\scratchtoksone}}% \doifsometoks\scratchtokstwo{_{\the\scratchtokstwo}}} \def\doscriptssup ^#1% {\doifelsesometoks\scratchtoksone {\appendtoks,{#1}\to\scratchtoksone} {\scratchtoksone{{#1}}}% \doscriptscheck} \def\doscriptssub _#1% {\doifelsesometoks\scratchtokstwo {\appendtoks,{#1}\to\scratchtokstwo} {\scratchtokstwo{{#1}}}% \doscriptscheck} % % a bit more low level: % \unexpanded\def\scripts % {\scratchtoksone\emptytoks %\scratchtokstwo\emptytoks %\doscriptscheck} % % \def\doscriptscheck % {\doifnextcharelse ^% % {\doscriptsstep\scratchtoksone} % {\doifnextcharelse _% % {\doscriptsstep\scratchtokstwo} % {\doscriptsflush}}} % % \def\doscriptsflush % {\iftok\scratchtoksone\emptytoks\else\Usuperscript{\the\scratchtoksone}\fi% %\iftok\scratchtokstwo\emptytoks\else\Usubscript {\the\scratchtokstwo}\fi} % % \def\doscriptsstep#1#1#3% % {\etoksapp#1{\iftok#1\emptytoks\else,\fi\normalunexpanded{#3}}% %\doscriptscheck} \starttext \startlines $z\scripts _{\rm one} _{\bf two} ^{one} _{ three} ^{\bi two}$ \stoplines \stoptext - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] error running wiki example with labels
> On 25 Jun 2020, at 17:54, Jan-Erik Hägglöf wrote: > > It is difficult to see the differences in this case, but I supply both > logfiles > > The two PATHs are not the same, so it is possible that one of the two uses a different mtxrun, context and/or luatex that is elsewhere in the PATH: test-by-shell-context.log:ENV > PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/janneman/context-osx-64/bin:/Users/janneman/context-osx-64/tex/texmf-osx-64/bin:/Users/janneman/scripts test-inside-with-mtxrun.log:ENV > PATH=/Users/janneman/context-osx-64/tex/texmf-osx-64/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/janneman/context-osx-64/bin:/Users/janneman/context-osx-64/tex/texmf-osx-64/bin:/Users/janneman/scripts but other than that, nothing stands out to me in that log. An interesting experiment would be to run the macvim-generated commandline (for the file with the error) in Terminal, and then that same commandline but with the PATH set as in macvim. > Now I also upgraded lmtx to latest version. But still having problems? 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 ___