Re: [NTG-context] Lua code and table
> On 17 Feb 2021, at 17:40, Fabrice Couvreur > wrote: > > Hi, The code works, but is it possible to make it shorter ? > Thank you > Fabrice > You can reduce the size of the test by storing the pattern in a table: \startluacode local background_one = { align = "middle", style = "type", background = "DiagonalRule", } local letters_1 = { "A", "B", "C", "D", "E", "F", "G", "H" } local pattern_1 = { ".XXX..XX", "X...XXX.", "X..X.XXX", "X.X.X..X", ".X.X.XX.", ".XX.X...", "XXX.X...", "X.XX" } context.startxtable({"align={middle,lohi}, width=0.8cm,offset=0.8ex,bodyfont=9pt,framecolor=cyan"}) context.startxrow() context.startxcell({"frame=off"}) context() context.stopxcell() for _, letter in ipairs(letters_1) do context.startxcell() context(letter) context.stopxcell() end context.stopxrow() for i, letter in ipairs(letters_1) do context.startxrow() context.startxcell() context(letter) context.stopxcell() for j = 1, 8 do context.startxcell( string.sub(pattern_1[i],j,j) == "X" and background_one ) context() context.stopxcell() end context.stopxrow() end context.stopxtable() \stopluacode — Bruce Horrocks Hampshire, UK ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] MKIV format generation error with latest 2021-02-17 13:33
On 2/17/2021 7:23 PM, Adam Reviczky wrote: Hi, I am getting the following error with luatex/mkiv with today's latest: hm, looks like some split / file mixup .. i'll upload a new zip tomorrow 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] Lua code and table
On 2/17/2021 10:26 PM, Wolfgang Schuster wrote: Fabrice Couvreur schrieb am 17.02.2021 um 18:40: Hi,The code works, but is it possible to make it shorter ? Thank you Fabrice \startuseMPgraphic{DiagonalRule} rulethickness := \frameddimension{rulethickness}; drawoptions( withpen pencircle scaled rulethickness withcolor \MPcolor{\framedparameter{framecolor}}); pair leftcorner, rightcorner, Leftcorner, Rightcorner; leftcorner := (rulethickness, \overlayheight-rulethickness); rightcorner := (\overlaywidth-rulethickness, rulethickness); Leftcorner := ( rulethickness, rulethickness); Rightcorner := (\overlaywidth-rulethickness,\overlayheight-rulethickness); draw leftcorner -- rightcorner; draw Leftcorner -- Rightcorner; \stopuseMPgraphic \startuseMPgraphic{DiagonalRule} drawoptions( withpen pencircle scaled OverlayLineWidth withcolor OverlayLineColor ); draw ulcorner OverlayBox -- lrcorner OverlayBox ; draw llcorner OverlayBox -- urcorner OverlayBox ; \stopuseMPgraphic Often this also works: \startuseMPgraphic{DiagonalRule} draw image ( draw ulcorner OverlayBox -- lrcorner OverlayBox ; draw llcorner OverlayBox -- urcorner OverlayBox ; ) withpen pencircle scaled OverlayLineWidth withcolor OverlayLineColor ; \stopuseMPgraphic - 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] Lua code and table
Fabrice Couvreur schrieb am 17.02.2021 um 18:40: Hi,The code works, but is it possible to make it shorter ? Thank you Fabrice \startuseMPgraphic{DiagonalRule} rulethickness := \frameddimension{rulethickness}; drawoptions( withpen pencircle scaled rulethickness withcolor \MPcolor{\framedparameter{framecolor}}); pair leftcorner, rightcorner, Leftcorner, Rightcorner; leftcorner := (rulethickness, \overlayheight-rulethickness); rightcorner := (\overlaywidth-rulethickness, rulethickness); Leftcorner := ( rulethickness, rulethickness); Rightcorner := (\overlaywidth-rulethickness,\overlayheight-rulethickness); draw leftcorner -- rightcorner; draw Leftcorner -- Rightcorner; \stopuseMPgraphic \startuseMPgraphic{DiagonalRule} drawoptions( withpen pencircle scaled OverlayLineWidth withcolor OverlayLineColor ); draw ulcorner OverlayBox -- lrcorner OverlayBox ; draw llcorner OverlayBox -- urcorner OverlayBox ; \stopuseMPgraphic 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] Lua code and table
Hi Fabrice, see below, I attached two ideas how to do it. The best, Tomáš Wed, Feb 17, 2021 ve 06:40:54PM +0100 Fabrice Couvreur napsal(a): #Hi, The code works, but is it possible to make it shorter ? #Thank you #Fabrice #\startuseMPgraphic{DiagonalRule} # rulethickness := \frameddimension{rulethickness}; # # drawoptions( # withpen pencircle scaled rulethickness # withcolor \MPcolor{\framedparameter{framecolor}}); # # pair leftcorner, rightcorner, Leftcorner, Rightcorner; # leftcorner := (rulethickness, \overlayheight-rulethickness); # rightcorner := (\overlaywidth-rulethickness, rulethickness); # Leftcorner := ( rulethickness, rulethickness); # Rightcorner := #(\overlaywidth-rulethickness,\overlayheight-rulethickness); # # draw leftcorner -- rightcorner; # draw Leftcorner -- Rightcorner; # \stopuseMPgraphic # #\defineoverlay # [DiagonalRule] # [\useMPgraphic{DiagonalRule}] # #\define[2]\DiagonalLabel{% # \setuptabulate [after={\blank[\frameddimension{offset}]}] # \starttabulate [|p|r|] # \NC \NC \bf #2 \NC\NR # \NC \bf #1 \NC \NC\NR # \stoptabulate #} #\starttext #\startluacode # local background_one = { # align = "middle", # style = "type", # background = "DiagonalRule", # } # # local letters_1 = { "A", "B", "C", "D", "E", "F", "G", "H" } # context.startxtable({"align={middle,lohi}, #width=0.8cm,offset=0.8ex,bodyfont=9pt,framecolor=cyan"}) # context.startxrow() # context.startxcell({"frame=off"}) # context() # context.stopxcell() # for _, letter in ipairs(letters_1) do # context.startxcell() # context(letter) context.stopxcell() # end # context.stopxrow() # for _, letter in ipairs(letters_1) do # context.startxrow() # context.startxcell() # context(letter) # context.stopxcell() # for j = 0, 7 do # context.startxcell( j == 0 and letter == "B" and background_one # or j == 0 and letter == "C" and background_one # or j == 0 and letter == "D" and background_one # or j == 0 and letter == "G" and background_one # or j == 0 and letter == "H" and background_one # or j == 1 and letter == "A" and background_one # or j == 1 and letter == "E" and background_one # or j == 1 and letter == "F" and background_one # or j == 1 and letter == "G" and background_one # or j == 2 and letter == "A" and background_one # or j == 2 and letter == "D" and background_one # or j == 2 and letter == "F" and background_one # or j == 2 and letter == "G" and background_one # or j == 2 and letter == "H" and background_one # or j == 3 and letter == "A" and background_one # or j == 3 and letter == "C" and background_one # or j == 3 and letter == "E" and background_one # or j == 3 and letter == "H" and background_one # or j == 4 and letter == "B" and background_one # or j == 4 and letter == "D" and background_one # or j == 4 and letter == "F" and background_one # or j == 4 and letter == "G" and background_one # or j == 5 and letter == "B" and background_one # or j == 5 and letter == "C" and background_one # or j == 5 and letter == "E" and background_one # or j == 6 and letter == "A" and background_one # or j == 6 and letter == "B" and background_one # or j == 6 and letter == "C" and background_one # or j == 6 and letter == "E" and background_one # or j == 7 and letter == "A" and background_one # or j == 7 and letter == "C" and background_one # or j == 7 and letter == "D" and background_one # ) # context() # context.stopxcell() # end # context.stopxrow() # end # context.stopxtable() #\stopluacode #\stoptext %%%= \starttext \startluacode function test() for x=0,7 do for y=65,72 do local yy=string.char(y) context(x) context(" "..yy) context(f1(x,yy)..f2(x,yy)..f3(x,yy)) context.par() end end end local background_one = true function f1 (j,letter) local res= j == 0 and letter == "B" and background_one or j == 0 and letter == "C" and background_one or j == 0 and letter == "D" and background_one or j == 0 and letter == "G" and background_one or j == 0 and letter == "H" and background_one or j == 1 and letter == "A" and background_one or j == 1 and letter == "E" and background_one or j == 1 and letter == "F" and background_one or j == 1 and letter == "G" and background_one or j == 2 and letter == "A" and background_one or j == 2 and letter == "D" and background_one or j == 2 and letter == "F" and background_one or j == 2 and letter == "G" and background_one or j == 2 and letter == "H" and backgro
[NTG-context] MKIV format generation error with latest 2021-02-17 13:33
Hi, I am getting the following error with luatex/mkiv with today's latest: context --make loading : ConTeXt Token Support / Initialization /usr/share/texmf/tex/context/base/mkxl/toks-ini.lmt:21: attempt to call a nil value (field 'getcommandvalues') stack traceback: /usr/share/texmf/tex/context/base/mkxl/toks-ini.lmt:21: in local 'code' /usr/share/texmf/tex/context/base/mkiv/util-lua.lua:96: in field 'loadedluacode' /usr/share/texmf/tex/context/base/mkiv/luat-env.lua:108: in field 'luafilechunk' /usr/share/texmf/tex/context/base/mkiv/luat-cod.lua:75: in function 'lua.registercode' [\directlua]:1: in main chunk. \registerctxluafile #1#2->\ctxlua {lua.registercode("#1","#2")} l.18 \registerctxluafile{toks-ini}{autosuffix} ? --- mtx-context | ConTeXt Process Management 1.04 mtx-context | mtx-context | main context file: /usr/share/texmf/tex/context/base/mkiv/context.mkiv mtx-context | current version: 2021.02.17 13:30 mtx-context | main context file: /usr/share/texmf/tex/context/base/mkxl/context.mkxl mtx-context | current version: 2021.02.17 13:30 --- Compiled with libpng 1.6.37; using 1.6.37 Compiled with lua version 5.3.6 Compiled with mplib version 2.00 Compiled with zlib 1.2.11; using 1.2.11 Development id: 7405 --- Adam ___ 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] Lua code and table
Hi, The code works, but is it possible to make it shorter ? Thank you Fabrice \startuseMPgraphic{DiagonalRule} rulethickness := \frameddimension{rulethickness}; drawoptions( withpen pencircle scaled rulethickness withcolor \MPcolor{\framedparameter{framecolor}}); pair leftcorner, rightcorner, Leftcorner, Rightcorner; leftcorner := (rulethickness, \overlayheight-rulethickness); rightcorner := (\overlaywidth-rulethickness, rulethickness); Leftcorner := ( rulethickness, rulethickness); Rightcorner := (\overlaywidth-rulethickness,\overlayheight-rulethickness); draw leftcorner -- rightcorner; draw Leftcorner -- Rightcorner; \stopuseMPgraphic \defineoverlay [DiagonalRule] [\useMPgraphic{DiagonalRule}] \define[2]\DiagonalLabel{% \setuptabulate [after={\blank[\frameddimension{offset}]}] \starttabulate [|p|r|] \NC\NC \bf #2 \NC\NR \NC \bf #1 \NC\NC\NR \stoptabulate } \starttext \startluacode local background_one = { align = "middle", style = "type", background = "DiagonalRule", } local letters_1 = { "A", "B", "C", "D", "E", "F", "G", "H" } context.startxtable({"align={middle,lohi}, width=0.8cm,offset=0.8ex,bodyfont=9pt,framecolor=cyan"}) context.startxrow() context.startxcell({"frame=off"}) context() context.stopxcell() for _, letter in ipairs(letters_1) do context.startxcell() context(letter) context.stopxcell() end context.stopxrow() for _, letter in ipairs(letters_1) do context.startxrow() context.startxcell() context(letter) context.stopxcell() for j = 0, 7 do context.startxcell( j == 0 and letter == "B" and background_one or j == 0 and letter == "C" and background_one or j == 0 and letter == "D" and background_one or j == 0 and letter == "G" and background_one or j == 0 and letter == "H" and background_one or j == 1 and letter == "A" and background_one or j == 1 and letter == "E" and background_one or j == 1 and letter == "F" and background_one or j == 1 and letter == "G" and background_one or j == 2 and letter == "A" and background_one or j == 2 and letter == "D" and background_one or j == 2 and letter == "F" and background_one or j == 2 and letter == "G" and background_one or j == 2 and letter == "H" and background_one or j == 3 and letter == "A" and background_one or j == 3 and letter == "C" and background_one or j == 3 and letter == "E" and background_one or j == 3 and letter == "H" and background_one or j == 4 and letter == "B" and background_one or j == 4 and letter == "D" and background_one or j == 4 and letter == "F" and background_one or j == 4 and letter == "G" and background_one or j == 5 and letter == "B" and background_one or j == 5 and letter == "C" and background_one or j == 5 and letter == "E" and background_one or j == 6 and letter == "A" and background_one or j == 6 and letter == "B" and background_one or j == 6 and letter == "C" and background_one or j == 6 and letter == "E" and background_one or j == 7 and letter == "A" and background_one or j == 7 and letter == "C" and background_one or j == 7 and letter == "D" and background_one ) context() context.stopxcell() end context.stopxrow() end context.stopxtable() \stopluacode \stoptext ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] Are positional graphics still working?
It works fine now. Thank you a lot for the fix. Cordially, Jairo :) El mié, 17 de feb. de 2021 a la(s) 06:09, Hans Hagen (j.ha...@xs4all.nl) escribió: > On 2/17/2021 12:18 AM, Jairo A. del Rio wrote: > > I've copied the following example from the ConTeXt archive: > > > > \defineoverlay[frames][\positionoverlay{frames}] > > > > \setupbackgrounds[text][background=frames] > > > > > > \startMPpositiongraphic{frame} > > > > if unknown context_apos : input mp-apos.mpiv ; fi ; > > > > \MPgetposboxes{\MPvar{self}}{\MPanchorid} > > > > if nofposboxes = 1 : > > > > draw posboxes[1] ; > > > > fi ; > > > > \stopMPpositiongraphic > > > > > > \startpositionoverlay{frames} > > > > \setMPpositiongraphic{one}{frame} > > > > \setMPpositiongraphic{two}{frame} > > > > \stoppositionoverlay > > > > > > \starttext > > > > This \hpos{one}{word} should be \hpos{two}{framed}. > > > > \stoptext > > > > Frames are misplaced, so I don't know if that's a bug or something else > > has been updated/changed/deprecated. Thank you in advance. > As a step-up to further integrated (more lmtx-ish) support for this the > next upload will have this: > > \defineoverlay[frames][\positionoverlay{frames}] > > \setupbackgrounds[text][background=frames] > > \startMPpositiongraphic{frame} > getposboxes("self","anchor") ; > if nofposboxes = 1 : > draw posboxes[1] ; > fi ; > \stopMPpositiongraphic > > \startpositionoverlay{frames} > \setMPpositiongraphic{one}{frame} > \setMPpositiongraphic{two}{frame} > \stoppositionoverlay > > \starttext > This \hpos{one}{\strut word} should \hpos{two}{\strut also be framed}. > \stoptext > > Hans > > > - >Hans Hagen | PRAGMA ADE >Ridderstraat 27 | 8061 GH Hasselt | The Netherlands > tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl > - > ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] Are positional graphics still working?
On 2/17/2021 12:18 AM, Jairo A. del Rio wrote: I've copied the following example from the ConTeXt archive: \defineoverlay[frames][\positionoverlay{frames}] \setupbackgrounds[text][background=frames] \startMPpositiongraphic{frame} if unknown context_apos : input mp-apos.mpiv ; fi ; \MPgetposboxes{\MPvar{self}}{\MPanchorid} if nofposboxes = 1 : draw posboxes[1] ; fi ; \stopMPpositiongraphic \startpositionoverlay{frames} \setMPpositiongraphic{one}{frame} \setMPpositiongraphic{two}{frame} \stoppositionoverlay \starttext This \hpos{one}{word} should be \hpos{two}{framed}. \stoptext Frames are misplaced, so I don't know if that's a bug or something else has been updated/changed/deprecated. Thank you in advance. As a step-up to further integrated (more lmtx-ish) support for this the next upload will have this: \defineoverlay[frames][\positionoverlay{frames}] \setupbackgrounds[text][background=frames] \startMPpositiongraphic{frame} getposboxes("self","anchor") ; if nofposboxes = 1 : draw posboxes[1] ; fi ; \stopMPpositiongraphic \startpositionoverlay{frames} \setMPpositiongraphic{one}{frame} \setMPpositiongraphic{two}{frame} \stoppositionoverlay \starttext This \hpos{one}{\strut word} should \hpos{two}{\strut also be framed}. \stoptext Hans - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] infinite number of runs
On 2/17/2021 10:07 AM, Pablo Rodriguez wrote: Hans, I have some documents that trigger infinite runs. I want to provide a minimal sample that shows this. But is there some code in the .tuc file (or in the .log file with \tracingall) that shows the need of another run? you can try --keeptuc and then see where the successive tuc files differ which might give a clue - 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] infinite number of runs
Hans, I have some documents that trigger infinite runs. I want to provide a minimal sample that shows this. But is there some code in the .tuc file (or in the .log file with \tracingall) that shows the need of another run? 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] Are positional graphics still working?
On 2/17/2021 12:18 AM, Jairo A. del Rio wrote: I've copied the following example from the ConTeXt archive: there is a comment in the code -- todo: anchor, page so i'll look into it (not hard to fix) in lmtx i want to add some more natural helpers to the interface; part of also updating the metafun manual (but first i need to do the periodical update of the luametatex manual - kind of boring an dless fun than metafun) - 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 ___