[NTG-context] notes by paragraph
Re my earlier question on footnotes by defined paragraph: \start...stoplocalfootnotes and \placelocalfootnotes largely solves the issue (had forgotten that option), but I am still getting the footnotes repeated at the bottom of the page. I am obviously missing a setting. There are parts of this text that do require the usual footnotes at the bottom, so I would not want to turn off this option permanently. I have tried \setupnotation[footnote][display=no] but that is not working. Julian ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
[NTG-context] footnotes by paragraph?
Here's a tricky one (for me) that I haven't been able to work out. I am dealing with a set of constitutions that I am organizing with a paragraph definition \defineparagraphs[Two][n=2] \setupparagraphs[Two][1][width=.2\textwidth,style=\bfx,after={\blank},align=flushleft] \setupparagraphs[Two][2][width=.77\textwidth,style=normal,after={\blank}] But I need to get the footnotes (which all apply to [2] in each article of the constitutions) to come beneath my defined 'Two'. I do not want them to come at the bottom of the page. I thought I might be able to do it by placing \start...stopTwo within a \start...stopsection and defining \setupnotation[way=bysection] but that is not working. Any thought on how I could approach this? Julian ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
[NTG-context] Subject: Leading spaces verbatim
Good day to everyone, I'm trying to make a verbatim block of text with copiable leading spaces so that students can just copy my Python code snippets into their IDE. I believe the question has been asked before (though I confess I can't find the right search terms to find the answer again). I get that PDFs are not the optimal way to give code to students (which is why for longer snippets, I just give them the files or I attach them into the PDF), but for short snippets it would be so much simpler... I recently stumbled onto this article: https://www.overleaf.com/latex/examples/using-luatex-to-convert-interword-glue-to-spaces-and-kerns/sfdkdkybrvkv wherein the author replaces the TeX glue with spaces and kerning. I was wondering whether the same idea could be applied within the typing environment but making a primitive verbatim environment using \obeylines and \obeyspaces did not result in copiable spaces. Unfortunately, whilst I have some concepts of how luatex works on the input file, the step wherein a pdf is formed is fairly misterious to me, meaning I can't really understand the Lua code from said article (https://gist.github.com/Semptum/076cca71bc251ebe19ff96c5effca3cb). Hence, my three questions: - Is it even realistic to make such a typing environment? - What would be the best path to do so? - Can someone recommend some reading material specifically about this kind of typographical adjustments using LuaTex? Stuff like adjusting the glyphs's position, replacing characters with combined characters etc... Sorry if that's a bit vague, as you can see from the rest of the message, I never really went too deep into the later stages of the TeX pipeline. Best regards, Andre___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] autospacing and colonequals (was Lucida-1.901 (2023-01-21) available)
On 1/27/2023 6:58 PM, Aditya Mahajan via ntg-context wrote: On Fri, 27 Jan 2023, Hans Hagen via ntg-context wrote: On 1/27/2023 6:26 PM, Otared Kavian via ntg-context wrote: Hi Hans, Thank you for the hint: indeed \setupmathematics[collapsing=2] does exactly what I was looking for… Now, like many others, I am just waiting for the 3145 pages document about maths in ConTeXt :-) It will be 3147 because we need to demo No, it has to be 31415 pages now (so that the number of pages eventually converges to pi)! ah, but then we need a volunteer for those thousands of samples (of show each one in 15 math fonts to get to that number of pages) (a run would take some 5-10 minutes depending on the complexity) 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 / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] autospacing and colonequals (was Lucida-1.901 (2023-01-21) available)
On Fri, 27 Jan 2023, Hans Hagen via ntg-context wrote: > On 1/27/2023 6:26 PM, Otared Kavian via ntg-context wrote: > > Hi Hans, > > > > Thank you for the hint: indeed > > \setupmathematics[collapsing=2] > > does exactly what I was looking for… > > > > Now, like many others, I am just waiting for the 3145 pages document about > > maths in ConTeXt :-) > It will be 3147 because we need to demo No, it has to be 31415 pages now (so that the number of pages eventually converges to pi)! Aditya___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] autospacing and colonequals (was Lucida-1.901 (2023-01-21) available)
On 1/27/2023 6:26 PM, Otared Kavian via ntg-context wrote: Hi Hans, Thank you for the hint: indeed \setupmathematics[collapsing=2] does exactly what I was looking for… Now, like many others, I am just waiting for the 3145 pages document about maths in ConTeXt :-) It will be 3147 because we need to demo \setupmathematics[hz=yes] 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 / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] autospacing and colonequals (was Lucida-1.901 (2023-01-21) available)
Hi Hans, Thank you for the hint: indeed \setupmathematics[collapsing=2] does exactly what I was looking for… Now, like many others, I am just waiting for the 3145 pages document about maths in ConTeXt :-) Best regards: Otared > On 26 Jan 2023, at 23:23, Hans Hagen via ntg-context > wrote: > > On 1/26/2023 10:52 PM, Otared Kavian via ntg-context wrote: > >> Indeed the command \colonequals give the precise expected alignment for the >> combination glyph « := ». Befors changing the combination « := » to >> \columnequals in my documents, I am wondering whether one could add a small >> lua code in order to make an automatic replacement at run time. Actually, >> since I don’t know of any other instance in which the combination « := » is >> used to mean something else, would it not be reasonnable to make « := » >> synonym to \colonequals? > > that's what the (has-always-been-there) > > \setupmathematics[collapsing=2] > > is for (needs latest version to work when the space trickery i senabled) > > 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 / > https://www.ntg.nl/mailman/listinfo/ntg-context > webpage : https://www.pragma-ade.nl / http://context.aanhet.net > archive : https://bitbucket.org/phg/context-mirror/commits/ > wiki : https://contextgarden.net > ___ Otared Kavian e-mail: ota...@gmail.com Phone: +33 6 88 26 70 95 ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] protected macro vs protected luacall
On 1/27/2023 12:03 PM, Henri Menke via ntg-context wrote: How much do you think would break if protected luacall were treated like protected macros after \the in the engine? That kind of incompatibility is no option (I'm not going to analyze it for mkiv let along other macro package usage which is out of my scope). That would probably need an extra branch in the switch(cur_cmd) in scan_something_internal. Currently protected luacall just goes to the default branch (You can't use ...). For various reasons luatex got frozen around version 1 and demand for stability (which also excluded experiments) is one of them. So, one has to work with what one gets (not much different from the rest of tex functionality). With careful coding the performance hit is not that large and machines still get a bit get faster so that compensates it anyway. Although some low level approaches can bring benefits it's never homogenious and largely depends on use cases. 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 / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] protected macro vs protected luacall
On Fri, 2023-01-27 at 11:01 +0100, Hans Hagen via ntg-context wrote: > On 1/27/2023 10:35 AM, Henri Menke via ntg-context wrote: > > > Thanks, this is indeed the workaround that I currently use. > > However, > > the downside is that this has to tokenize the contents of > > \directlua > > every time (and is therefore susceptible to surrounding \catcode > > shenanigans) and it expands in at minimum two steps, whereas a > > luacall > > always expands in a single step. But I guess that's what I will > > have to > > live with. > on my 2018 laptop, with > >function FoO() end > > this > >\directlua{FoO()}} > > takes 0.014 seconds so probably the least of your worries > compared > to other macro and lua magic True, but then there is still the problem with the number of expansions. With a nested \directlua I always need at least two steps to get the result from Lua. \directlua{ function TestCmd() tex.print("\string\\numexpr 17\string\\relax") end lua.get_functions_table()[999] = TestCmd } \let\:\expandafter % I'm lazy \tt \directlua{token.set_lua("test", 999)} \:\def\:\x\:{\test}\meaning\x % macro:->\numexpr 17\relax \protected\def\test{\directlua{TestCmd()}} \:\def\:\x\:{\test}\meaning\x\par % macro:->\directlua {TestCmd()} \:\:\:\def\:\:\:\x\:\:\:{\test}\meaning\x % macro:->\numexpr 17\relax \bye How much do you think would break if protected luacall were treated like protected macros after \the in the engine? That would probably need an extra branch in the switch(cur_cmd) in scan_something_internal. Currently protected luacall just goes to the default branch (You can't use ...). Cheers, Henri > > 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 / > https://www.ntg.nl/mailman/listinfo/ntg-context > webpage : https://www.pragma-ade.nl / http://context.aanhet.net > archive : https://bitbucket.org/phg/context-mirror/commits/ > wiki : https://contextgarden.net > _ > __ ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] protected macro vs protected luacall
On 1/27/2023 10:35 AM, Henri Menke via ntg-context wrote: Thanks, this is indeed the workaround that I currently use. However, the downside is that this has to tokenize the contents of \directlua every time (and is therefore susceptible to surrounding \catcode shenanigans) and it expands in at minimum two steps, whereas a luacall always expands in a single step. But I guess that's what I will have to live with. on my 2018 laptop, with function FoO() end this \directlua{FoO()}} takes 0.014 seconds so probably the least of your worries compared to other macro and lua magic 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 / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] protected macro vs protected luacall
On Fri, 2023-01-27 at 10:30 +0100, Hans Hagen via ntg-context wrote: > On 1/27/2023 10:13 AM, Henri Menke via ntg-context wrote: > > On Thu, 2023-01-26 at 23:07 +0100, Hans Hagen via ntg-context > > wrote: > > > On 1/26/2023 9:33 PM, Henri Menke via ntg-context wrote: > > > > \directlua{ > > > > userdata = userdata or {} > > > > function userdata.test() > > > > tex.print("\string\\numexpr 17\string\\relax") > > > > end > > > > } > > > > > > > > \tt > > > > \protected\def\test{\directlua{userdata.test()}} > > > > \meaning\test\par > > > > \edef\x{\test}\meaning\x\par > > > > \the\test > > > > > > > > \directlua{ > > > > local t = lua.get_functions_table() > > > > t[\string#t + 1] = userdata.test > > > > token.set_lua("test", userdata.test, \string#t, > > > > "protected") > > > > } > > > > \meaning\test\par > > > > \edef\x{\test}\meaning\x\par > > > > \the\test > > > from the code it looks like we're talking plain luatex ... > > > > > > \the is very selective and doesn't work for all primitives or > > > macros > > > > > > compare it to \number which accepts any number representation > > > following > > > it while \the doesn't work ok 123 > > > > > > that said, your set_lua is wrong and passes a function as well as > > > an > > > index > > > > > > \directlua{ > > > lua.get_functions_table()[999] = function() > > >tex.print("\string\\numexpr 17\string\\relax") > > > end > > > token.set_lua("test", 999) > > > } > > > > > > \the\test % needs the \numexpr > > > > > > \number \test % doesn't > > > > > > \count0 \test % needs the \numexpr > > > > > > \count0=\test % doesn't > > > > > > etc > > > > Thanks for pointing out my mistake. Your example works fine but now > > the > > luacall is no longer protected and will therefore fully expand in > > \edef. So do I understand this correctly that there is no way to > > make > > the second \the\test work? > > > > \directlua{ > > lua.get_functions_table()[999] = function() > >tex.pri > > nt("\string\\numexpr 17\string\\relax") > > end > > } > > > > \tt > > \directlua{token.set_lua("test", 999)} > > \meaning\test\par % expandable luacall 999 > > \edef\x{\test}\meaning\x\par % macro:->\numexpr 17\relax > > \the\test % 17 > > > > \directlua{token.set_lua("test", 999, "protected")} > > \meaning\test\par % luacall 999 > > \edef\x{\test}\meaning\x\par % macro:->\test > > \the\test % ! You can't use `luacall 999' after \the. > > > > \bye > you can do > > \directlua{ > function TestCmd() > tex.print("\string\\numexpr 17\string\\relax") > end > } > > \protected\def\test{\directlua{TestCmd()}} > > or, more efficient: > > \directlua{ > function TestCmd() > tex.print("17") > end > } > > \protected\def\test{\numexpr\directlua{TestCmd()}\relax} Thanks, this is indeed the workaround that I currently use. However, the downside is that this has to tokenize the contents of \directlua every time (and is therefore susceptible to surrounding \catcode shenanigans) and it expands in at minimum two steps, whereas a luacall always expands in a single step. But I guess that's what I will have to live with. Cheers, Henri > > 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 / > https://www.ntg.nl/mailman/listinfo/ntg-context > webpage : https://www.pragma-ade.nl / http://context.aanhet.net > archive : https://bitbucket.org/phg/context-mirror/commits/ > wiki : https://contextgarden.net > _ > __ ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] protected macro vs protected luacall
On 1/27/2023 10:13 AM, Henri Menke via ntg-context wrote: On Thu, 2023-01-26 at 23:07 +0100, Hans Hagen via ntg-context wrote: On 1/26/2023 9:33 PM, Henri Menke via ntg-context wrote: \directlua{ userdata = userdata or {} function userdata.test() tex.print("\string\\numexpr 17\string\\relax") end } \tt \protected\def\test{\directlua{userdata.test()}} \meaning\test\par \edef\x{\test}\meaning\x\par \the\test \directlua{ local t = lua.get_functions_table() t[\string#t + 1] = userdata.test token.set_lua("test", userdata.test, \string#t, "protected") } \meaning\test\par \edef\x{\test}\meaning\x\par \the\test from the code it looks like we're talking plain luatex ... \the is very selective and doesn't work for all primitives or macros compare it to \number which accepts any number representation following it while \the doesn't work ok 123 that said, your set_lua is wrong and passes a function as well as an index \directlua{ lua.get_functions_table()[999] = function() tex.print("\string\\numexpr 17\string\\relax") end token.set_lua("test", 999) } \the\test % needs the \numexpr \number \test % doesn't \count0 \test % needs the \numexpr \count0=\test % doesn't etc Thanks for pointing out my mistake. Your example works fine but now the luacall is no longer protected and will therefore fully expand in \edef. So do I understand this correctly that there is no way to make the second \the\test work? \directlua{ lua.get_functions_table()[999] = function() tex.pri nt("\string\\numexpr 17\string\\relax") end } \tt \directlua{token.set_lua("test", 999)} \meaning\test\par % expandable luacall 999 \edef\x{\test}\meaning\x\par % macro:->\numexpr 17\relax \the\test % 17 \directlua{token.set_lua("test", 999, "protected")} \meaning\test\par % luacall 999 \edef\x{\test}\meaning\x\par % macro:->\test \the\test % ! You can't use `luacall 999' after \the. \bye you can do \directlua{ function TestCmd() tex.print("\string\\numexpr 17\string\\relax") end } \protected\def\test{\directlua{TestCmd()}} or, more efficient: \directlua{ function TestCmd() tex.print("17") end } \protected\def\test{\numexpr\directlua{TestCmd()}\relax} 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 / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] protected macro vs protected luacall
On Thu, 2023-01-26 at 23:07 +0100, Hans Hagen via ntg-context wrote: > On 1/26/2023 9:33 PM, Henri Menke via ntg-context wrote: > > \directlua{ > >userdata = userdata or {} > >function userdata.test() > > tex.print("\string\\numexpr 17\string\\relax") > >end > > } > > > > \tt > > \protected\def\test{\directlua{userdata.test()}} > > \meaning\test\par > > \edef\x{\test}\meaning\x\par > > \the\test > > > > \directlua{ > >local t = lua.get_functions_table() > >t[\string#t + 1] = userdata.test > >token.set_lua("test", userdata.test, \string#t, "protected") > > } > > \meaning\test\par > > \edef\x{\test}\meaning\x\par > > \the\test > from the code it looks like we're talking plain luatex ... > > \the is very selective and doesn't work for all primitives or macros > > compare it to \number which accepts any number representation > following > it while \the doesn't work ok 123 > > that said, your set_lua is wrong and passes a function as well as an > index > > \directlua{ > lua.get_functions_table()[999] = function() > tex.print("\string\\numexpr 17\string\\relax") > end > token.set_lua("test", 999) > } > > \the\test % needs the \numexpr > > \number \test % doesn't > > \count0 \test % needs the \numexpr > > \count0=\test % doesn't > > etc Thanks for pointing out my mistake. Your example works fine but now the luacall is no longer protected and will therefore fully expand in \edef. So do I understand this correctly that there is no way to make the second \the\test work? \directlua{ lua.get_functions_table()[999] = function() tex.pri nt("\string\\numexpr 17\string\\relax") end } \tt \directlua{token.set_lua("test", 999)} \meaning\test\par % expandable luacall 999 \edef\x{\test}\meaning\x\par % macro:->\numexpr 17\relax \the\test % 17 \directlua{token.set_lua("test", 999, "protected")} \meaning\test\par % luacall 999 \edef\x{\test}\meaning\x\par % macro:->\test \the\test % ! You can't use `luacall 999' after \the. \bye Cheers, Henri > > 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 / > https://www.ntg.nl/mailman/listinfo/ntg-context > webpage : https://www.pragma-ade.nl / http://context.aanhet.net > archive : https://bitbucket.org/phg/context-mirror/commits/ > wiki : https://contextgarden.net > _ > __ ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___