Re: [NTG-context] missing mails
Hi Hans, So, if there has been serious issues not resolved (the last year) let me know. I've been having two issues with parfillskip nodes in LMTX that I haven't been able to figure out myself. Neither of them are particularly serious, but the first one is quite annoying. (The below is mostly copied from an earlier email, "Callbacks (and nodes) in LuaMetaTeX") 1. In LMTX, calling "tex.linebreak" produces a luatex warning > tex: left parfill skip is gone warning. I don't get this warning in Plain LuaTeX, LuaLaTeX, or MkIV, so I think that it's specific to LuaMetaTeX. The LuaMetaTeX manual hardly mentions "left parfill skip"/"parfillleftskip", so I'm not too sure what to do to avoid this warning. Any call to "tex.linebreak" seems to produce this warning. Here's a minimal example: \startluacode function test(head) tex.linebreak(node.copylist(head)) return head end nodes.tasks.appendaction("processors", "after", "test") \stopluacode \starttext Hello! \stoptext And a less minimal example: % From CTAN or modules.contextgarden.net \usemodule[lua-widow-control] \starttext \dorecurse{10}{\samplefile{knuth}} \stoptext With the lwc module, I call "tex.linebreak" twice for every paragraph, so these warning messages get quite annoying. The log file for compiling the lwc manual https://github.com/gucci-on-fleek/lua-widow-control/runs/6946059955?check_suite_focus=true#check-step-9 is 22000 lines long, most of which are "left parfill skip" warnings. 2. The LuaMetaTeX manual says that "pre_linebreak_filter" is called _after_ the parfillskip glue has been added, but this doesn't seem to be the case. With LuaLaTeX/Plain LuaTeX/MkIV, this is true, but the node list passed to the callback in MkXL is missing the parfillskip. This code: \startluacode function test(head) local last = node.slide(head) print "START" for i=1,3 do print(last) print( node.type(last.id), node.subtypes(last.id)[last.subtype], last.width, last.stretchorder, last.stretch ) last = last.prev end print "STOP" return head end nodes.tasks.appendaction("processors", "after", "test") \stopluacode \starttext Hello! \stoptext with MkXL produces: START nil : glue spaceskip> gluespaceskip 341648 0 384354 2258 : glyph unset> glyph nil 213792 nil nil 2521 : glyph unset> glyph nil 385140 nil nil STOP START nil : glue userskip> glueuserskip0 2 65536 2357 : glyph unset> glyph nil 385140 nil nil 2611 : rule strut> rulestrut 0 nil nil STOP but with MkIV produces: START nil : glue 15> glueparfillskip 0 nil 65536 1041 : penalty 2> penalty linepenalty nil nil nil 1239 : glyph 256> glyph nil 213792 nil nil STOP START nil : glue 0> glueuserskip0 nil 65536 1479 : glyph 256> glyph nil 385140 nil nil 1375 : hlist 2> hlist box 0 nil nil STOP This problem isn't very serious at all since I can work around it fairly easily, but I'm including it since it's so closely related to the issue above. I _think_ that both of these are engine bugs, but I may just misreading the docs or missing something completely. Please let me know if you have any solutions. Thanks, -- Max ___ 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] Count (and limit) glyphs per line?
I've been confronted with the following 'intriguing' formatting requirement for a document: "Intriguing" is definitely right here. I suspect these guidelines were made for typewriters and haven't been updated since. to limit the number of glyphs per line to 112. 112 characters per line sounds much too long anyways. From "The Elements of Typographic Style": > Anything from 45 to 75 characters is widely regarded as a satisfactory > length of line for a single-column page set in a serifed text face > in a text size. The 66-character line (counting both letters and > spaces) is widely regarded as ideal. For multiple-column work, a > better average is 40 to 50 characters. > > If the type is well set and printed, lines of 85 or 90 characters > will pose no problem in discontinuous texts, such as bibliographies, > or, with generous leading, in footnotes. But even with generous > leading, a line that averages more than 75 or so characters is likely > to be too long for continuous reading. If you use something like \setuplayout[width=80\averagecharwidth] then your lines will for sure have fewer than 112 characters and will probably be more readable too. I'm nevertheless curious if there is a Lua/TeX solution to this "problem"? Option 1: Use a monospaced font. Then 112 characters per line <=> page width = 112em. Option 2: A hacky Lua solution \startluacode local max_length = 112 local glyph_id = node.id "glyph" local disc_id = node.id "disc" local glue_id = node.id "glue" function userdata.limiter(head) language.hyphenate(head) local chars = 0 local width = 0 local n = head while n do if n.id == glyph_id or n.id == glue_id then chars = chars + 1 width = width + n.width - (n.shrink or 0) end if chars >= max_length or width > tex.hsize then local back_chars = 0 local end_disc = nil while n do if n.id == glue_id then local penalty = node.new "penalty" penalty.penalty = -1 node.insertbefore(head, n, penalty) break end if not end_disc and n.id == disc_id then end_disc = n end if end_disc and back_chars >= 5 then end_disc.penalty = -1 break end if n.id == glyph_id then back_chars = back_chars + 1 end n = n.prev end width = 0 chars = 0 end n = n.next end return head end nodes.tasks.appendaction( "processors", "before", "userdata.limiter" ) \stopluacode \setuppapersize[landscape,letter] \showframe \starttext \setupalign[flushleft] \setupbodyfont[14pt] \samplefile{knuth} \setupbodyfont[12pt] \samplefile{knuth} \setupbodyfont[10pt] \samplefile{knuth} \page \setupalign[normal] \setupbodyfont[14pt] \samplefile{knuth} \setupbodyfont[12pt] \samplefile{knuth} \setupbodyfont[10pt] \samplefile{knuth} \stoptext This code will ensure that no line ever exceeds "max_length" characters. It uses a greedy algorithm instead of the standard TeX algorithm for line breaking, but it still produces mostly decent results. -- Max ___ 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] Failing \doifemptyelse
Hans Hagen via ntg-context schrieb am 23.06.2022 um 23:00: On 6/23/2022 9:16 PM, Willi Egger via ntg-context wrote: Good evening gurus! Why is the minimal example failing? i.e. executing always the else-branch? \setuppapersize[A6][A6] \setvariables [Test] [Number=] \starttext Value of variable Number before test: \getvariable{Test}{Number} \crlf \doifemptyelse{\getvariable{Test}{Number}} {\dorecurse {5} {TEST} } {Nothing defined \par Contents of variable Number: \getvariable{Test}{Number} } \stoptex there's also \doifelsevariable {Test} {Number} that can be used in this case \doifelseemptyvariable{Test}{Number}{...}{...} is the better choice 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 ___
[NTG-context] Count (and limit) glyphs per line?
Dear list, I've been confronted with the following 'intriguing' formatting requirement for a document: " • Type density: Must be no more than 15 characters per linear inch (including characters and spaces). • Line spacing: Must be no more than six lines per vertical inch. " While the line spacing resolves in ConTeXt to \setupinterlinespace[line=\dimexpr(1in / 6)] I was wondering if one can limit "type density" as the number of glyphs per inch in TeX too? I thought, it is more convenient to rephrase this request (for a 7 in textwidth) to limit the number of glyphs per line to 112. (Font must be sans or serif, of course ...) I've tried \setuplayout[width=112\averagecharwidth] which, however, results in ~120–130 characters and spaces per line. Pragmatically, I'm narrowing the text width to empirically match the requirement, but I'm nevertheless curious if there is a Lua/TeX solution to this "problem"? Thank you! Benjamin ___ 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] Detailed citation of reference
Hi there, using \cite[myreference] I will get a result like "[1]", or I could also change the "1" into some more detailed information such as a tag. However, I want to obtain something like "[1, section 2.1]". How can I achieve this? Thank you very much, Johann ___ 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] Failing \doifemptyelse
On 6/23/2022 9:16 PM, Willi Egger via ntg-context wrote: Good evening gurus! Why is the minimal example failing? i.e. executing always the else-branch? \setuppapersize[A6][A6] \setvariables [Test] [Number=] \starttext Value of variable Number before test: \getvariable{Test}{Number} \crlf \doifemptyelse{\getvariable{Test}{Number}} {\dorecurse {5} {TEST} } {Nothing defined \par Contents of variable Number: \getvariable{Test}{Number} } \stoptex there's also \doifelsevariable {Test} {Number} that can be used - 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] Failing \doifemptyelse
On 6/23/2022 9:16 PM, Willi Egger via ntg-context wrote: Good evening gurus! Why is the minimal example failing? i.e. executing always the else-branch? \setuppapersize[A6][A6] \setvariables [Test] [Number=] \starttext Value of variable Number before test: \getvariable{Test}{Number} \crlf \doifemptyelse{\getvariable{Test}{Number}} {\dorecurse {5} {TEST} } {Nothing defined \par Contents of variable Number: \getvariable{Test}{Number} } \stoptex because that one doesn't expand the argument \doifelsenothing \doifelsesomething \doifnothing \doifsomething can be used for your purpose - 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] Failing \doifemptyelse
Willi Egger via ntg-context schrieb am 23.06.2022 um 21:16: Good evening gurus! Why is the minimal example failing? i.e. executing always the else-branch? \doifempty(else) doesn't expand the argument and any argument counts as not empty. To satisfy the command you can expand the first argument (\normalexpanded) or you use \doifnothing(else) which expands the argument. \starttext \startbuffer \doifemptyelse{}{YES}{NO} \doifemptyelse{\empty}{YES}{NO} \normalexpanded{\doifemptyelse{}}{YES}{NO} \normalexpanded{\doifemptyelse{\empty}}{YES}{NO} \doifnothingelse{}{YES}{NO} \doifnothingelse{\empty}{YES}{NO} \stopbuffer \typebuffer \getbuffer \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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
[NTG-context] Failing \doifemptyelse
Good evening gurus! Why is the minimal example failing? i.e. executing always the else-branch? \setuppapersize[A6][A6] \setvariables [Test] [Number=] \starttext Value of variable Number before test: \getvariable{Test}{Number} \crlf \doifemptyelse{\getvariable{Test}{Number}} {\dorecurse {5} {TEST} } {Nothing defined \par Contents of variable Number: \getvariable{Test}{Number} } \stoptex I am using ConTeXt version 2022.05.11 11:36 LMTX fmt: 2022.6.15 Kind regards Willi ___ 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] colors and contours in luametafun
On 6/20/2022 6:29 PM, Jacob Kauffmann via ntg-context wrote: Dear list, Am 01.09.2021 um 09:54 schrieb Jacob Kauffmann via ntg-context : - color by value in lmt_surface We want to show a surface plot of a function where the color indicates the function value (instead, or in addition to a light source). The easiest would be to have variable cf for the brightness factor (as it is), and in addition variables such as zt, minz, maxz, akin to the color formatter for lmt_contour. This becomes handy when colors are to be aligned with function values (e.g. negative = blue, zero = white, positive = red, see MWE attached). I managed to achieve this by tweaking f_color and mp.lmt_surface_do in mlib-cnt.lmt in ConTeXt ver: 2022.05.11 11:36 LMTX fmt: 2022.6.20 a bit. Please find the diff and a MWE attached. in next version (next time just send me the file, easier than a diff) Cheers, Jacob Kauffmann --- context/tex/texmf-context/tex/context/base/mkxl/mlib-cnt.lmt 2022-06-20 18:11:51.0 +0200 +++ mlib-cnt.lmt2022-06-20 18:26:22.0 +0200 @@ -1839,7 +1839,29 @@ local f_color = formatters [ [[ local math = math -return function(f) +local min = math.min +local max = math.max +local abs = math.abs +local minz = %s +local maxz = %s + +local color_value = 0 +local color_step = mp.lmt_color_functions.step +local color_shade = mp.lmt_color_functions.shade + +local function step(...) +return color_step(color_value,n,...) +end +local function shade(...) +return color_shade(color_value,n,...) +end +-- local function lin(l) +-- return l/n +-- end +%s +return function(z, f) +function_value = z +brightness_factor = f return %s end ]] ] @@ -1898,7 +1920,7 @@ local dy = (ymax - ymin) / ny local xt = xmin -- -local minf, maxf +local minf, maxf, minz, maxz -- -- similar as contours but no data loop here -- @@ -1908,12 +1930,6 @@ return false -- fatal error end -- -local ccode = load(f_color(colorcode)) -local color = type(ccode) == "function" and ccode() -if type(color) ~= "function" then -return false -- fatal error -end --- for i=0,nx do local yt = ymin for j=0,ny do @@ -1946,7 +1962,16 @@ maxf = fac end -- -data[i][j] = { x, y, fac } +if not minz then + minz = z + maxz = z +elseif z < minz then + minz = z +elseif z > maxz then + maxz = z +end +-- +data[i][j] = { x, y, fac, z } -- yt = yt + dy end @@ -1957,6 +1982,16 @@ local range = maxf - minf local cl = linecolor or 1 local enforce = attributes.colors.model == "cmyk" +-- +-- local ccode = load(f_color(colorcode)) +report("minz, maxz is (%s,%s)",minz,maxz) +report("colorcode is %s", colorcode) +local ccode = load(f_color(minz, maxz, preamble, colorcode)) +local color = type(ccode) == "function" and ccode() +if type(color) ~= "function" then +return false -- fatal error +end +-- for i=0,nx-1 do for j=0,ny-1 do -- points @@ -1985,12 +2020,13 @@ local z32 = z3[2] local z41 = z4[1] local z42 = z4[2] +local zout = z1[4] -- if lines then -- -- fill first and draw then, previous shapes can be covered -- else -- -- fill and draw in one go to prevent artifacts -- end -local cr, cg, cb = color(cf) +local cr, cg, cb = color(zout, cf) if not cr then cr = 0 end if not cg then cg = 0 end if not cb then cb = 0 end ___ 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 ___ -- - 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 Wi
[NTG-context] missing mails
Hi, I just found otu that the majority of the mailing list mails ended up in a different mail box (som,ehoe thunderbird has problems with two accounts being subscribed to the same list). So, if there has been serious issues not resolved (the last year) let me know. A quick checked that most got answered in some way, 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] Graphviz and ConTeXt
Hi, You could just convert these separately to pdf/svg/jpg/png and then load them as \externalfigure. You could also use the filter module to be able to take them inline into the ConTeXt code: \usemodule[filter] \define[1]\ReadFigure{\externalfigure[#1]} \defineexternalfilter[graphviz] [cache=yes, readcommand=\ReadFigure, output={\externalfilterbasefile.pdf}, filtercommand={dot -Tpdf -o "\externalfilterbasefile.pdf" "\externalfilterinputfile"}] \starttext \startTEXpage \startgraphviz digraph G { main -> parse -> execute; main -> init; main -> cleanup; execute -> make_string; execute -> printf init -> make_string; main -> printf; execute -> compare; } \stopgraphviz \stopTEXpage \stoptext See the filter module documentation for more details about that. Best wishes, Taco > On 23 Jun 2022, at 14:08, juh via ntg-context wrote: > > Dear all, > > I have a legacy project that I shall convert to a new ConTeXt project. > > There are a lot of Graphviz dot-files. What shall I do with these? > > Any hints? > juh > -- > Autoren-Homepage: . http://literatur.hasecke.com > Satiren & Essays: . http://www.sudelbuch.de > Privater Blog: http://www.hasecke.eu > Netzliteratur-Projekt: http://www.generationenprojekt.de > > > ___ > If your question is of interest to others as well, please add an entry to the > Wiki! > > maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context > webpage : http://www.pragma-ade.nl / http://context.aanhet.net > archive : https://bitbucket.org/phg/context-mirror/commits/ > wiki : http://contextgarden.net > ___ — Taco Hoekwater E: t...@bittext.nl genderfluid (all pronouns) ___ 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] Graphviz and ConTeXt
Dear all, I have a legacy project that I shall convert to a new ConTeXt project. There are a lot of Graphviz dot-files. What shall I do with these? Any hints? juh -- Autoren-Homepage: . http://literatur.hasecke.com Satiren & Essays: . http://www.sudelbuch.de Privater Blog: http://www.hasecke.eu Netzliteratur-Projekt: http://www.generationenprojekt.de signature.asc Description: PGP signature ___ 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 ___