Re: [NTG-context] Lua to Context Table
On Sat, 2 Aug 2014, luigi scarso wrote: On Sat, Aug 2, 2014 at 12:59 AM, John Kitzmiller wrote: Here is Lua code that prints the first nine fibonacci numbers: local function fib(n) f={1,1} for i=3,9 do f[i]=f[i-1]+f[i-2] end return(f[n]) end for n=1,9 do print(fib(n)) end Here is Context+Lua that prints 3 x 3 table of the first nine natural numbers: \starttext \setupTABLE[each][each][frame=off,align=left,width=4em,height=2em] \startluacode context.bTABLE() for j = 0, 2 do context.bTR() for k = 1, 3 do context.bTD() context(3*j+k) context.eTD() end context.eTR() end context.eTABLE() \stopluacode \stoptext How can these be combined to print a 3 x 3 table of the first nine fibonacci numbers? I have tried a couple of ways to iterate over the lua table f in the most indented line of context, looked at what pertinent threads I could find, the Wiki entries, CLD, and tried Aditya's method from Stack Exchange; I am missing something. You have a *global* table f that collides with the internals of context local function fib(n) f={1,1} for i=3,9 do f[i]=f[i-1]+f[i-2] end return(f[n]) end \starttext \setupTABLE[each][each][frame=off,align=left,width=8em,height=2em] \startluacode local function fib(n) local f={1,1} for i=3,9 do f[i]=f[i-1]+f[i-2] end return(f[n]) end context.bTABLE() for j = 0, 2 do context.bTR() for k = 1, 3 do context.bTD() context("fib(%s)=%s" ,3*j+k, fib(3*j+k) ) context.eTD() end context.eTR() end context.eTABLE() \stopluacode \stoptext This version recomputes all fibnocci numbers from scrach each time. Here is a memoized version: \setupTABLE[each][each][frame=off,align=left,width=8em,height=2em] \starttext \startluacode local fibs = {1, 1} local function fib(n) if fibs[n] == nil then print("", "Computing fib:" .. n) fibs[n] = fib(n-1) + fib(n-2) end return fibs[n] end context.bTABLE() for j = 0, 2 do context.bTR() for k = 1, 3 do context.bTD() context("fib(%s)=%s" ,3*j+k, fib(3*j+k) ) context.eTD() end context.eTR() end context.eTABLE() \stopluacode \stoptext Aditya ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Lua to Context Table
On Sat, Aug 2, 2014 at 12:59 AM, John Kitzmiller wrote: > Here is Lua code that prints the first nine fibonacci numbers: > > local function fib(n) > f={1,1} > for i=3,9 do > f[i]=f[i-1]+f[i-2] > end > return(f[n]) > end > for n=1,9 do print(fib(n)) end > > Here is Context+Lua that prints 3 x 3 table of the first nine natural > numbers: > > \starttext > \setupTABLE[each][each][frame=off,align=left,width=4em,height=2em] > \startluacode > context.bTABLE() > for j = 0, 2 do > context.bTR() > for k = 1, 3 do > context.bTD() > context(3*j+k) > context.eTD() > end > context.eTR() > end > context.eTABLE() > \stopluacode > \stoptext > > How can these be combined to print a 3 x 3 table of the first nine > fibonacci numbers? > > I have tried a couple of ways to iterate over the lua table f in the most > indented line of context, looked at what pertinent threads I could find, > the Wiki entries, CLD, and tried Aditya's method from Stack Exchange; I am > missing something. > You have a *global* table f that collides with the internals of context local function fib(n) f={1,1} for i=3,9 do f[i]=f[i-1]+f[i-2] end return(f[n]) end \starttext \setupTABLE[each][each][frame=off,align=left,width=8em,height=2em] \startluacode local function fib(n) local f={1,1} for i=3,9 do f[i]=f[i-1]+f[i-2] end return(f[n]) end context.bTABLE() for j = 0, 2 do context.bTR() for k = 1, 3 do context.bTD() context("fib(%s)=%s" ,3*j+k, fib(3*j+k) ) context.eTD() end context.eTR() end context.eTABLE() \stopluacode \stoptext -- luigi ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
[NTG-context] Lua to Context Table
Here is Lua code that prints the first nine fibonacci numbers: local function fib(n) f={1,1} for i=3,9 do f[i]=f[i-1]+f[i-2] end return(f[n]) end for n=1,9 do print(fib(n)) end Here is Context+Lua that prints 3 x 3 table of the first nine natural numbers: \starttext \setupTABLE[each][each][frame=off,align=left,width=4em,height=2em] \startluacode context.bTABLE() for j = 0, 2 do context.bTR() for k = 1, 3 do context.bTD() context(3*j+k) context.eTD() end context.eTR() end context.eTABLE() \stopluacode \stoptext How can these be combined to print a 3 x 3 table of the first nine fibonacci numbers? I have tried a couple of ways to iterate over the lua table f in the most indented line of context, looked at what pertinent threads I could find, the Wiki entries, CLD, and tried Aditya's method from Stack Exchange; I am missing something. John ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] \os
Am 01.08.2014 um 18:39 schrieb Procházka Lukáš Ing. - Pontex s. r. o. : > Hello, > > the command \os turns old-style numbers on. > > How to turn it off (when being on initially)? When you have a font which uses old style numerals by default you can disable them by enabling lining numbers because you load the font. Below is a example with one of my own fonts which use old style numbers by default. \definefontfeature[default][default][lnum=yes] \setupbodyfont[calluna] \starttext 0123456789 \stoptext Wolfgang ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
[NTG-context] \os
Hello, the command \os turns old-style numbers on. How to turn it off (when being on initially)? TIA. Best regards, Lukas -- Ing. Lukáš Procházka [mailto:l...@pontex.cz] Pontex s. r. o. [mailto:pon...@pontex.cz] [http://www.pontex.cz] Bezová 1658 147 14 Praha 4 Tel: +420 241 096 751 Fax: +420 244 461 038 ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Leave out reference to page if on the same page?
On 01 Aug 2014, at 13:30, Gerben Wierda wrote: > […] > I’ve tried to add this to my environment and product file, but even without > using it, it ends in an error: > > (/usr/local/texlive/2014/texmf-dist/tex/context/base/spec-tpd.mkii > specials: loading definition file fdf > (/usr/local/texlive/2014/texmf-dist/tex/context/base/spec-fdf.mkii)) > ! Undefined control sequence. > l.5 {\doifcheckedpagestate >{#5}% > ? > > G Hi Gerben, I think you are using mkii, while the code sent by Hans and containing \doifcheckedpagestate is intended for use with mkiv. Best regards: OK___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Leave out reference to page if on the same page?
On 26 Jul 2014, at 10:43, Hans Hagen wrote: > On 7/25/2014 4:31 PM, Gerben Wierda wrote: >> Thanks all for the discussion. As a simple user, I think I must pass. All >> this complexity in my document text and setup is too much trouble and it >> seems risky (wjhat am I going to break?). Far less work to do a small check >> at the end. > > Well, that kind of decisions demand injecting a node so there could be > potential interference (as with more mechanisms that carry status info around > for a second pass). > > Anyway, maybe someone else benefits from the extension. > >> What I was looking for was something simple that made for instance >> \at{page][foo] conditional, e.g. >> >> \conditionalat[when]{page}[foo] >> >> with ‘when’ is something like >> always >> onpage >> offpage >> onspread >> offspread >> never >> >> Typing \conditionalat instead of \at is what I as a simpleton user can >> handle… > > \unprotect > > \unexpanded\def\strc_references_conditional#1#2[#3]#4[#5]% > {text}[condition][reference] > {\doifcheckedpagestate{#5}% > {\doifelse{#3}\v!precedingpage{#1{#2}[#5]}\ignorespaces}% > {\doifelse{#3}\v!hencefore{#1{#2}[#5]}\ignorespaces}% > {\doifelse{#3}\v!current {#1{#2}[#5]}\ignorespaces}% > {\doifelse{#3}\v!hereafter{#1{#2}[#5]}\ignorespaces}% > {\doifelse{#3}\v!followingpage{#1{#2}[#5]}\ignorespaces}% > {}} > > \unexpanded\def\conditionalat {\strc_references_conditional\at} > \unexpanded\def\conditionalin {\strc_references_conditional\in} > \unexpanded\def\conditionalabout{\strc_references_conditional\about} > > \protect > > But I'll not enable it to the code as it's not used anyway (maybe sometime a > module). I’ve tried to add this to my environment and product file, but even without using it, it ends in an error: (/usr/local/texlive/2014/texmf-dist/tex/context/base/spec-tpd.mkii specials: loading definition file fdf (/usr/local/texlive/2014/texmf-dist/tex/context/base/spec-fdf.mkii)) ! Undefined control sequence. l.5 {\doifcheckedpagestate {#5}% ? G > >> G >> >> On 25 Jul 2014, at 13:06, Hans Hagen wrote: >> >>> On 7/24/2014 2:03 PM, Otared Kavian wrote: Hi, Thanks for your attention, Wolfgang: indeed removing \analyzecurrentreference from your example allows mkiv to typeset correctly and obtain the expected result. >>> >>> >>> yet another sparsely documented feature ... in beta: >>> >>> % tests/mkiv/pagestate-001.tex >>> >>> \useMPlibrary[dum] >>> >>> \setuppagenumbering >>> [alternative=doublesided] >>> >>> % new: \setupreferencing[doublesided=no] >>> >>> % old: \somewhere{backward}{foreward}[label] >>> % new: \someplace{preceding}{backward}{current}{foreward}{following}[label] >>> % old: \atpage[#label] >>> % new: >>> \doifcheckedpagestate{label}{preceding}{backward}{current}{foreward}{following}{otherwise} >>> >>> \starttext >>> >>> \dorecurse {20} { >>>\placefigure >>> [here] >>> [fig:#1] >>> {} >>> {\externalfigure[dummy]} >>>\dorecurse {20} { >>>##1: \atpage[fig:##1] / >>>\doifcheckedpagestate{fig:##1} >>> {preceding} >>> {backward} >>> {current} >>> {foreward} >>> {following} >>> {otherwise} >>>} >>> } >>> >>> \stoptext >>> >>> if okay, then it's something to wikify ... should >>> \setupreferencing[doublesided=no] be default? (currently yes i.e. spread >>> aware) >>> >>> keep in mind that this kind of functionality once it kicks in (is used) can >>> result in a few more runs to get thing right and that there's always the >>> danger of oscillation as the text injected is dependent on the situation >>> >>> Hans >>> >>> >>> - >>> Hans Hagen | PRAGMA ADE >>> Ridderstraat 27 | 8061 GH Hasselt | The Netherlands >>>tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com >>> | 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://tex.aanhet.net >>> archive : http://foundry.supelec.fr/projects/contextrev/ >>> wiki : http://contextgarden.net >>> ___ >> >> ___ >> If your question is of interest to others as well, please add an entry to >> the Wiki! >> >> maillist : ntg-context@ntg.nl / >> http://www.ntg.nl/mailman/l
Re: [NTG-context] Hyphenatedurl: custom line-break symbol, disable stretching
On 2014-07-31, 14:49, Wolfgang Schuster wrote: > From what I can see in the code there is no option to disable the > stretch values. Thanks for checking. Kind regards, Joshua ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___