Re: [NTG-context] Modes and conditional part of the source
Hello Aditya, thanks for the code, I'll try something like that. Best regards, Lukas On Thu, 28 Feb 2019 12:54:06 +0100, Aditya Mahajan wrote: On Thu, 28 Feb 2019, Procházka Lukáš Ing. wrote: Hello, I'm struggling with using modes to make a part of the text conditional. Here is my code: \def\b#1{\startmode[#1]} \def\e{\stopmode} % \enablemode[100] % For optional usage \starttext A \b{100} % Should be start of some conditional text from here ... B \e % ... to here \stoptext Modes don't work that way. You can do something like this: \define[1]\bbb {\doifnotmode{#1} {\grabbufferdata[dummy][bbb][eee]}} \let\eee\relax \enablemode[100] \starttext A \bbb{100} Inside mode 100 \eee \bbb{101} Inside mode 101 \eee \stoptext Depending on the actual use case, there might be simpler ways. Aditya -- Ing. Lukáš Procházka | mailto:l...@pontex.cz Pontex s. r. o. | mailto:pon...@pontex.cz | http://www.pontex.cz | IDDS: nrpt3sn | IČO: 40763439 Bezová 1658 147 14 Praha 4 Mob.: +420 702 033 396 ___ 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] Modes and conditional part of the source
On Thu, 28 Feb 2019, Procházka Lukáš Ing. wrote: Hello, I'm struggling with using modes to make a part of the text conditional. Here is my code: \def\b#1{\startmode[#1]} \def\e{\stopmode} % \enablemode[100] % For optional usage \starttext A \b{100} % Should be start of some conditional text from here ... B \e % ... to here \stoptext Modes don't work that way. You can do something like this: \define[1]\bbb {\doifnotmode{#1} {\grabbufferdata[dummy][bbb][eee]}} \let\eee\relax \enablemode[100] \starttext A \bbb{100} Inside mode 100 \eee \bbb{101} Inside mode 101 \eee \stoptext Depending on the actual use case, there might be simpler ways. 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] Grammar to parse TeX input?
I’ve tried context.processbuffer but I am afraid it’s not what I am after, most probably I have not phrased clearly my question. What I am looking for is roughly what’s described in Taco’s presentation https://meeting.contextgarden.net/2014/talks/2014-09-12-taco-luatex/luatextalk.pdf A way to decompose some input into tokens which represent either normal text, csnames etc… I had a try to this token library in LuaTeX but I could not find examples of how to use it. I suspect that buffers mechanism use it somehow. Thanks De : Hans Hagen Envoyé le :lundi 26 novembre 2018 18:55 À : mailing list for ConTeXt users; Joseph Canedo Objet :Re: [NTG-context] Grammar to parse TeX input? On 11/26/2018 3:19 PM, Joseph Canedo wrote: > \startluacode > > function zzz_function(text) > > - How to process ‘text’ to get bits which are macros, groups etc… ? > Eventually expanded ? > > end > > \stopluacode > > \definebuffer[ZZZBuffer] > > \def\StartZZZ{\grabbufferdata[ZZZBuffer][StartZZZ][StopZZZ]} > > \def\StopZZZ{\ctxlua{zzz_function(buffers.getcontent('ZZZBuffer'))}} > > \StartZZZ > > \input knuth > > \StopZZZ context.processbuffer { "ZZZBuffer" } - 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] Grammar to parse TeX input?
On 11/26/2018 3:19 PM, Joseph Canedo wrote: \startluacode function zzz_function(text) - How to process ‘text’ to get bits which are macros, groups etc… ? Eventually expanded ? end \stopluacode \definebuffer[ZZZBuffer] \def\StartZZZ{\grabbufferdata[ZZZBuffer][StartZZZ][StopZZZ]} \def\StopZZZ{\ctxlua{zzz_function(buffers.getcontent('ZZZBuffer'))}} \StartZZZ \input knuth \StopZZZ context.processbuffer { "ZZZBuffer" } - 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] Grammar to parse TeX input?
Dear list, I use a buffer to make some text processing. That text contains TeX macros etc… and I’d like to know if there is some feature in lua to parse the text to extract bits which macros, normal text etc… ? Thanks Best regards Joseph Example of pseudo MWE follows. \startluacode function zzz_function(text) - How to process ‘text’ to get bits which are macros, groups etc… ? Eventually expanded ? end \stopluacode \definebuffer[ZZZBuffer] \def\StartZZZ{\grabbufferdata[ZZZBuffer][StartZZZ][StopZZZ]} \def\StopZZZ{\ctxlua{zzz_function(buffers.getcontent('ZZZBuffer'))}} \StartZZZ \input knuth \StopZZZ ___ 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] How can I remove a blank leading line from a buffer
On 8/13/2018 18:43, Rik Kabel wrote: On 8/13/2018 15:52, Wolfgang Schuster wrote: Rik Kabel schrieb am 13.08.18 um 20:27: On 8/13/2018 13:46, Wolfgang Schuster wrote: \starttext \BeforePar{\dontleavehmode\llap{? }}\GotoPar \input knuth \startnarrower \BeforePar{\dontleavehmode\llap{? }}\GotoPar \input knuth \stopnarrower \stoptext Wolfgang I am applying it incorrectly, or it does not work with the buffers created by \grabbufferdata: \setupwhitespace[none] \setupindenting[none] \starttexdefinition unexpanded startBufTest \bgroup \dosingleempty\dostartBufTest \stoptexdefinition \starttexdefinition dostartBufTest [#SETUPS] \getrawparameters[BufTest][xx=yy,#SETUPS] \grabbufferdata[TestBuffer][startBufTest][stopBufTest] \stoptexdefinition \starttexdefinition stopBufTest \startnarrower[left,right] \startparagraph \BeforePar{\dontleavehmode\llap{? }}\GotoPar \inlinebuffer[TestBuffer] \stopparagraph \stopnarrower \egroup \stoptexdefinition \starttexdefinition stopBufTest \startnarrower[left,right] \startparagraph \dontleavehmode\llap{? }% \blank[overlay] \inlinebuffer[TestBuffer] \stopparagraph \stopnarrower \egroup \stoptexdefinition Wolfgang Thank you, Wolfgang. That does it. Note that the % escaping the line end is not needed ( although it might be needed outside a \starttexdefinition environment) – the following works as well: \starttexdefinition stopBufTest \startnarrower[left,right] \startparagraph \dontleavehmode{\llap{? }} \blank[overlay] \inlinebuffer[TestBuffer] \stopparagraph \stopnarrower \egroup \stoptexdefinition Alas, this is not yet a workable solution. It does not work with a layout of grid=tolerant, which I am currently using (although it does work with some other grid settings). For now I will just add empty [] to the startBufTest invocations. I really think, though, that a buffers.strip function would be the way to go, instead of futzing after the damage is done. -- Rik ___ 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] How can I remove a blank leading line from a buffer
On 8/13/2018 15:52, Wolfgang Schuster wrote: Rik Kabel schrieb am 13.08.18 um 20:27: On 8/13/2018 13:46, Wolfgang Schuster wrote: \starttext \BeforePar{\dontleavehmode\llap{? }}\GotoPar \input knuth \startnarrower \BeforePar{\dontleavehmode\llap{? }}\GotoPar \input knuth \stopnarrower \stoptext Wolfgang I am applying it incorrectly, or it does not work with the buffers created by \grabbufferdata: \setupwhitespace[none] \setupindenting[none] \starttexdefinition unexpanded startBufTest \bgroup \dosingleempty\dostartBufTest \stoptexdefinition \starttexdefinition dostartBufTest [#SETUPS] \getrawparameters[BufTest][xx=yy,#SETUPS] \grabbufferdata[TestBuffer][startBufTest][stopBufTest] \stoptexdefinition \starttexdefinition stopBufTest \startnarrower[left,right] \startparagraph \BeforePar{\dontleavehmode\llap{? }}\GotoPar \inlinebuffer[TestBuffer] \stopparagraph \stopnarrower \egroup \stoptexdefinition \starttexdefinition stopBufTest \startnarrower[left,right] \startparagraph \dontleavehmode\llap{? }% \blank[overlay] \inlinebuffer[TestBuffer] \stopparagraph \stopnarrower \egroup \stoptexdefinition Wolfgang Thank you, Wolfgang. That does it. Note that the % escaping the line end is not needed ( although it might be needed outside a \starttexdefinition environment) – the following works as well: \starttexdefinition stopBufTest \startnarrower[left,right] \startparagraph \dontleavehmode{\llap{? }} \blank[overlay] \inlinebuffer[TestBuffer] \stopparagraph \stopnarrower \egroup \stoptexdefinition -- Rik ___ 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] How can I remove a blank leading line from a buffer
Rik Kabel schrieb am 13.08.18 um 20:27: On 8/13/2018 13:46, Wolfgang Schuster wrote: \starttext \BeforePar{\dontleavehmode\llap{? }}\GotoPar \input knuth \startnarrower \BeforePar{\dontleavehmode\llap{? }}\GotoPar \input knuth \stopnarrower \stoptext Wolfgang I am applying it incorrectly, or it does not work with the buffers created by \grabbufferdata: \setupwhitespace[none] \setupindenting[none] \starttexdefinition unexpanded startBufTest \bgroup \dosingleempty\dostartBufTest \stoptexdefinition \starttexdefinition dostartBufTest [#SETUPS] \getrawparameters[BufTest][xx=yy,#SETUPS] \grabbufferdata[TestBuffer][startBufTest][stopBufTest] \stoptexdefinition \starttexdefinition stopBufTest \startnarrower[left,right] \startparagraph \BeforePar{\dontleavehmode\llap{? }}\GotoPar \inlinebuffer[TestBuffer] \stopparagraph \stopnarrower \egroup \stoptexdefinition \starttexdefinition stopBufTest \startnarrower[left,right] \startparagraph \dontleavehmode\llap{? }% \blank[overlay] \inlinebuffer[TestBuffer] \stopparagraph \stopnarrower \egroup \stoptexdefinition 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] How can I remove a blank leading line from a buffer
On 8/13/2018 13:46, Wolfgang Schuster wrote: \starttext \BeforePar{\dontleavehmode\llap{? }}\GotoPar \input knuth \startnarrower \BeforePar{\dontleavehmode\llap{? }}\GotoPar \input knuth \stopnarrower \stoptext Wolfgang I am applying it incorrectly, or it does not work with the buffers created by \grabbufferdata: \setupwhitespace[none] \setupindenting[none] \starttexdefinition unexpanded startBufTest \bgroup \dosingleempty\dostartBufTest \stoptexdefinition \starttexdefinition dostartBufTest [#SETUPS] \getrawparameters[BufTest][xx=yy,#SETUPS] \grabbufferdata[TestBuffer][startBufTest][stopBufTest] \stoptexdefinition \starttexdefinition stopBufTest \startnarrower[left,right] \startparagraph \BeforePar{\dontleavehmode\llap{? }}\GotoPar \inlinebuffer[TestBuffer] \stopparagraph \stopnarrower \egroup \stoptexdefinition \starttext \startBufTest Buffer without blank lines. \stopBufTest \startBufTest Buffer with blank lines. \stopBufTest \startBufTest[key=value] Buffer with \type{[key=value]}. \stopBufTest \stoptext -- Rik ___ 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] How can I remove a blank leading line from a buffer
On 8/13/2018 03:01, Hans Hagen wrote: On 8/13/2018 5:18 AM, Rik Kabel wrote: %% How can one remove blank lines at the start of a buffer so that %% commands that grab a buffer can be used in the same way as, for %% example, \startparagraph...\stopparagraph, which allow blank %% lines around the content? %% %% The problem appears when an optional argument is allowed but none %% is provided. Adding \relax does not help; adding empty brackets %% does. I see no way to distinguish between a buffer without %% leading blank lines and a buffer that was created when brackets %% are provided. %% %% \inlinebuffer handles the leading blank lines when there is %% nothing prepended, but I need to prepend. (It also handles the %% unwanted trailing line, but that is not an issue here). %% %% How can I unpack the buffer, apply the equivalent functions of %% ignorespaspaces and removeunwantedspaces to it, and repack it? %% The buffer may contain internal blank lines and macros, and %% those should be retained. Or, is there already a function to %% strip a buffer in the manner that string.strip does a string? \setupwhitespace[none] \setupindenting[none] \define\Mark{\color[middlegray]{\itb¿\ }} \define\First{nothing yet} \define\Arg{nothing yet} \setuplanguage[en][spacing=packed] \starttexdefinition unexpanded startBufTest \bgroup \dosingleempty\dostartBufTest \stoptexdefinition \starttexdefinition dostartBufTest [#SETUPS] \doifsomethingelse{#{SETUPS}} {\define\Arg{yes}} {\define\Arg{no}} \iffirstargument \define\First{yes} \else \define\First{no} \fi \relax \getrawparameters[BufTest][xx=yy,#SETUPS] \grabbufferdata[TestBuffer][startBufTest][stopBufTest] \stoptexdefinition \starttexdefinition stopBufTest \startparagraph \dontleavehmode\llap{\Mark}\inlinebuffer[TestBuffer] \ (first: \First, arg: \Arg) \stopparagraph \egroup \stoptexdefinition \starttext \startparagraph A starting paragraph. \stopparagraph \startBufTest Buffer without blank lines. \stopBufTest \startparagraph An intervening paragraph. \stopparagraph \startBufTest Buffer with blank lines. \stopBufTest \startparagraph An intervening paragraph. \stopparagraph \startBufTest\relax Buffer with \tex{relax}. \stopBufTest \startparagraph An intervening paragraph. \stopparagraph \startBufTest[] Buffer with \type{[]}. \stopBufTest \startparagraph An intervening paragraph. \stopparagraph \startBufTest[key=value] Buffer with \type{[key=value]}. \stopBufTest \startparagraph A closing paragraph. \stopparagraph \stoptext \startparagraph % \dontleavehmode\llap{\Mark}\inlinebuffer[TestBuffer] % \ (first: \First, arg: \Arg) \margintext{\Mark} \setupparagraphintro[first][(first: \First, arg: \Arg)] %\setupparagraphintro[next][(first: \First, arg: \Arg)] \getbuffer[TestBuffer] \stopparagraph Hans, That works for the over-simplified case here, but fails in practice. For a \startnarrower[left] paragraph, the mark is still in the main margin, not the 'margin' of the narrowed paragraph. Also, the placement of the text in the margin is wrong and not easily controlled as with \llap and \rlap. The code started out more like: \define\Mark{\color[middlegray]{\hskip.6cm\itb¿\ }} \setwidthof{\Mark}\to\MarkWidth ... \starttexdefinition stopBufTest \startluacode buffers.prepend("TestBuffer","\\dontleavehmode\\llap{\\Mark}") \stopluacode \setupnarrower[left=\MarkWidth] \startnarrower[left,right] \startparagraph \inlinebuffer[TestBuffer] \stopparagraph \stopnarrower \egroup \stoptexdefinition So I am still looking for a way to do this. Meanwhile I am trying to understand Aditya's examples. -- Rik ___ 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] How can I remove a blank leading line from a buffer
On 8/13/2018 5:18 AM, Rik Kabel wrote: %% How can one remove blank lines at the start of a buffer so that %% commands that grab a buffer can be used in the same way as, for %% example, \startparagraph...\stopparagraph, which allow blank %% lines around the content? %% %% The problem appears when an optional argument is allowed but none %% is provided. Adding \relax does not help; adding empty brackets %% does. I see no way to distinguish between a buffer without %% leading blank lines and a buffer that was created when brackets %% are provided. %% %% \inlinebuffer handles the leading blank lines when there is %% nothing prepended, but I need to prepend. (It also handles the %% unwanted trailing line, but that is not an issue here). %% %% How can I unpack the buffer, apply the equivalent functions of %% ignorespaspaces and removeunwantedspaces to it, and repack it? %% The buffer may contain internal blank lines and macros, and %% those should be retained. Or, is there already a function to %% strip a buffer in the manner that string.strip does a string? \setupwhitespace[none] \setupindenting[none] \define\Mark{\color[middlegray]{\itb¿\ }} \define\First{nothing yet} \define\Arg{nothing yet} \setuplanguage[en][spacing=packed] \starttexdefinition unexpanded startBufTest \bgroup \dosingleempty\dostartBufTest \stoptexdefinition \starttexdefinition dostartBufTest [#SETUPS] \doifsomethingelse{#{SETUPS}} {\define\Arg{yes}} {\define\Arg{no}} \iffirstargument \define\First{yes} \else \define\First{no} \fi \relax \getrawparameters[BufTest][xx=yy,#SETUPS] \grabbufferdata[TestBuffer][startBufTest][stopBufTest] \stoptexdefinition \starttexdefinition stopBufTest \startparagraph \dontleavehmode\llap{\Mark}\inlinebuffer[TestBuffer] \ (first: \First, arg: \Arg) \stopparagraph \egroup \stoptexdefinition \starttext \startparagraph A starting paragraph. \stopparagraph \startBufTest Buffer without blank lines. \stopBufTest \startparagraph An intervening paragraph. \stopparagraph \startBufTest Buffer with blank lines. \stopBufTest \startparagraph An intervening paragraph. \stopparagraph \startBufTest\relax Buffer with \tex{relax}. \stopBufTest \startparagraph An intervening paragraph. \stopparagraph \startBufTest[] Buffer with \type{[]}. \stopBufTest \startparagraph An intervening paragraph. \stopparagraph \startBufTest[key=value] Buffer with \type{[key=value]}. \stopBufTest \startparagraph A closing paragraph. \stopparagraph \stoptext \startparagraph % \dontleavehmode\llap{\Mark}\inlinebuffer[TestBuffer] % \ (first: \First, arg: \Arg) \margintext{\Mark} \setupparagraphintro[first][(first: \First, arg: \Arg)] %\setupparagraphintro[next][(first: \First, arg: \Arg)] \getbuffer[TestBuffer] \stopparagraph - 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] How can I remove a blank leading line from a buffer
On 13/08/18 15:18, Rik Kabel wrote: %% How can one remove blank lines at the start of a buffer so that %% commands that grab a buffer can be used in the same way as, for %% example, \startparagraph...\stopparagraph, which allow blank %% lines around the content? %% %% The problem appears when an optional argument is allowed but none %% is provided. Adding \relax does not help; adding empty brackets %% does. I see no way to distinguish between a buffer without %% leading blank lines and a buffer that was created when brackets %% are provided. %% %% \inlinebuffer handles the leading blank lines when there is %% nothing prepended, but I need to prepend. (It also handles the %% unwanted trailing line, but that is not an issue here). %% %% How can I unpack the buffer, apply the equivalent functions of %% ignorespaspaces and removeunwantedspaces to it, and repack it? %% The buffer may contain internal blank lines and macros, and %% those should be retained. Or, is there already a function to %% strip a buffer in the manner that string.strip does a string? \setupwhitespace[none] \setupindenting[none] \define\Mark{\color[middlegray]{\itb¿\ }} \define\First{nothing yet} \define\Arg{nothing yet} \setuplanguage[en][spacing=packed] \starttexdefinition unexpanded startBufTest \bgroup \dosingleempty\dostartBufTest \stoptexdefinition \starttexdefinition dostartBufTest [#SETUPS] \doifsomethingelse{#{SETUPS}} {\define\Arg{yes}} {\define\Arg{no}} \iffirstargument \define\First{yes} \else \define\First{no} \fi \relax \getrawparameters[BufTest][xx=yy,#SETUPS] \grabbufferdata[TestBuffer][startBufTest][stopBufTest] \stoptexdefinition \starttexdefinition stopBufTest \startparagraph % Ignore first \par \def\par{\let\par\normalpar} \dontleavehmode\llap{\Mark}\inlinebuffer[TestBuffer] \ (first: \First, arg: \Arg) \stopparagraph \egroup \stoptexdefinition \starttext \startparagraph A starting paragraph. \stopparagraph \startBufTest Buffer without blank lines. \stopBufTest \startparagraph An intervening paragraph. \stopparagraph \startBufTest Buffer with blank lines. \stopBufTest \startparagraph An intervening paragraph. \stopparagraph \startBufTest\relax Buffer with \tex{relax}. \stopBufTest \startparagraph An intervening paragraph. \stopparagraph \startBufTest[] Buffer with \type{[]}. \stopBufTest \startparagraph An intervening paragraph. \stopparagraph \startBufTest[key=value] Buffer with \type{[key=value]}. \stopBufTest \startparagraph A closing paragraph. \stopparagraph \stoptext \stopmode %% -- %% Rik Kabel ___ 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 ___ ___ 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] How can I remove a blank leading line from a buffer
On Sun, 12 Aug 2018, Rik Kabel wrote: %% How can one remove blank lines at the start of a buffer so that %% commands that grab a buffer can be used in the same way as, for %% example, \startparagraph...\stopparagraph, which allow blank %% lines around the content? %% %% The problem appears when an optional argument is allowed but none %% is provided. Adding \relax does not help; adding empty brackets %% does. I see no way to distinguish between a buffer without %% leading blank lines and a buffer that was created when brackets %% are provided. %% %% \inlinebuffer handles the leading blank lines when there is %% nothing prepended, but I need to prepend. (It also handles the %% unwanted trailing line, but that is not an issue here). %% %% How can I unpack the buffer, apply the equivalent functions of %% ignorespaspaces and removeunwantedspaces to it, and repack it? %% The buffer may contain internal blank lines and macros, and %% those should be retained. Or, is there already a function to %% strip a buffer in the manner that string.strip does a string? \setupwhitespace[none] \setupindenting[none] \define\Mark{\color[middlegray]{\itb¿\ }} \define\First{nothing yet} \define\Arg{nothing yet} \setuplanguage[en][spacing=packed] \starttexdefinition unexpanded startBufTest \bgroup \dosingleempty\dostartBufTest \stoptexdefinition \starttexdefinition dostartBufTest [#SETUPS] \doifsomethingelse{#{SETUPS}} {\define\Arg{yes}} {\define\Arg{no}} \iffirstargument \define\First{yes} \else \define\First{no} \fi \relax \getrawparameters[BufTest][xx=yy,#SETUPS] \grabbufferdata[TestBuffer][startBufTest][stopBufTest] \stoptexdefinition \starttexdefinition stopBufTest \startparagraph \dontleavehmode\llap{\Mark}\inlinebuffer[TestBuffer] \ (first: \First, arg: \Arg) \stopparagraph \egroup \stoptexdefinition \starttext \startparagraph A starting paragraph. \stopparagraph \startBufTest Buffer without blank lines. \stopBufTest \startparagraph An intervening paragraph. \stopparagraph \startBufTest Buffer with blank lines. \stopBufTest \startparagraph An intervening paragraph. \stopparagraph \startBufTest\relax Buffer with \tex{relax}. \stopBufTest \startparagraph An intervening paragraph. \stopparagraph \startBufTest[] Buffer with \type{[]}. \stopBufTest \startparagraph An intervening paragraph. \stopparagraph \startBufTest[key=value] Buffer with \type{[key=value]}. \stopBufTest \startparagraph A closing paragraph. \stopparagraph \stoptext \stopmode Perhaps \ignorespaces might work, but I often find that the conceptually simplest solution is to post-process the buffer at the lua end. See http://wiki.contextgarden.net/Programming_in_LuaTeX#Manipulating_verbatim_text for an example. 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
[NTG-context] How can I remove a blank leading line from a buffer
%% How can one remove blank lines at the start of a buffer so that %% commands that grab a buffer can be used in the same way as, for %% example, \startparagraph...\stopparagraph, which allow blank %% lines around the content? %% %% The problem appears when an optional argument is allowed but none %% is provided. Adding \relax does not help; adding empty brackets %% does. I see no way to distinguish between a buffer without %% leading blank lines and a buffer that was created when brackets %% are provided. %% %% \inlinebuffer handles the leading blank lines when there is %% nothing prepended, but I need to prepend. (It also handles the %% unwanted trailing line, but that is not an issue here). %% %% How can I unpack the buffer, apply the equivalent functions of %% ignorespaspaces and removeunwantedspaces to it, and repack it? %% The buffer may contain internal blank lines and macros, and %% those should be retained. Or, is there already a function to %% strip a buffer in the manner that string.strip does a string? \setupwhitespace[none] \setupindenting[none] \define\Mark{\color[middlegray]{\itb¿\ }} \define\First{nothing yet} \define\Arg{nothing yet} \setuplanguage[en][spacing=packed] \starttexdefinition unexpanded startBufTest \bgroup \dosingleempty\dostartBufTest \stoptexdefinition \starttexdefinition dostartBufTest [#SETUPS] \doifsomethingelse{#{SETUPS}} {\define\Arg{yes}} {\define\Arg{no}} \iffirstargument \define\First{yes} \else \define\First{no} \fi \relax \getrawparameters[BufTest][xx=yy,#SETUPS] \grabbufferdata[TestBuffer][startBufTest][stopBufTest] \stoptexdefinition \starttexdefinition stopBufTest \startparagraph \dontleavehmode\llap{\Mark}\inlinebuffer[TestBuffer] \ (first: \First, arg: \Arg) \stopparagraph \egroup \stoptexdefinition \starttext \startparagraph A starting paragraph. \stopparagraph \startBufTest Buffer without blank lines. \stopBufTest \startparagraph An intervening paragraph. \stopparagraph \startBufTest Buffer with blank lines. \stopBufTest \startparagraph An intervening paragraph. \stopparagraph \startBufTest\relax Buffer with \tex{relax}. \stopBufTest \startparagraph An intervening paragraph. \stopparagraph \startBufTest[] Buffer with \type{[]}. \stopBufTest \startparagraph An intervening paragraph. \stopparagraph \startBufTest[key=value] Buffer with \type{[key=value]}. \stopBufTest \startparagraph A closing paragraph. \stopparagraph \stoptext \stopmode %% -- %% Rik Kabel ___ 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] Parallel output of source data
Hello Wolfgang, On Tue, 03 Jul 2018 09:07:23 +0200, Wolfgang Schuster wrote: Hi Lukas, when you create the buffer with the grabbufferdata-command you already set the delimiter for the environment with the third argument, in the example below this is the \stopcontentexport command. To have different start/stop-commands for your environment means you have to change all names in the implementation of the contentxport-environment. %% \unexpanded\def\bH{} \def\dobH[#1]% {... \grabbufferdata[...][bH][eH]} \def\eH {} %% thank you for the explanation! - Much clearer for me how buffers work! Best regards, Lukas Wolfgang Procházka Lukáš Ing. <mailto:l...@pontex.cz> 3. Juli 2018 um 08:52 Hello, I tried to \let shortcuts for \startcontentexport and \stopcontentexport, but Ctx run fails. I guess this is a basic misunderstanding, but - why? \unexpanded\def\startcontentexport{\dosingleempty\dostartcontentexport} \def\dostartcontentexport[#1]% {\iffirstargument \edef\contentexportfile{#1}% \else \let\contentexportfile\empty \fi \grabbufferdata[contentexport][startcontentexport][stopcontentexport] } \def\stopcontentexport{% \doifsomething{\contentexportfile}{\savebuffer[list=contentexport,prefix=no,file=\contentexportfile]}% \getbufferdata[contentexport] } \let\bX=\startcontentexport % < Use of these two "shortcuts" is not possible, \let\eX=\stopcontentexport % < I'm getting : ! TeX capacity exceeded, sorry [input stack size=1] \starttext A \startcontentexport[t~.out.mkiv] Hello! \startitemize \item Item \stopitemize \stopcontentexport B \bX[t2~.out.mkiv] Ahoj \eX \stoptext HSo how to define "shortcuts" properly? Best regards, Lukas -- Ing. Lukáš Procházka | mailto:l...@pontex.cz Pontex s. r. o. | mailto:pon...@pontex.cz | http://www.pontex.cz | IDDS:nrpt3sn Bezová 1658 147 14 Praha 4 Mob.: +420 702 033 396 ___ 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] Parallel output of source data
On 7/3/2018 8:52 AM, Procházka Lukáš Ing. wrote: Hello, I tried to \let shortcuts for \startcontentexport and \stopcontentexport, but Ctx run fails. I guess this is a basic misunderstanding, but - why? \unexpanded\def\startcontentexport{\dosingleempty\dostartcontentexport} \def\dostartcontentexport[#1]% {\iffirstargument \edef\contentexportfile{#1}% \else \let\contentexportfile\empty \fi \grabbufferdata[contentexport][startcontentexport][stopcontentexport] } \def\stopcontentexport{% \doifsomething{\contentexportfile}{\savebuffer[list=contentexport,prefix=no,file=\contentexportfile]}% \getbufferdata[contentexport] } \let\bX=\startcontentexport % < Use of these two "shortcuts" is not possible, \let\eX=\stopcontentexport % < I'm getting : ! TeX capacity exceeded, sorry [input stack size=1] \starttext A \startcontentexport[t~.out.mkiv] Hello! \startitemize \item Item \stopitemize \stopcontentexport B \bX[t2~.out.mkiv] Ahoj \eX \stoptext HSo how to define "shortcuts" properly? impossible ... just define an extra grabbuffer what has this to do with parallel texts 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] Parallel output of source data
Hi Lukas, when you create the buffer with the grabbufferdata-command you already set the delimiter for the environment with the third argument, in the example below this is the \stopcontentexport command. To have different start/stop-commands for your environment means you have to change all names in the implementation of the contentxport-environment. %% \unexpanded\def\bH{} \def\dobH[#1]% {... \grabbufferdata[...][bH][eH]} \def\eH {} %% Wolfgang Procházka Lukáš Ing. <mailto:l...@pontex.cz> 3. Juli 2018 um 08:52 Hello, I tried to \let shortcuts for \startcontentexport and \stopcontentexport, but Ctx run fails. I guess this is a basic misunderstanding, but - why? \unexpanded\def\startcontentexport{\dosingleempty\dostartcontentexport} \def\dostartcontentexport[#1]% {\iffirstargument \edef\contentexportfile{#1}% \else \let\contentexportfile\empty \fi \grabbufferdata[contentexport][startcontentexport][stopcontentexport] } \def\stopcontentexport{% \doifsomething{\contentexportfile}{\savebuffer[list=contentexport,prefix=no,file=\contentexportfile]}% \getbufferdata[contentexport] } \let\bX=\startcontentexport % < Use of these two "shortcuts" is not possible, \let\eX=\stopcontentexport % < I'm getting : ! TeX capacity exceeded, sorry [input stack size=1] \starttext A \startcontentexport[t~.out.mkiv] Hello! \startitemize \item Item \stopitemize \stopcontentexport B \bX[t2~.out.mkiv] Ahoj \eX \stoptext HSo how to define "shortcuts" properly? Best regards, Lukas ___ 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 ___ ___ 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] Parallel output of source data
Hello, I tried to \let shortcuts for \startcontentexport and \stopcontentexport, but Ctx run fails. I guess this is a basic misunderstanding, but - why? \unexpanded\def\startcontentexport{\dosingleempty\dostartcontentexport} \def\dostartcontentexport[#1]% {\iffirstargument \edef\contentexportfile{#1}% \else \let\contentexportfile\empty \fi \grabbufferdata[contentexport][startcontentexport][stopcontentexport] } \def\stopcontentexport{% \doifsomething{\contentexportfile}{\savebuffer[list=contentexport,prefix=no,file=\contentexportfile]}% \getbufferdata[contentexport] } \let\bX=\startcontentexport % < Use of these two "shortcuts" is not possible, \let\eX=\stopcontentexport % < I'm getting : ! TeX capacity exceeded, sorry [input stack size=1] \starttext A \startcontentexport[t~.out.mkiv] Hello! \startitemize \item Item \stopitemize \stopcontentexport B \bX[t2~.out.mkiv] Ahoj \eX \stoptext HSo how to define "shortcuts" properly? Best regards, Lukas -- Ing. Lukáš Procházka | mailto:l...@pontex.cz Pontex s. r. o. | mailto:pon...@pontex.cz | http://www.pontex.cz | IDDS:nrpt3sn Bezová 1658 147 14 Praha 4 Mob.: +420 702 033 396 t.mkiv Description: Binary data ___ 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] Problem defining macro with Lua inside
... Great, thank you! Lukas On Wed, 30 May 2018 13:47:12 +0200, Henri Menke wrote: On 05/30/2018 08:19 PM, Procházka Lukáš Ing. wrote: Hello, I'm trying to define a macro (a MS Word -> clipboard -> Ctx tool), whose simplified form is the following: This cannot work \startluacode has to “see” \stopluacode. Use buffers: \unexpanded\def\startWord {\grabbufferdata[Word][startWord][stopWord]} \unexpanded\def\stopWord {\startluacode print(buffers.prepend("Word","context[[")) print(buffers.append("Word","]]")) \stopluacode \ctxluabuffer[Word]} \starttext \startWord abc def ghi \stopWord \stoptext \def\startWord{% \startluacode context[[ } \def\stopWord{% ]] \stopluacode } \starttext aaa \startWord abc def ghi \stopWord \stoptext Unfortunately, I'm not able to define \startWord and \stopWord in a way that Ctx would accept. How to define it? Any help would be appreciated. Best regards, Lukas -- Ing. Lukáš Procházka | mailto:l...@pontex.cz Pontex s. r. o. | mailto:pon...@pontex.cz | http://www.pontex.cz | IDDS:nrpt3sn Bezová 1658 147 14 Praha 4 Mob.: +420 702 033 396 ___ 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] Problem defining macro with Lua inside
On 05/30/2018 08:19 PM, Procházka Lukáš Ing. wrote: > Hello, > > I'm trying to define a macro (a MS Word -> clipboard -> Ctx tool), whose > simplified form is the following: > This cannot work \startluacode has to “see” \stopluacode. Use buffers: \unexpanded\def\startWord {\grabbufferdata[Word][startWord][stopWord]} \unexpanded\def\stopWord {\startluacode print(buffers.prepend("Word","context[[")) print(buffers.append("Word","]]")) \stopluacode \ctxluabuffer[Word]} \starttext \startWord abc def ghi \stopWord \stoptext > > \def\startWord{% > \startluacode > context[[ > } > > \def\stopWord{% > ]] > \stopluacode > } > > \starttext > aaa > > \startWord > abc > def > > ghi > \stopWord > \stoptext > > > Unfortunately, I'm not able to define \startWord and \stopWord in a way > that Ctx would accept. > > How to define it? > > Any help would be appreciated. > > Best regards, > > Lukas > > > > > ___ > 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 > ___ > ___ 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] Problem with Filter Module in latent context beta
On Tue, 17 Apr 2018, Aditya Mahajan wrote: On Tue, 17 Apr 2018, Hans Hagen wrote: On 4/17/2018 12:01 AM, Aditya Mahajan wrote: All features of the filter and vim modules work with the latest beta, except for one final bug: leading spaces are stripped from the buffer. \starttext \startbuffer[test] Leading spaces \stopbuffer \savebuffer[file=test-temp.tmp, prefix=no, list=test] \stoptext The leading spaces are stripped before the buffer is saved to the file temp.tmp. Is it possible for the leading space NOT to be stripped? (If not, I'll just document this as a feature :-). \samplefile{ward} \startnarrower \samplefile{ward} \startbuffer[test] Leading spaces And some more \stopbuffer \typebuffer[test] \stopnarrower \samplefile{ward} \startbuffer[test] Leading spaces And some more \stopbuffer \typebuffer[test] it is actually a feature to align the left edge relative to the least indented so that we can use them inside other constructs Now, as you're not afraid of low level code: \unprotect \unexpanded\def\StartAditya {\buff_pickup {Aditya}% {StartAditya}% {StopAditya}% {}% {\savebuffer[file=test-temp.tmp,prefix=no,list=Aditya]}% \zerocount} This is perfect as I am already using `\grabbufferdata` in my code. I can easily adapt it to use `\buff_pickup` instead. Thanks!. Does what you want but of course it's sort of ugly for a module to do that. What we can do is this which is still ugly but picking up verbatim is always ugly: \def\buff_start_indeed#1#2#3#4% {\edef\p_strip{\namedbufferparameter{#1}\c!strip}% \normalexpanded{\buff_pickup{#2}{#3}{#4}{}{\buff_stop{#4}}\ifx\p_strip\v!no\zerocount\else\plusone\fi}} \protect I want this to be configurable at runtime and the vim module already has code that enables `strip=yes` and `strip=no` options (I do this via a function in vim so that it works with both mkii and mkiv; although I don't think that anyone uses the mkii module any longer). I added `strip=yes` option to the filter module, which is now the default option. See "Stripping leading whitespace" in the module documentation (https://github.com/adityam/filter). This is a MkIV only feature and I will not implement it in MkII. I also made `strip=yes` to be the default in t-vim (to be consistent with t-filter). In t-vim, the `strip` option works with both mkii and mkiv. 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] Problem with Filter Module in latent context beta
On Tue, 17 Apr 2018, Hans Hagen wrote: On 4/17/2018 12:01 AM, Aditya Mahajan wrote: All features of the filter and vim modules work with the latest beta, except for one final bug: leading spaces are stripped from the buffer. \starttext \startbuffer[test] Leading spaces \stopbuffer \savebuffer[file=test-temp.tmp, prefix=no, list=test] \stoptext The leading spaces are stripped before the buffer is saved to the file temp.tmp. Is it possible for the leading space NOT to be stripped? (If not, I'll just document this as a feature :-). \samplefile{ward} \startnarrower \samplefile{ward} \startbuffer[test] Leading spaces And some more \stopbuffer \typebuffer[test] \stopnarrower \samplefile{ward} \startbuffer[test] Leading spaces And some more \stopbuffer \typebuffer[test] it is actually a feature to align the left edge relative to the least indented so that we can use them inside other constructs Now, as you're not afraid of low level code: \unprotect \unexpanded\def\StartAditya {\buff_pickup {Aditya}% {StartAditya}% {StopAditya}% {}% {\savebuffer[file=test-temp.tmp,prefix=no,list=Aditya]}% \zerocount} This is perfect as I am already using `\grabbufferdata` in my code. I can easily adapt it to use `\buff_pickup` instead. Thanks!. Does what you want but of course it's sort of ugly for a module to do that. What we can do is this which is still ugly but picking up verbatim is always ugly: \def\buff_start_indeed#1#2#3#4% {\edef\p_strip{\namedbufferparameter{#1}\c!strip}% \normalexpanded{\buff_pickup{#2}{#3}{#4}{}{\buff_stop{#4}}\ifx\p_strip\v!no\zerocount\else\plusone\fi}} \protect I want this to be configurable at runtime and the vim module already has code that enables `strip=yes` and `strip=no` options (I do this via a function in vim so that it works with both mkii and mkiv; although I don't think that anyone uses the mkii module any longer). 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] source code and result side by side
Am 2017-08-04 um 06:30 schrieb Henri Menke <henrime...@gmail.com>: > On 08/04/2017 07:46 AM, Henning Hraban Ramm wrote: >> Am 2017-07-31 um 03:26 schrieb Aditya Mahajan <adit...@umich.edu>: >> >>> You can't do that with buffers. If you need to define your own macros that >>> behave like buffers, you need to use \grabbufferdata (see buff-ini.mkiv). >>> But in this case, there is a simpler solution: >>> >>> \defineframed >>> [CodeExampleFramed] >>> [ >>> frame=off, >>> width=0.5\textwidth, >>> align=normal, >>> ] >>> >>> \definebuffer >>> [CodeExample] >>> >>> \define\stopCodeExample >>> {\placesidebyside >>> {\CodeExampleFramed{\typeCodeExample}} >>> {\CodeExampleFramed{\getCodeExample}}} >> >> Oh, I overlooked something: >> Can I get pretty printing back, like in \startTEX ... \stopTEX? >> >> I couldn’t find any suitable setup options. > > \typebuffer[whatever][option=tex] \typebuffer[CodeExample][option=tex] doesn’t do anything, but \typeCodeExample[option=tex] actually works, I didn’t expect that. Thank you! Greetlings, Hraban --- http://www.fiee.net http://wiki.contextgarden.net GPG Key ID 1C9B22FD ___ 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] source code and result side by side
Am 2017-07-31 um 03:26 schrieb Aditya Mahajan <adit...@umich.edu>: > You can't do that with buffers. If you need to define your own macros that > behave like buffers, you need to use \grabbufferdata (see buff-ini.mkiv). But > in this case, there is a simpler solution: > > \defineframed > [CodeExampleFramed] > [ >frame=off, >width=0.5\textwidth, >align=normal, > ] > > \definebuffer >[CodeExample] > > \define\stopCodeExample >{\placesidebyside > {\CodeExampleFramed{\typeCodeExample}} > {\CodeExampleFramed{\getCodeExample}}} Oh, I overlooked something: Can I get pretty printing back, like in \startTEX ... \stopTEX? I couldn’t find any suitable setup options. This doesn’t work: \setupbuffer[CodeExampleB][before={\startTEX},after={\stopTEX}] Greetlings, Hraban --- http://www.fiee.net http://wiki.contextgarden.net GPG Key ID 1C9B22FD ___ 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] source code and result side by side
Am 2017-07-31 um 03:26 schrieb Aditya Mahajan <adit...@umich.edu>: > You can't do that with buffers. If you need to define your own macros that > behave like buffers, you need to use \grabbufferdata (see buff-ini.mkiv). But > in this case, there is a simpler solution: Thank you very much, I can work with that. A related question: How can I use commands like \chapter{} in an example without affecting my main structure? I’d like to show a few examples für head setups. Greetlings, Hraban --- http://www.fiee.net http://wiki.contextgarden.net GPG Key ID 1C9B22FD ___ 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] source code and result side by side
On Sun, 30 Jul 2017, Henning Hraban Ramm wrote: Am 2017-07-29 um 00:57 schrieb Aditya Mahajan <adit...@umich.edu>: On Fri, 28 Jul 2017, Henning Hraban Ramm wrote: Ahoi again, I’m preparing some ConTeXt docs with a lot of examples and would like to reproduce what we have in the wiki as ... i.e. sourcecode beside the result. Often the shown source is exactly what I want to show, in other cases I need some additional setup that I don’t want to show. Which approach would you suggest? Combinations? \startbuffer[example-1] \stopbuffer \placesidebyside {\typebuffer[example-1]} {\getbuffer[setups, example-1]} Thank you again, that should be enough for most of my small examples. I guess I never heard of or forgot about \placesidebyside as well as \placeontopofeachother. But I’d like to show a lot of similar examples to explain several options. Therefore, if I’d like to simplify my code, but this doesn’t work: \def\CodeExample#1{% \startbuffer[zB] #1 \stopbuffer \typebuffer[zB] \getbuffer[zB] } \CodeExample{\framed[frame=off,leftframe=on,rulethickness=1em,framecolor=blue]{Klotz am Bein}} You can't do that with buffers. If you need to define your own macros that behave like buffers, you need to use \grabbufferdata (see buff-ini.mkiv). But in this case, there is a simpler solution: \defineframed [CodeExampleFramed] [ frame=off, width=0.5\textwidth, align=normal, ] \definebuffer [CodeExample] \define\stopCodeExample {\placesidebyside {\CodeExampleFramed{\typeCodeExample}} {\CodeExampleFramed{\getCodeExample}}} \starttext \startCodeExample \framed [ frame=off, leftframe=on, rulethickness=1em, framecolor=blue, ]{Klotz am Bein} \stopCodeExample \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 ___
[NTG-context] How do I insert characters before \par
ConTeXters, I am stymied trying to insert characters into a buffer, or failing that, to back up, removing the \par, and adding characters after the buffer is loaded. The code I am working with reduces to this: 1. % macros=mkvi engine=luajittex 2. \starttexdefinition unexpanded startABC 3.\begingroup 4.\dosingleempty\dostartABC 5. \stoptexdefinition 6. \starttexdefinition dostartABC [#SETUPS] 7. \getrawparameters[ABC][inset=2em,#SETUPS] 8. \grabbufferdata[bu:ABC][startABC][stopABC] 9. \stoptexdefinition 10. \starttexdefinition stopABC 11. \setupnarrower[left=\ABCinset] 12. \startnarrower[left,right] 13.\startlines 14. (\,\inlinebuffer[bu:ABC]\,) 15.\stoplines 16. \stopnarrower 17.\endgroup 18. \stoptexdefinition 19. \starttext 20. \startsubject[title={Test of ABC}] 21. \startABC[inset=5em] 22.“Hope” is the thing with feathers\,— 23. That perches in the soul\,— 24. And sings the tune without the words\,— 25. And never stops\,—\,at all\,— 26. \stopABC 27. \startABC 28. ABCDEFG 29. \stopABC 30. \stoptext In line 14, I prefix the buffer with(\, but\,) ends up on another line, after the \par inserted at the end of the buffer. Inlining a second buffer which contains the closing bits with (\inlinebuffer[a,b]) does the same. Can somebody suggest a path? --- Rik ___ 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] \savebuffer to merge of save contents
Hello ConTeXist. Is there any possibility or modifications that will allow to savebuffer to work, so that will add (merge) the buffer contents into a file (Which content of the previous buffer)? For inspiration, it is possible use a solution that wrote before year ago Wolfgang for Lukas Prochazka – ie https://mailman.ntg.nl/pipermail/ntg-context/2016/087657.html Thanx Jaroslav Hajtmar Here is source code of Wolfgangs solution: \unexpanded\def\startcontentexport {\dosingleempty\dostartcontentexport} \def\dostartcontentexport[#1]% {\iffirstargument \edef\contentexportfile{#1}% \else \let\contentexportfile\empty \fi \grabbufferdata[contentexport][startcontentexport][stopcontentexport]} \def\stopcontentexport {\doifsomething{\contentexportfile}{\savebuffer[list=contentexport,prefix=no,file=\contentexportfile]}% \getbufferdata[contentexport]} \starttext A \startcontentexport[Test.mkiv] Basic content … \startitemize \item Item \stopitemize \stopcontentexport B \startcontentexport[Test.mkiv] Add this text into Test.mkiv file \startitemize \item Item \stopitemize \stopcontentexport C \startcontentexport[Test.mkiv] And this text add into Test.mkiv file too. \startitemize \item Item \stopitemize \stopcontentexport \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] Parallel output of source data
Great, that's it! Thank you. Best regards, Lukas On Fri, 02 Dec 2016 20:04:56 +0100, Wolfgang Schuster <schuster.wolfg...@gmail.com> wrote: Procházka Lukáš Ing. <mailto:l...@pontex.cz> 2. Dezember 2016 um 08:10 Hello, is there a way to let ConTeXt to flush the input stream in parallel into an output buffer, like: \starttext A \startoutput{Test.mkiv} Hello! \startitemize \item Item \stopitemize \stopoutput B \stoptext which would produce: Test.mkiv Hello! \startitemize \item Item \stopitemize You can use a buffer to store content and save it in a external file. \unexpanded\def\startcontentexport {\dosingleempty\dostartcontentexport} \def\dostartcontentexport[#1]% {\iffirstargument \edef\contentexportfile{#1}% \else \let\contentexportfile\empty \fi \grabbufferdata[contentexport][startcontentexport][stopcontentexport]} \def\stopcontentexport {\doifsomething{\contentexportfile}{\savebuffer[list=contentexport,prefix=no,file=\contentexportfile]}% \getbufferdata[contentexport]} \starttext A \startcontentexport[Test.mkiv] Hello! \startitemize \item Item \stopitemize \stopcontentexport B \stoptext Wolfgang -- Ing. Lukáš Procházka | mailto:l...@pontex.cz Pontex s. r. o. | mailto:pon...@pontex.cz | http://www.pontex.cz | IDDS:nrpt3sn Bezová 1658 147 14 Praha 4 Tel: +420 241 096 751 (+420 720 951 172) 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] Parallel output of source data
Procházka Lukáš Ing. <mailto:l...@pontex.cz> 2. Dezember 2016 um 08:10 Hello, is there a way to let ConTeXt to flush the input stream in parallel into an output buffer, like: \starttext A \startoutput{Test.mkiv} Hello! \startitemize \item Item \stopitemize \stopoutput B \stoptext which would produce: Test.mkiv Hello! \startitemize \item Item \stopitemize You can use a buffer to store content and save it in a external file. \unexpanded\def\startcontentexport {\dosingleempty\dostartcontentexport} \def\dostartcontentexport[#1]% {\iffirstargument \edef\contentexportfile{#1}% \else \let\contentexportfile\empty \fi \grabbufferdata[contentexport][startcontentexport][stopcontentexport]} \def\stopcontentexport {\doifsomething{\contentexportfile}{\savebuffer[list=contentexport,prefix=no,file=\contentexportfile]}% \getbufferdata[contentexport]} \starttext A \startcontentexport[Test.mkiv] Hello! \startitemize \item Item \stopitemize \stopcontentexport B \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 ___
Re: [NTG-context] User-Defined Commands With Key-Value Options
On 2015-07-22 05:20, Joas Yannick wrote: On 7/20/2105 11:28 AM Joas Yannick wrote: On 7/20/2105 0:50 AM Hans Hagen wrote: So how would you like to use lua? Is the data stored in lua? Yes, I imagine that the data (for instance, the value of the keys number, name, abbreviation, title, etc.) is stored somewhere when the compilation process reads, say, \startbiblebook, and that they are available to define the the formatting done by \startbiblebook. Thank you. I have found this wiki: http://wiki.contextgarden.net/Commands_with_KeyVal_arguments But since I do not know Lua, I would appreciate that someone gets me started with my example. Joas, Perhaps there some confusion here about how ConTeXt is used to create a document, and what role Lua plays in it. ConTeXt is a macro-based language that provides a level of abstraction over TeX, which is also a macro language. Documents can be completely specified with the use of ConTeXt. Lua is a traditional programming language that is used by some versions of ConTeXt to optimize and extend some of the internal capabilities of ConTeXt and TeX. There are very few situations, if any, in which a document writer /must/ resort to using Lua; ConTeXt almost always suffices. Only the first example you found in the ConTeXt wiki uses Lua, and that example is not really useful for your problem. The other examples on that page are coded in the ConTeXt macro language. You might also look at http://wiki.contextgarden.net/System_Macros/Handling_Arguments and http://wiki.contextgarden.net/Commands_with_optional_arguments for more examples, and on the mailing list. I would also recommend looking in the mailing list for discussions of the \getrawparameters and \getbufferdata and related commands (in particular http://www.mail-archive.com/ntg-context%40ntg.nl/msg78808.html). Here is some code I use to format verse. It provides default values for the language, margin inset and continuation line indents that can be overridden when needed: \starttexdefinition unexpanded startPoem \begingroup \dosingleempty\dostartPoem \stoptexdefinition \starttexdefinition dostartPoem [#SETUPS] \getrawparameters[Poem][inset=2em,indent=0em,before=,font=, language=en,#SETUPS] \grabbufferdata[Poem][startPoem][stopPoem] \stoptexdefinition \starttexdefinition stopPoem \obeylines \language[\Poemlanguage] \Poembefore \Poemfont \setupnarrower[left={\dimexpr\Poemindent+\Poeminset\relax}, right=\Poeminset, before=] \startnarrower[left,right] \startparagraph \setupindenting[-\Poemindent,yes] \inlinebuffer[Poem] \stopparagraph \stopnarrower \endgroup \blank[halfline] \stoptexdefinition This type of code can easily be used to deal with the names, numbers, and abbreviations you describe in your requirements. -- Rik Kabel ___ 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] How to define a new environment / function?
Dr. Thomas Möbius mailto:kont...@thomasmoebius.de 17. Juni 2015 15:23 Dear list, having used ConTeXt for years now, I am the first time in need to, well, programming something. And I realised, I am a little bit lost. I have a rather long list of variable descriptions that I would like to typeset in a usable and readable way. It should look something like this: ---snip: minimal example--- \starttext \setupdelimitedtext[blockquote] {{\bf Geschlecht} \qquad Geschlecht \hfill $0,1$} \startblockquote Das Geschlecht des Probanden. \stopblockquote \blank {{\bf SoB} \qquad Geburtssaison \hfill $1,\dots,4$} \startblockquote Jahreszeit der Geburt. Kodierung: 1 = Winter, 2 = Frühling, 3 = Sommer, 4 = Herbst. \stopblockquote \blank {{\bf BildungV} \qquad Bildung Vater \hfill $1,\dots,6$} \startblockquote Ordinale Beschreibung der Bildung des Vaters zum Zeitpunkt der Erhebung. Kodierung: 0 = kein Abschluss, 1 = Volksschule, 2 = Hauptschule, 3 = Realschule, 4 = Fachabitur, 5 = Abitur, 6 = Studium. \stopblockquote \blank {{\bf BildungM} \qquad Bildung Mutter \hfill $1,\dots,6$} \startblockquote Ordinale Beschreibung der Bildung der Mutter zum Zeitpunkt der Erhebung. Kodierung siehe {\bf BildungV}. \stopblockquote \blank {{\bf Urb15} \qquad Urbanität \hfill $\naturalnumbers$} \startblockquote Beschreibung der Urbanität des Umfelds in den ersten 15 Lebensjahren. Kodierung: $\sum_{i=1}^{15} u_i$ mit $u_i=$ ein Punkt für eine Stadt bis 10.000 Einwohner, 2 Punkte für bis 100.000 Einwohner, 3 Punkte über 100.000 Einwohner im Jahr $i$. \stopblockquote \blank {{\bf LQ} \qquad Händigkeit \hfill $(0,1)$} \startblockquote Lateralisierungsquotient, wobei -1 = perfekt linkshändig und +1 = perfekt rechtshändig. \stopblockquote \stoptext ---end snip--- What I would like to have is a function/environment/something that would allow me to write the above text in the following way: ---snip: want to example--- \starttext \startvariable [alias=Geschlecht, name=Geschlecht, range={$0,1$}] Das Geschlecht des Probanden. \stopvariable \startvariable [alias=SoB, name=Geburtssaison, range={$1,\dots,4$}] Jahreszeit der Geburt. Kodierung: 1 = Winter, 2 = Frühling, 3 = Sommer, 4 = Herbst. \stopvariable \startvariable [alias=BildungV, name={Bildung Vater}, range={$1,\dots,6$}, reference=bildungDesVater] Ordinale Beschreibung der Bildung des Vaters zum Zeitpunkt der Erhebung. Kodierung: 0 = kein Abschluss, 1 = Volksschule, 2 = Hauptschule, 3 = Realschule, 4 = Fachabitur, 5 = Abitur, 6 = Studium. \stopvariable \startvariable [alias=BildungM, name={Bildung Mutter}, range={$1,\dots,6$}] Ordinale Beschreibung der Bildung der Mutter zum Zeitpunkt der Erhebung. Kodierung siehe \in[bildungDesVater]. \stopvariable \startvariable [alias=Urb15, name=Urbanität, range={$\naturalnumbers$}] Beschreibung der Urbanität des Umfelds in den ersten 15 Lebensjahren. Kodierung: $\sum_{i=1}^{15} u_i$ mit $u_i=$ ein Punkt für eine Stadt bis 10.000 Einwohner, 2 Punkte für bis 100.000 Einwohner, 3 Punkte über 100.000 Einwohner im Jahr $i$. \startvariable [alias=LQ, name=Händigkeit, range={$(0,1)$}] Lateralisierungsquotient, wobei -1 = perfekt linkshändig und +1 = perfekt rechtshändig. \stopvariable \stoptext ---end snip--- Could someone point me in the right direction, or get me started somehow? Is this difficult to accomplish? Or is it super easy and I just don't know it? The code below does what you want. \def\startvariable {\begingroup \dosingleempty\dostartvariable} \def\dostartvariable[#1]% {\getrawparameters[variable][alias=,name=,range=,reference=,#1]% \grabbufferdata[variable][startvariable][stopvariable]} \def\stopvariable {\directsetup{variable:content}% \endgroup} \startsetups[variable:content] \startlinealignment[middle] \variablealias \qquad \variablename \hfill \variablerange \doifsomething{\variablereference}{\expanded{\reference[\variablereference]{\variablealias}}} \stoplinealignment \startblockquote \getbufferdata[variable] \stopblockquote \stopsetups \starttext \startvariable [alias=Geschlecht, name=Geschlecht, range={$0,1$}] Das Geschlecht des Probanden. \stopvariable \startvariable [alias=SoB, name=Geburtssaison, range={$1,\dots,4$}] Jahreszeit der Geburt. Kodierung: 1 = Winter, 2 = Frühling, 3 = Sommer, 4 = Herbst. \stopvariable \startvariable [alias=BildungV, name={Bildung Vater}, range={$1,\dots,6$},reference=bildungDesVater] Ordinale Beschreibung der Bildung des Vaters zum Zeitpunkt der Erhebung. Kodierung: 0 = kein Abschluss, 1 = Volksschule, 2 = Hauptschule, 3 = Realschule, 4 = Fachabitur, 5 = Abitur, 6 = Studium. \stopvariable \startvariable [alias=BildungM, name={Bildung Mutter}, range={$1,\dots,6$}] Ordinale Beschreibung der Bildung der Mutter zum Zeitpunkt der Erhebung. Kodierung siehe \in[bildungDesVater]. \stopvariable \startvariable [alias=Urb15, name=Urbanität, range={$\naturalnumbers$}] Beschreibung der
Re: [NTG-context] vertical spacing and makeups
On 04/19/2015 08:50 PM, Wolfgang Schuster wrote: Am 18.04.2015 um 20:29 schrieb Pablo Rodriguez: [...] So the a workaround would be to use \blank instead of \par or a blank line, wouldn’t it be? You can flush the content of the buffer in a \vbox where you set the whitespace at the begin of the box. \def\startSlide {\grabbufferdata[SlideContent][startSlide][stopSlide]} \def\stopSlide {\startmakeup[standard][align=middle] \vbox\bgroup \setupwhitespace[big] \begstrut\getbufferdata[SlideContent]\endstrut \egroup \stopmakeup} Many thanks for your reply, Wolfgang. This is exactly what I needed. 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] vertical spacing and makeups
Am 18.04.2015 um 20:29 schrieb Pablo Rodriguez oi...@gmx.es: On 04/18/2015 07:15 PM, Wolfgang Schuster wrote: Am 18.04.2015 um 18:43 schrieb Pablo Rodriguez: [...] The first page shows that \setupwhitespace[big] affects to a single line in a makeup. Shouldn’t white space be added only between paragraphs? The second page is right vertically centered. And the third page shows that the white space isn’t added before the first paragraph in a normal page (no makeup). This is the first issue, isn’t it a bug? Or what am I missing? TeX inserts the \parskip value which is set by \setupwhitespace before your text in the makeup environment. Note that this happens only when you have skip before the text (e.g. with the default top=\vss setting) at the begin of the environment. The following low level example demonstrates this: \setuppapersize[A6] \starttext \dontleavehmode \ruledvbox to 3cm{\hsize=4cm text} \ruledvbox to 3cm{\hsize=4cm\parskip=2ex\relax text} \dontleavehmode \ruledvbox to 3cm{\hsize=4cm\vss text\vss} \ruledvbox to 3cm{\hsize=4cm\parskip=2ex\relax\vss text\vss} \stoptext Many thanks for your reply, Wolfgang. So the a workaround would be to use \blank instead of \par or a blank line, wouldn’t it be? You can flush the content of the buffer in a \vbox where you set the whitespace at the begin of the box. \def\startSlide {\grabbufferdata[SlideContent][startSlide][stopSlide]} \def\stopSlide {\startmakeup[standard][align=middle] \vbox\bgroup \setupwhitespace[big] \begstrut\getbufferdata[SlideContent]\endstrut \egroup \stopmakeup} \setuppapersize[S8] %\setupbodyfont[100pt] \showgrid \starttext \startSlide program content \stopSlide \startSlide descender \stopSlide \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 ___
Re: [NTG-context] vertical spacing and makeups
On 04/18/2015 07:15 PM, Wolfgang Schuster wrote: Am 18.04.2015 um 18:43 schrieb Pablo Rodriguez: [...] The first page shows that \setupwhitespace[big] affects to a single line in a makeup. Shouldn’t white space be added only between paragraphs? The second page is right vertically centered. And the third page shows that the white space isn’t added before the first paragraph in a normal page (no makeup). This is the first issue, isn’t it a bug? Or what am I missing? TeX inserts the \parskip value which is set by \setupwhitespace before your text in the makeup environment. Note that this happens only when you have skip before the text (e.g. with the default top=\vss setting) at the begin of the environment. The following low level example demonstrates this: \setuppapersize[A6] \starttext \dontleavehmode \ruledvbox to 3cm{\hsize=4cm text} \ruledvbox to 3cm{\hsize=4cm\parskip=2ex\relax text} \dontleavehmode \ruledvbox to 3cm{\hsize=4cm\vss text\vss} \ruledvbox to 3cm{\hsize=4cm\parskip=2ex\relax\vss text\vss} \stoptext Many thanks for your reply, Wolfgang. So the a workaround would be to use \blank instead of \par or a blank line, wouldn’t it be? The second issue is about the line height. If I didn’t get it wrong from Hans some days ago, line height is the x-height, plus ascender and descender heights. TeX has only a concept for the distance between the baseline of two lines, to get a certain line height and depth at the begin and end of your text you have to the \strut or \begstrut and \endstrut commands. \def\startSlide {\grabbufferdata[SlideContent][startSlide][stopSlide]} \def\stopSlide {\startmakeup[standard][align=middle] \begstrut\getbufferdata[SlideContent]\endstrut \stopmakeup} I tried to use struts with the first issue and I thought they didn’t work sith makeups. Many thanks for your code excerpted above. I would have never thought of this in a decade. Many thanks for your highly instructive explanation also, 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] vertical spacing and makeups
Am 18.04.2015 um 18:43 schrieb Pablo Rodriguez oi...@gmx.es: Dear list, I have the following sample: \showgrid \setupinteraction[option=max] \setuppapersize[S6] \setuppagenumbering[location=] \setupbodyfont[100pt] \setupwhitespace[big] \startsetups[setups:slides] \setupwhitespace[big] \stopsetups \setupmakeup[pagestate=start] \definemakeup[slides][setups=setups:slides] \definemakeup[slide] \starttext \startmakeup[slides]\ConTeXt\stopmakeup \startmakeup[slide]\ConTeXt\stopmakeup \page\ConTeXt \startmakeup[slides]program\stopmakeup \startmakeup[slides]descender\stopmakeup \startmakeup[slide]program\stopmakeup \startmakeup[slide]descender\stopmakeup \page program \page descender \stoptext The first page shows that \setupwhitespace[big] affects to a single line in a makeup. Shouldn’t white space be added only between paragraphs? The second page is right vertically centered. And the third page shows that the white space isn’t added before the first paragraph in a normal page (no makeup). This is the first issue, isn’t it a bug? Or what am I missing? TeX inserts the \parskip value which is set by \setupwhitespace before your text in the makeup environment. Note that this happens only when you have skip before the text (e.g. with the default top=\vss setting) at the begin of the environment. The following low level example demonstrates this: \setuppapersize[A6] \starttext \dontleavehmode \ruledvbox to 3cm{\hsize=4cm text} \ruledvbox to 3cm{\hsize=4cm\parskip=2ex\relax text} \dontleavehmode \ruledvbox to 3cm{\hsize=4cm\vss text\vss} \ruledvbox to 3cm{\hsize=4cm\parskip=2ex\relax\vss text\vss} \stoptext The second issue is about the line height. If I didn’t get it wrong from Hans some days ago, line height is the x-height, plus ascender and descender heights. TeX has only a concept for the distance between the baseline of two lines, to get a certain line height and depth at the begin and end of your text you have to the \strut or \begstrut and \endstrut commands. In vertical centering for makeups, why does ascender or descender height affect to basline position? Sorry, but this is a problem for readability. And it think it is better to center the line instead than a group of glyphs. \def\startSlide {\grabbufferdata[SlideContent][startSlide][stopSlide]} \def\stopSlide {\startmakeup[standard][align=middle] \begstrut\getbufferdata[SlideContent]\endstrut \stopmakeup} \setuppapersize[S8] \setupbodyfont[100pt] \showgrid \starttext \startSlide program \stopSlide \startSlide descender \stopSlide \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 ___
Re: [NTG-context] ConTeXt gobble my mind
Hello Wolfgang, thank you very much for all these solutions. Do you have any recommendations about using one over the others ? Currently, the conditional selection of my slides works pretty good : I have created the following macros : \courseSlideList[resavi][1-10,20-30,34,37-40], this macro allows me to activate all the slides given by their number in a list defined in the current file ; \includeSelectionFrom{adressage_groupe_utf8}{1-100} this macro allows me to include some slides given by a list of number from an external file ; \skipSlide that can suppress the process of the following slide. Of course, all of theses macros work beautifully recursively with files using them (the numbering macro work nicely on currently defined slides as included slides). This is why I use only ConTeXt for all my work ! Cheers ! Pierre-François. On 08 Nov 2014, at 12:08, Wolfgang Schuster schuster.wolfg...@gmail.com wrote: Am 08.11.2014 um 00:00 schrieb Pierre-François Bonnefoi bonne...@unilim.fr: Just before going to bed, I've found a solution with all your help and the help of Taco Hoekwater through the ntg mail archive : \def\startSlide% {\def\stopSlide{\checkSlide\doif{\getvariable{temp}{publish}}{yes}{\page\getbuffer[Slide]}}% \dostartbuffer[Slide][startSlide][stopSlide]} Let me know if it's my philosopher's stone... I've tried it and it works so far. No more ugly gobbling, my mind is free. Below are two other methods. Method 1 === \newconditional\SkipSlide \setfalse\SkipSlide \definebuffer[Slide] \def\stopSlide {\ifconditional\SkipSlide \else \page \getbuffer[\thedefinedbuffer{Slide}]% \fi \setfalse\SkipSlide} \starttext \startSlide First Slide \stopSlide \settrue\SkipSlide \startSlide Second Slide \stopSlide \startSlide Third Slide \stopSlide \stoptext Method 2 === \def\startSlide {\dosingleempty\dostartSlide} \def\dostartSlide[#1]% {\doifelse{#1}{-} {\let\stopSlide\stopSlideNop} {\let\stopSlide\stopSlideYes}% \grabbufferdata[Slide][startSlide][stopSlide]} \let\stopSlideNop\relax \def\stopSlideYes {\page \getbuffer[Slide]} \starttext \startSlide First Slide \stopSlide \startSlide[-] Second Slide \stopSlide \startSlide Third Slide \stopSlide \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 ___ -- Bonnefoi Pierre-Francois|E-mail : bonne...@unilim.fr http://libpfb.so/ Universite de Limoges, Laboratoire XLIM | Tel : 06 28 18 03 38 123 av Albert Thomas| Mrs. Peel, we're needed... 87060 Limoges CEDEX - FRANCE| The Avengers. ___ 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] ConTeXt gobble my mind
On 11/9/2014 2:34 PM, Pierre-François Bonnefoi wrote: Hello Wolfgang, thank you very much for all these solutions. Do you have any recommendations about using one over the others ? Currently, the conditional selection of my slides works pretty good : I have created the following macros : \courseSlideList[resavi][1-10,20-30,34,37-40], this macro allows me to activate all the slides given by their number in a list defined in the current file ; \includeSelectionFrom{adressage_groupe_utf8}{1-100} this macro allows me to include some slides given by a list of number from an external file ; \skipSlide that can suppress the process of the following slide. Of course, all of theses macros work beautifully recursively with files using them (the numbering macro work nicely on currently defined slides as included slides). This is why I use only ConTeXt for all my work ! there is also a block mechanism, see blocks in test suite ... originally that was made for a mix of (parallel) questions, answers, anything (numbered and unnumbered), selective filtering by tag etc Hans Cheers ! Pierre-François. On 08 Nov 2014, at 12:08, Wolfgang Schuster schuster.wolfg...@gmail.com mailto:schuster.wolfg...@gmail.com wrote: Am 08.11.2014 um 00:00 schrieb Pierre-François Bonnefoi bonne...@unilim.fr mailto:bonne...@unilim.fr: Just before going to bed, I've found a solution with all your help and the help of Taco Hoekwater through the ntg mail archive : \def\startSlide% {\def\stopSlide{\checkSlide\doif{\getvariable{temp}{publish}}{yes}{\page\getbuffer[Slide]}}% \dostartbuffer[Slide][startSlide][stopSlide]} Let me know if it's my philosopher's stone... I've tried it and it works so far. No more ugly gobbling, my mind is free. Below are two other methods. Method 1 === \newconditional\SkipSlide \setfalse\SkipSlide \definebuffer[Slide] \def\stopSlide {\ifconditional\SkipSlide \else \page \getbuffer[\thedefinedbuffer{Slide}]% \fi \setfalse\SkipSlide} \starttext \startSlide First Slide \stopSlide \settrue\SkipSlide \startSlide Second Slide \stopSlide \startSlide Third Slide \stopSlide \stoptext Method 2 === \def\startSlide {\dosingleempty\dostartSlide} \def\dostartSlide[#1]% {\doifelse{#1}{-} {\let\stopSlide\stopSlideNop} {\let\stopSlide\stopSlideYes}% \grabbufferdata[Slide][startSlide][stopSlide]} \let\stopSlideNop\relax \def\stopSlideYes {\page \getbuffer[Slide]} \starttext \startSlide First Slide \stopSlide \startSlide[-] Second Slide \stopSlide \startSlide Third Slide \stopSlide \stoptext Wolfgang ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl mailto: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 ___ -- Bonnefoi Pierre-Francois|E-mail : bonne...@unilim.fr mailto:bonne...@unilim.fr http://libpfb.so/ Universite de Limoges, Laboratoire XLIM | Tel : 06 28 18 03 38 123 av Albert Thomas| Mrs. Peel, we're needed... 87060 Limoges CEDEX - FRANCE| The Avengers. ___ 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 ___ -- - 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 ___
Re: [NTG-context] ConTeXt gobble my mind
Am 08.11.2014 um 00:00 schrieb Pierre-François Bonnefoi bonne...@unilim.fr: Just before going to bed, I've found a solution with all your help and the help of Taco Hoekwater through the ntg mail archive : \def\startSlide% {\def\stopSlide{\checkSlide\doif{\getvariable{temp}{publish}}{yes}{\page\getbuffer[Slide]}}% \dostartbuffer[Slide][startSlide][stopSlide]} Let me know if it's my philosopher's stone... I've tried it and it works so far. No more ugly gobbling, my mind is free. Below are two other methods. Method 1 === \newconditional\SkipSlide \setfalse\SkipSlide \definebuffer[Slide] \def\stopSlide {\ifconditional\SkipSlide \else \page \getbuffer[\thedefinedbuffer{Slide}]% \fi \setfalse\SkipSlide} \starttext \startSlide First Slide \stopSlide \settrue\SkipSlide \startSlide Second Slide \stopSlide \startSlide Third Slide \stopSlide \stoptext Method 2 === \def\startSlide {\dosingleempty\dostartSlide} \def\dostartSlide[#1]% {\doifelse{#1}{-} {\let\stopSlide\stopSlideNop} {\let\stopSlide\stopSlideYes}% \grabbufferdata[Slide][startSlide][stopSlide]} \let\stopSlideNop\relax \def\stopSlideYes {\page \getbuffer[Slide]} \starttext \startSlide First Slide \stopSlide \startSlide[-] Second Slide \stopSlide \startSlide Third Slide \stopSlide \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] First letter lost possible cause: \grabbfferdata
Recently there have been reports of the first letter of a line of text being lost in the database and letter modules. I tracked down what appears to be the same problem and developed a work-around. The problem appears to be with the \grabbufferdata command. Something has changed in the way it works, and it now swallows the first token of the buffer that it grabs. It may also show up with other commands, but this is the only one I have found in my projects. If you have code with this command, a workaround is to insert \ignorespaces after it. I have no idea why this helps. If you do not have the code (if it is in somebody else's module), then using a blank line or dummy argument or \relax after the command that calls the code with \grabbufferdata may help. The following code shows the issues and these workarounds. % macros=mkvi \starttexdefinition unexpanded startNoIgnore \begingroup \dostartNoIgnore \stoptexdefinition \starttexdefinition dostartNoIgnore \grabbufferdata[Test][startNoIgnore][stopTest] \stoptexdefinition \starttexdefinition unexpanded startWithIgnore \begingroup \dostartWithIgnore \stoptexdefinition \starttexdefinition dostartWithIgnore \grabbufferdata[Test][startWithIgnore][stopTest] \ignorespaces \stoptexdefinition \starttexdefinition stopTest \getbufferdata[Test] \endgroup \stoptexdefinition \define\TestText {\qquad If you can read this the first token was not swallowed.} \starttext \subject{Test without \tex{ignorespaces}} First, the problem: \startNoIgnore\TestText\stopTest And the same with \type{{}} \startWithIgnore{}\TestText\stopTest Workaround with \tex{relax} \startNoIgnore\relax\TestText\stopTest Workaround with blank line \startNoIgnore \TestText\stopTest \subject{Test with \tex{ignorespaces}} This now works: \startWithIgnore\TestText\stopTest And the same with \type{{}} \startWithIgnore{}\TestText\stopTest And the same with \tex{relax} \startWithIgnore\relax\TestText\stopTest And the same with a blank line after the opening \startWithIgnore \TestText\stopTest \stoptext -- Rik Kabel ___ 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] First letter lost possible cause: \grabbfferdata
On 2014-06-25 15:51, Rik Kabel wrote: Recently there have been reports of the first letter of a line of text being lost in the database and letter modules. I tracked down what appears to be the same problem and developed a work-around. The problem appears to be with the \grabbufferdata command. Something has changed in the way it works, and it now swallows the first token of the buffer that it grabs. It may also show up with other commands, but this is the only one I have found in my projects. And as soon as I post, I see that Hans has found the problem in the buffering code. -- Rik Kabel ___ 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] First letter lost possible cause: \grabbfferdata
On 6/25/2014 10:03 PM, Rik Kabel wrote: On 2014-06-25 15:51, Rik Kabel wrote: Recently there have been reports of the first letter of a line of text being lost in the database and letter modules. I tracked down what appears to be the same problem and developed a work-around. The problem appears to be with the \grabbufferdata command. Something has changed in the way it works, and it now swallows the first token of the buffer that it grabs. It may also show up with other commands, but this is the only one I have found in my projects. And as soon as I post, I see that Hans has found the problem in the buffering code. but you're going to test it -) - 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 ___
Re: [NTG-context] First letter lost possible cause: \grabbfferdata
On 2014-06-25 16:07, Hans Hagen wrote: On 6/25/2014 10:03 PM, Rik Kabel wrote: On 2014-06-25 15:51, Rik Kabel wrote: Recently there have been reports of the first letter of a line of text being lost in the database and letter modules. I tracked down what appears to be the same problem and developed a work-around. The problem appears to be with the \grabbufferdata command. Something has changed in the way it works, and it now swallows the first token of the buffer that it grabs. It may also show up with other commands, but this is the only one I have found in my projects. And as soon as I post, I see that Hans has found the problem in the buffering code. but you're going to test it -) Indeed I have, but my tests mean little beyond what I can eyeball to see if it still looks okay. I might say that the issue is resolved for my small environment but I do not know what side-effects may result from the change. I have no library of edge cases, no integrated build environment, and only a single platform. That said, however, the issue disappears for my projects when I remake ConTeXt (and ConTeXtjit) with your patch. And clearly, the \ignorespaces that I used in my workaround was just a convenient no-op. I could have used {} or \relax to the same effect. -- Rik Kabel ___ 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] database module: the first letter is lost
On 2014-06-25 19:04, Hans Hagen wrote: On 6/25/2014 11:13 PM, Wolfgang Schuster wrote: Am 25.06.2014 um 21:44 schrieb Hans Hagen pra...@wxs.nl mailto:pra...@wxs.nl: On 6/25/2014 7:21 PM, Michael Green wrote: This appears to be the same as the problem Peter Münster found with the letter module \usemodule[database] \defineseparatedlist[MyTable] [separator=tab, before=\bTABLE,after=\eTABLE, first=\bTR,last=\eTR, left=\bTD,right=\eTD] \starttext The first letter of “Cell” is lost. \startseparatedlist[MyTable] Cell 1Cell 2 \stopseparatedlist With an extra return, “Cell” is intact. \startseparatedlist[MyTable] Cell 1Cell 2 \stopseparatedlist \stoptext in buff-ini.mkiv change this: \def\buff_start_indeed#1#2#3#4% {\normalexpanded{\buff_pickup{#2}{#3}{#4}{}{\buff_stop{#4}}\plusone}} probably needs some checking Adding \obeylines to \grabbufferdatadirect would also work \unexpanded\def\grabbufferdatadirect % name start stop {\begingroup % (6) + \obeylines \buff_start_indeed\empty} but I’m interested what’s the purpose of the fifth argument for \buff_start_indeed. that was wrong; the pickup macro has a fifth argument (\plusone here) but goes unnoticed when you add \obeylines in which case the first 'obeyedline' ended up in #5 (i probably messed up when adding some feature but i would have to need to look at older code to see how/when) does it make sense? Hans Adding \obeylines as Wolfgang indicated did not resolve the issue with my test case (shortened below), while removing #5 as Hans suggested does resolve it. % macros=mkvi \starttexdefinition unexpanded startTest \begingroup \dostartTest \stoptexdefinition \starttexdefinition dostartTest \grabbufferdata[Test][startTest][stopTest] \stoptexdefinition \starttexdefinition stopTest \getbufferdata[Test] \endgroup \stoptexdefinition \define\TestText {If you can read this the first token was not swallowed.} \starttext If another line does not follow this, there is a failure. \startTest\TestText\stopTest \stoptext As I wrote before, I do not have a way to more extensively test the other effects of the change. -- Rik Kabel ___ 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] Movable code, was Re: starttexdefinition error in standalone, works in TL2013
On 2014-03-01 07:32, Wolfgang Schuster wrote: \unexpanded\def\startTranslation {\begingroup \dosingleempty\dostartTranslation} \def\dostartTranslation[#1]% {\iffirstargument \getrawparameters[Translation][setups=,language=en,#1]% \fi \grabbufferdata[Translation][startTranslation][stopTranslation]} \def\stopTranslation {\language[\Translationlanguage]% \Translationsetups (\,\getbufferdata[Translation]\removeunwantedspaces\,)% \endgroup} \starttext \startTranslation[language=nl] It betrays a slow-witted mentality to pursue the streams, but not to see the sources of things. \stopTranslation \stoptext Wolfgang Wolfgang (and list), The above code works fine with simple texts, but is not movable. Adding a footnote, as in the following, to the text section shows that: \starttext \startTranslation[language=en] It betrays a slow-witted mentality to pursue the streams, but not to see the sources of things.% \footnote{% \startTranslation[language=la] Tardi ingeni est rivulos consectari, fontes rerum non videre. \stopTranslation% } \stopTranslation \stoptext or even by: \starttext It betrays a slow-witted mentality to pursue the streams, but not to see the sources of things.% \footnote{% \startTranslation[language=la] Tardi ingeni est rivulos consectari, fontes rerum non videre. \stopTranslation% } \stoptext In LaTeX, this might be dealt with by a combination robust command definitions and \protected. When I wrote an endnotes routine in LaTeX, I used those and wrote the notes to a file which was then read back in at the appropriate time, but that does not help with pagenotes. I imagine that at the time the footnote is processed the Translationsetups and Translationlanguage macros are no longer defined, and I have no idea how one would reference the buffer contents, although it does look like they have stable names in the log file. Can this be made movable? Also, am I correct that the \iffirstargument test in the definition of dostarttranslation is redundant? My understanding is that \dosingleempty assures the presence of [#1]. -- Rik ___ 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] starttexdefinition error in standalone, works in TL2013
Am 27.02.2014 um 05:08 schrieb Rik Kabel cont...@rik.users.panix.com: The following code processes cleanly under TL2013 and fails with ConTeXt ver: 2014.02.14 17:07 MKIV beta fmt: 2014.2.16 int: english/english. I suspect a regression, but I am also open to being told that I am doing things incorrectly. The \starttexdefinition was extended after the texlive release to support keywords like global or expanded and has therefore changed since then. The reason why it fails is that context passes the argument to Lua where they are parsed and at this point macros like your \EndTranslation are expanded. Even though this can be fixed I think it’s better to use the normal \def command when you want to create delimited commands. I also notice that it fails (even under TL2013) if a space is inserted after [#SETUP] in the doTrans intro. I thought that spaces should be allowed in \starttexdefinition -- is this only in the body and not the parameter description? No, spaces between arguments aren’t ignored but no spaces are added at the end of each line in the replacement text. \starttexdefinition Test #1 #2 “#2” “#1” \stoptexdefinition \starttext \Test ab cd \stoptext BTW: It’s better to follow contexts rules and use start/stop for environments, this way you can make use of the buffer mechanism to store text. \unexpanded\def\startTranslation {\begingroup \dosingleempty\dostartTranslation} \def\dostartTranslation[#1]% {\iffirstargument \getrawparameters[Translation][setups=,language=en,#1]% \fi \grabbufferdata[Translation][startTranslation][stopTranslation]} \def\stopTranslation {\language[\Translationlanguage]% \Translationsetups (\,\getbufferdata[Translation]\removeunwantedspaces\,)% \endgroup} \starttext \startTranslation[language=nl] It betrays a slow-witted mentality to pursue the streams, but not to see the sources of things. \stopTranslation \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 ___
Re: [NTG-context] starttexdefinition error in standalone, works in TL2013
On 2014-03-01 07:32, Wolfgang Schuster wrote: Am 27.02.2014 um 05:08 schrieb Rik Kabel cont...@rik.users.panix.com: {useful information on TL2013 and starttexdefinition skipped} BTW: It’s better to follow contexts rules and use start/stop for environments, this way you can make use of the buffer mechanism to store text. \unexpanded\def\startTranslation {\begingroup \dosingleempty\dostartTranslation} \def\dostartTranslation[#1]% {\iffirstargument \getrawparameters[Translation][setups=,language=en,#1]% \fi \grabbufferdata[Translation][startTranslation][stopTranslation]} \def\stopTranslation {\language[\Translationlanguage]% \Translationsetups (\,\getbufferdata[Translation]\removeunwantedspaces\,)% \endgroup} \starttext \startTranslation[language=nl] It betrays a slow-witted mentality to pursue the streams, but not to see the sources of things. \stopTranslation \stoptext Thank you for the excellent example. The only problem I see is that it fails if no optional argument is present (in which case the keyval settings \TranslationXXX never get defined). This is easily remedied by removing the \iffirstargument and \fi wrapping the \getrawparameters. -- Rik ___ 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] Argument of \startInvoice has an extra }.
Hi, How could I avoid that error here please: --8---cut here---start-8--- \def\beginInvoice{\dosingleempty\dobeginInvoice} \def\dobeginInvoice[#1]{\grabbufferdata[myLetter][beginInvoice][endInvoice]} \def\startInvoice#1\stopInvoice{bla} \starttext \beginInvoice \startInvoice test \stopInvoice \endInvoice \stoptext --8---cut here---end---8--- TIA for any help, -- Peter ___ 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] Argument of \startInvoice has an extra }.
On Sat, 9 Nov 2013, Peter Münster wrote: Hi, How could I avoid that error here please: --8---cut here---start-8--- \def\beginInvoice{\dosingleempty\dobeginInvoice} \def\dobeginInvoice[#1]{\grabbufferdata[myLetter][beginInvoice][endInvoice]} \def\startInvoice#1\stopInvoice{bla} \starttext \beginInvoice \startInvoice test \stopInvoice \endInvoice \stoptext One possibility is to restrict optional arguments to one line: \def\beginInvoice{\bgroup\obeylines\dosingleempty\dobeginInvoice} \def\dobeginInvoice[#1]{\egroup\grabbufferdata[myLetter][beginInvoice][endInvoice]} 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] Argument of \startInvoice has an extra }.
On Sat, Nov 09 2013, Aditya Mahajan wrote: One possibility is to restrict optional arguments to one line: \def\beginInvoice{\bgroup\obeylines\dosingleempty\dobeginInvoice} \def\dobeginInvoice[#1]{\egroup\grabbufferdata[myLetter][beginInvoice][endInvoice]} Thanks. How did you find the reason for the error (and the solution)? Is there also a solution with support for multiple lines? Unfortunately this does not work: --8---cut here---start-8--- \def\beginInvoice{\bgroup\obeylines\dosingleempty\dobeginInvoice} \def\dobeginInvoice[#1]{\egroup\getparameters[PRM][#1]% \grabbufferdata[myLetter][beginInvoice][endInvoice]} \def\endInvoice{\getbuffer[myLetter]} \def\startInvoice#1\stopInvoice{#1} \starttext \beginInvoice[bla=blub, blub=bla] \startInvoice test \PRMblub \stopInvoice \endInvoice \beginInvoice \startInvoice test \stopInvoice \endInvoice \stoptext --8---cut here---end---8--- TIA, -- Peter ___ 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] letter module: File ended while scanning use of \buff_gobble
On Mon, Mar 04 2013, Wolfgang Schuster wrote: \usemodule[letter] \startsetups[letter:section:content] \getbuffer[MyLetter] \stopsetups \setuplettersection[content][alternative=setups] \def\StartLetter {\starttext \grabbufferdata[MyLetter][StartLetter][StopLetter]} \def\StopLetter {\placeletter \stoptext} \StartLetter \input tufte \StopLetter Thanks Wolfgang. How could I add something at the start and at the end of the letter? This does not work: --8---cut here---start-8--- \def\StartLetter {\starttext \grabbufferdata[MyLetter][StartLetter][StopLetter] something at the start of the letter} \def\StopLetter {something at the end of the letter \placeletter \stoptext} --8---cut here---end---8--- TIA for any help, -- Peter ___ 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] letter module: File ended while scanning use of \buff_gobble
Am 01.09.2013 um 13:33 schrieb Peter Münster pmli...@free.fr: On Mon, Mar 04 2013, Wolfgang Schuster wrote: \usemodule[letter] \startsetups[letter:section:content] \getbuffer[MyLetter] \stopsetups \setuplettersection[content][alternative=setups] \def\StartLetter {\starttext \grabbufferdata[MyLetter][StartLetter][StopLetter]} \def\StopLetter {\placeletter \stoptext} \StartLetter \input tufte \StopLetter Thanks Wolfgang. How could I add something at the start and at the end of the letter? This does not work: --8---cut here---start-8--- \def\StartLetter {\starttext \grabbufferdata[MyLetter][StartLetter][StopLetter] something at the start of the letter} \def\StopLetter {something at the end of the letter \placeletter \stoptext} --8---cut here---end---8--- \startrawsetups[letter:section:content] Text before the content of the letter. \getbuffer[MyLetter] Text after the content of the letter. \stoprawsetups 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 ___
Re: [NTG-context] documents inside documents
Am 25.06.2013 um 22:25 schrieb Pablo Rodríguez oi...@web.de: On 25/06/13 21:55, Wolfgang Schuster wrote: Am 25.06.2013 um 21:31 schrieb Pablo Rodríguez oi...@web.de: Dear list, I need for a document explaining some ConTeXt features, to be able to include a document inside (a page that includes the feature). I know I can create another document and then insert the pages, but it would be much easier for me to be able to have the code inside the main the document. Is there a standard way to do it with ConTeXt? http://www.ntg.nl/pipermail/ntg-context/2013/072963.html Many thanks for your fast reply, Wolfgang. I'm afraid I cannot get it working with the sample file I provided. I do need to be able to get a complete document, not a TEXpage. Is that possible? \startbuffer[extract:before] \mainlanguage[en] \setuplanguage[en][patterns={en,agr}] \definepapersize[mine][width=6in,height=2in] \setuppapersize[mine] \usemodule[simplefonts] \setmainfont[Theano Didot] \definelinenote[contxt] \setupnote[contxt][paragraph=yes, inbetween=\hskip1.5em] \setupnotation[contxt][numbercommand=,alternative=serried,distance=1em,compress=yes,compressseparator=] \stopbuffer % \startbuffer[extract:after] % % empty % \stopbuffer \def\startextract {\dosingleempty\dostartextract} \def\dostartextract[#1]% {\edef\extractfilename{#1}% \grabbufferdata[extract:content][startextract][stopextract]} \def\stopextract {\doifsomething\extractfilename {\savebuffer[list={extract:before,extract:content,extract:after},file=\extractfilename.tex,prefix=no]% \typesetfile[\extractfilename][]}} \starttext \startextract[dummy] \startlinenumbering οὐκ οἶσθ᾽\contxt{οἶσθ᾽: οἶσθα, 2nd sg., οἶσδα} ὅτι πολλῶν ἐτῶν\contxt{πολλῶν ἐτῶν: for…; gen. time within} Ἀγάθων ἐνθάδε οὐκ ἐπιδεδήμηκεν\contxt{ἐπιδεδήμηκεν: pf. ἐπιδήμέω}, ἀφ᾽ οὗ\contxt{ἀφ᾽ οὗ: since; “from which (time)”} δ᾽ ἐγὼ Σωκράτει συνδιατρίβω\contxt{συνδιατρίβω: I have been spending; pres. but pf. progressive in translation} καὶ ἐπιμελὲς πεποίημαι\contxt{ἐπιμελὲς πεποίημαι: I have made it my business; “have made it my care,” pf.} \stoplinenumbering \stopextract \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 ___
Re: [NTG-context] orphans and widows in poems
Am 17.06.2013 um 19:18 schrieb Pablo Rodríguez oi...@web.de: On 16/06/13 21:03, Wolfgang Schuster wrote: Am 16.06.2013 um 09:46 schrieb Pablo Rodríguez oi...@web.de: [...] Is there no way to avoid orphans and widows in the lines environment? 1. Don’t use * in your setups names because names starting with an asterisk are system modes. 2. To load the defaults settings you have to use \setups[*reset] which needs the asterisks because it’s a system mode. 3.The settings doesn’t help because in the lines environment each line is a separate paragraph which makes \widowpenalty useless here. Thanks for your reply, Wolfgang. So, according to 3, there is no way to prevent widow or orphan lines in a line environment, isn't it? Not with the current implementation of the environment because it doesn’t know how many lines are there. With a Lua based solution it would be simple to add a mechanism to prevent a page break at a certain region because the needed information are available. \startluacode userdata = userdata or { } userdata.linescontent = userdata.linescontent or { } local linescontent = userdata.linescontent function linescontent.process() local lines = string.splitlines(buffers.getcontent(linescontent)) context.begingroup() for i=1,#lines do local l = lines[i] context(%s,l) context.par() end context.endgroup() end \stopluacode \def\startlinescontent {\grabbufferdata[linescontent][startlinescontent][stoplinescontent]} \def\stoplinescontent {\ctxlua{userdata.linescontent.process()}} \starttext \startlinescontent One Two Three Four Five Six \stoplinescontent \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 ___
Re: [NTG-context] orphans and widows in poems
On 6/17/2013 11:05 PM, Wolfgang Schuster wrote: Am 17.06.2013 um 19:18 schrieb Pablo Rodríguez oi...@web.de: On 16/06/13 21:03, Wolfgang Schuster wrote: Am 16.06.2013 um 09:46 schrieb Pablo Rodríguez oi...@web.de: [...] Is there no way to avoid orphans and widows in the lines environment? 1. Don’t use * in your setups names because names starting with an asterisk are system modes. 2. To load the defaults settings you have to use \setups[*reset] which needs the asterisks because it’s a system mode. 3.The settings doesn’t help because in the lines environment each line is a separate paragraph which makes \widowpenalty useless here. Thanks for your reply, Wolfgang. So, according to 3, there is no way to prevent widow or orphan lines in a line environment, isn't it? Not with the current implementation of the environment because it doesn’t know how many lines are there. With a Lua based solution it would be simple to add a mechanism to prevent a page break at a certain region because the needed information are available. yes, some of that is on the agenda (not to hard but as usual it take a bit of thinking / experimenting to get an interface) basically it's a variant of \setpenalties (the plural \widowpenalties etc) \startluacode userdata = userdata or { } userdata.linescontent = userdata.linescontent or { } local linescontent = userdata.linescontent function linescontent.process() local lines = string.splitlines(buffers.getcontent(linescontent)) context.begingroup() for i=1,#lines do local l = lines[i] context(%s,l) context.par() end context.endgroup() end \stopluacode \def\startlinescontent {\grabbufferdata[linescontent][startlinescontent][stoplinescontent]} \def\stoplinescontent {\ctxlua{userdata.linescontent.process()}} \starttext \startlinescontent One Two Three Four Five Six \stoplinescontent \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 ___ -- - 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 ___
Re: [NTG-context] TEXpage filename
Wolfgang— Can this be extended so as to allow the extraction of the individual component files (as PDFs with their component names) when processing a product file? Alan On Thu, May 2, 2013 at 2:44 AM, Wolfgang Schuster schuster.wolfg...@gmail.com wrote: Am 01.05.2013 um 23:02 schrieb Wolfgang Schuster schuster.wolfg...@gmail.com: Am 01.05.2013 um 12:16 schrieb Alan BRASLAU alan.bras...@cea.fr: Hello, In the production of (scientific) articles for journal submissions, one is often expected to supply the figures as separate files. One workflow can be through the use of \startTEXpage\stopTEXpage followed by an external extraction of single pdf pages to separate files. However, is it possible or would it be possible to directly output to a named file, as in: \startTEXpage{figure1.pdf} \stopTEXpage or perhaps \startTEXpage [file=figure1.pdf] \stopTEXpage ? (I could not find an answer looking at the source.) One could then (optionally) reinclude the figure in a review copy of the full text through the use of \externalfigure [figure1] You can put each graphic in a separate document and tell context to create a pdf with the \typesetfile command. \startbuffer[extract:before] \startTEXpage \stopbuffer \startbuffer[extract:after] \stopTEXpage \stopbuffer \def\startextract {\dosingleempty\dostartextract} \def\dostartextract[#1]% {\edef\extractfilename{#1}% \grabbufferdata[extract:content][startextract][stopextract]} \def\stopextract {\doifsomething\extractfilename {\savebuffer[list={extract:before,extract:content,extract:after},file=\extractfilename.tex,prefix=no]% \typesetfile[\extractfilename][]}} \starttext \startplacefigure[title={External file}] \startextract[extract-1] \blackrule[width=4cm,height=4cm,color=orange] \stopextract \stopplacefigure \stoptext Creating a new environment which does all of this itself isn’t hard because most of the stuff which is needed can be seen in the example below. % the external file \startbuffer[figure-1] \startTEXpage \blackrule[width=4cm,height=4cm,color=blue] \stopTEXpage \stopbuffer \savebuffer[list=figure-1,file=figure-1.tex,prefix=no] % process the external file at runtime \starttext \placefigure{External file}{\typesetfile[figure-1]} The second argument for \typesetfile is needed to get this working: \placefigure{External file}{\typesetfile[figure-1][]} 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 ___ ___ 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] TEXpage filename
Am 01.05.2013 um 23:02 schrieb Wolfgang Schuster schuster.wolfg...@gmail.com: Am 01.05.2013 um 12:16 schrieb Alan BRASLAU alan.bras...@cea.fr: Hello, In the production of (scientific) articles for journal submissions, one is often expected to supply the figures as separate files. One workflow can be through the use of \startTEXpage\stopTEXpage followed by an external extraction of single pdf pages to separate files. However, is it possible or would it be possible to directly output to a named file, as in: \startTEXpage{figure1.pdf} \stopTEXpage or perhaps \startTEXpage [file=figure1.pdf] \stopTEXpage ? (I could not find an answer looking at the source.) One could then (optionally) reinclude the figure in a review copy of the full text through the use of \externalfigure [figure1] You can put each graphic in a separate document and tell context to create a pdf with the \typesetfile command. \startbuffer[extract:before] \startTEXpage \stopbuffer \startbuffer[extract:after] \stopTEXpage \stopbuffer \def\startextract {\dosingleempty\dostartextract} \def\dostartextract[#1]% {\edef\extractfilename{#1}% \grabbufferdata[extract:content][startextract][stopextract]} \def\stopextract {\doifsomething\extractfilename {\savebuffer[list={extract:before,extract:content,extract:after},file=\extractfilename.tex,prefix=no]% \typesetfile[\extractfilename][]}} \starttext \startplacefigure[title={External file}] \startextract[extract-1] \blackrule[width=4cm,height=4cm,color=orange] \stopextract \stopplacefigure \stoptext Creating a new environment which does all of this itself isn’t hard because most of the stuff which is needed can be seen in the example below. % the external file \startbuffer[figure-1] \startTEXpage \blackrule[width=4cm,height=4cm,color=blue] \stopTEXpage \stopbuffer \savebuffer[list=figure-1,file=figure-1.tex,prefix=no] % process the external file at runtime \starttext \placefigure{External file}{\typesetfile[figure-1]} The second argument for \typesetfile is needed to get this working: \placefigure{External file}{\typesetfile[figure-1][]} 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 ___
Re: [NTG-context] letter module: File ended while scanning use of \buff_gobble
Am 04.03.2013 um 14:57 schrieb Peter Münster pmli...@free.fr: Hi, How could I embed \startletter/\stopletter in a macro please? This does not work: --8---cut here---start-8--- \usemodule[letter] \def\myStartLetter{\startletter} \def\myStopLetter{\stopletter} \myStartLetter \input tufte \myStopLetter --8---cut here---end---8--- The module uses a buffer to store the content of the letter environment. What you can do is to create a new buffer for your environment and feed the content of this buffer to the letter module. \usemodule[letter] \startsetups[letter:section:content] \getbuffer[MyLetter] \stopsetups \setuplettersection[content][alternative=setups] \def\StartLetter {\starttext \grabbufferdata[MyLetter][StartLetter][StopLetter]} \def\StopLetter {\placeletter \stoptext} \StartLetter \input tufte \StopLetter 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 ___
Re: [NTG-context] code after \stopbuffer
Thanks, got the following now working: \def\startxmlbuffer{\grabbufferdata[xmlbuffer][startxmlbuffer][stopxmlbuffer]} \def\stopxmlbuffer{\endinput} .. \xmlprocessbuffer{dvd}{xmlbuffer}{} Hans van der Meer On 13 feb. 2013, at 22:34, Wolfgang Schuster wolfgang.schus...@gmail.com wrote: Am 13.02.2013 um 17:49 schrieb H. van der Meer h.vanderm...@uva.nl: Is it possible to have a command automatically executed each time \stopbuffer has been read? Preferably coupled to a specific named \startbuffer[this_one], iff possible at all of course. Thus: \startbuffer[this_one] ..contents.. \stopbuffer % in execution followed by \command \def\startmybuffer {\grabbufferdata[mybuffer][startmybuffer][stopmybuffer]} \def\stopmybuffer {\startframedtext[width=max] \getbuffer[mybuffer] \stopframedtext} \starttext \startmybuffer \input knuth \stopmybuffer \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 ___ ___ 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] code after \stopbuffer
Am 13.02.2013 um 17:49 schrieb H. van der Meer h.vanderm...@uva.nl: Is it possible to have a command automatically executed each time \stopbuffer has been read? Preferably coupled to a specific named \startbuffer[this_one], iff possible at all of course. Thus: \startbuffer[this_one] ..contents.. \stopbuffer % in execution followed by \command \def\startmybuffer {\grabbufferdata[mybuffer][startmybuffer][stopmybuffer]} \def\stopmybuffer {\startframedtext[width=max] \getbuffer[mybuffer] \stopframedtext} \starttext \startmybuffer \input knuth \stopmybuffer \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 ___
Re: [NTG-context] \setlayer on \startalign row
On Wed, 6 Feb 2013, Troy Henderson wrote: I would like to make a row of a \startalign ... \stopalign hidden. The following fails. \starttext \definelayer[hiddenlayer][state=stop] \startformula \startalign[n=3,align={right,middle,left}] \NC a \NC = \NC b \NR \setlayer[hiddenlayer]{\NC a + c \NC = \NC b + c \NR} \stopalign \stopformula \stoptext Layers would not work for something like this. I usually use the attached macros for stepping: \environment steps \starttext \StartStepping 2 \startformula \startalign[n=3,align={right,middle,left}] \NC a \NC = \NC b \NR \STEP 2{\NC a + c \NC = \NC b + c \NR} \stopalign \stopformula \StopStepping \stoptext Aditya\startmodule steps \unprotect % This module defines two macros: % \ONLY{count}{...} which displays text on a particular page % \STEP{count}{...} which displays text from a particular page \def\complexslides_only#1{\csname complexslides_steps_only_#1\endcsname} \def\complexslides_step#1{\csname complexslides_steps_step_#1\endcsname} \def\complexslides_hide#1{\csname complexslides_steps_hide_#1\endcsname} \def\StartStep#1#2\StopStep{\complexslides_step{#1}{#2}} \def\StartOnly#1#2\StopOnly{\complexslides_only{#1}{#2}} \def\StartHide#1#2\StopHide{\complexslides_hide{#1}{#2}} \long\def\gobble#1{} \long\def\oneofone#1{#1} \long\def\gobblebox#1% {\phantom{\framed[align=normal, frame=off]{#1}}} \long\def\displaybox#1% {\framed[align=normal, frame=off]{#1}} % Allow nesting of \StartStepping ... \StopStepping \def\StartStepping#1#2\StopStepping% {\dorecurse{30}{\long\setvalue{complexslides_steps_step_\recurselevel}{\gobble}}% \dorecurse{30}{\long\setvalue{complexslides_steps_only_\recurselevel}{\gobble}}% \dorecurse{30}{\long\setvalue{complexslides_steps_hide_\recurselevel}{\gobblebox}}% \pushmacro\ONLY \pushmacro\STEP \pushmacro\HIDE \def\ONLY{\complexslides_only}% \def\STEP{\complexslides_step}% \def\HIDE{\complexslides_hide}% \dorecurse{#1}{% \edef\currentStepLevel{\recurselevel}% \long\setvalue{complexslides_steps_step_\currentStepLevel}{\oneofone}% \long\setvalue{complexslides_steps_only_\currentStepLevel}{\oneofone}% \long\setvalue{complexslides_steps_hide_\currentStepLevel}{\displaybox}% #2% \setvalue{complexslides_steps_only_\currentStepLevel}{\gobble}% \page\decrementnumber[userpage]}% \incrementnumber[userpage]% \popmacro\ONLY \popmacro\STEP } \def\doifStepelse% {\doifelse\currentStepLevel} % To be used in a group \unexpanded\def\disablesteps {\def\complexslides_only##1{\gobble}% ##2 \def\complexslides_step##1{\oneofone}%##2 } \unexpanded\def\SetStep#1#2% i of n {\dorecurse{#2}{\long\setvalue{complexslides_steps_step_\recurselevel}{\gobble}}% \dorecurse{#2}{\long\setvalue{complexslides_steps_only_\recurselevel}{\gobble}}% \dorecurse{#2}{\long\setvalue{complexslides_steps_hide_\recurselevel}{\gobblebox}}% \edef\currentStepLevel{#1}% \long\setvalue{complexslides_steps_step_\currentStepLevel}{\oneofone}% \long\setvalue{complexslides_steps_only_\currentStepLevel}{\oneofone}% \long\setvalue{complexslides_steps_hide_\currentStepLevel}{\displaybox}% } \def\hidecomponent#1 {\let\StartS\StartStepping \let\StopS\StopStepping \def\StartStepping{\grabbufferdata[Stepping][StartStepping][StopStepping]} \component[#1] \let\StartStepping\StartS \let\StopStepping\StopS} \protect \stopmodule ___ 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] Getting the content of source lines in a \startlines \stoplines env?
Am 04.02.2013 um 18:11 schrieb Ingo Hohmann cont...@ingohohmann.de: Hi, in another thread I got an answer to the question, how to format lines in an environment automatically. Is there a way to get the content of source lines? For example, to save the line content into a variable? You can save the content in a buffer and process the content with Lua. \startluacode userdata = userdata or { } userdata.linescontent = userdata.linescontent or { } local linescontent = userdata.linescontent function linescontent.process() local lines = string.splitlines(buffers.getcontent(linescontent)) context.startlines() for i=1,#lines do local l = lines[i] if i == 1 then context({\\bf %s},l) context(true) elseif i == 2 then context({\\tt %s},l) context(true) else context(%s,l) context(true) end end context.stoplines() end \stopluacode \def\startlinescontent {\grabbufferdata[linescontent][startlinescontent][stoplinescontent]} \def\stoplinescontent {\ctxlua{userdata.linescontent.process()}} \starttext \startlinescontent One Two Three Four Five Six \stoplinescontent \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 ___
Re: [NTG-context] Figure captions in margin
On 2013–01–20 Devendra Ghate wrote: I am using a layout with wide right margin. For floats that are \textwidth wide, I can place captions in the margin using**\setupcaption[location=rightmargin,high/low]. However, for figures that are (*\textwidth+\marginwidth+\margindistance*) wide, I would like to *place the caption in the margin below the figure*. For a recent project I had the similar requirements. I did not find a proper solution. I attached an example of the code I used. However, it has several issues: 1) Margin floats and texts overlay and need manual adjustment. 2) The baseline of the float description does not match the baseline of the main text (fixed using manual trial and error). I used an ugly hack (toffset=7.5ex) to align the description vertically. 3) The \startplacesmartfigure is not very robust. My notes say “Do not indent \startplacesmartfigure”. I don't recall what the exact issue was. 4) Probably many more that I haven't discovered, yet. Feel free to suggest fixes for the mentioned issues. Marco \useMPlibrary [dum] \unprotect \setupfloat [figure] [default={top,bottom}] \setupfloat [table] [default={bottom,top}] \definefloat [margintable] [margintables] [table] \definefloat [marginfigure] [marginfigures] [figure] \setupcaptions [width=\marginwidth, prefix=no] \setupcaption [table] [location={outermargin, high}] \setupcaption [figure] [location={outermargin, high}] \setupcaption [marginfigure, margintable] [align=flushleft, location=bottom] \setupcaption [table, figure] [way=bytext] \setupfloat [marginfigure, margintable] [default=margin] \definefloat [widetable] [widetables] [table] \setupfloat [widetable] [location=inner] \definefloat [widefigure] [widefigures] [figure] \setupfloat [widefigure] [location=inner] \defineframed [caption_framed] [frame=off, offset=overlay, location=high, toffset=7.5ex] \starttexdefinition caption_command #1 \caption_framed{#1} \stoptexdefinition \setupcaption [widetable] [location={outermargin, low}, command=\caption_command] \setupcaption [widefigure] [location={outermargin, low}, command=\caption_command] \newtoks\t_smart_figure_args \starttexdefinition startplacesmartfigure [#1] \t_smart_figure_args={#1} \grabbufferdata [smart_figure_buffer] [startplacesmartfigure] [stopplacesmartfigure] \stoptexdefinition \startluacode userdata = userdata or { } function userdata.do_place_smart_figure(width) context.unprotect() if tex.sp(width) = tex.dimen.rightmarginwidth + tex.sp(.1pt) then context.startplacemarginfigure{tex.toks.t_smart_figure_args} tex.print(buffers.getcontent(smart_figure_buffer)) context.stopplacemarginfigure() else if tex.sp(width) = tex.dimen.textwidth + tex.sp(.1pt) then context.startplacefigure{tex.toks.t_smart_figure_args} tex.print(buffers.getcontent(smart_figure_buffer)) context.stopplacefigure() else context.startplacewidefigure{tex.toks.t_smart_figure_args} tex.print(buffers.getcontent(smart_figure_buffer)) context.stopplacewidefigure() end end context.protect() end \stopluacode \starttexdefinition stopplacesmartfigure \scratchdimen\hsize \hsize\maxdimen \setbox\scratchbox\vbox{\getbuffer[smart_figure_buffer]} \hsize\scratchdimen \luacode{userdata.do_place_smart_figure(\the\wd\scratchbox)} \stoptexdefinition \protect \starttext \startplacesmartfigure [title=Foo] \externalfigure [dummy] [width=\rightmarginwidth, height=3cm] \stopplacesmartfigure \dorecurse{5}{%% \input knuth\par} \startplacesmartfigure [title=\input ward\par] \externalfigure [dummy] [width=\textwidth, height=8cm] \stopplacesmartfigure \startplacesmartfigure [title=\input ward\par] \externalfigure [dummy] [width=\dimexpr\textwidth+\rightmargintotal\relax, height=3cm] \stopplacesmartfigure \stoptext signature.asc Description: Digital 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] New module: simplesteps.
\begingroup \grabbufferdata[simplesteps][startframe][stopframe]% } With the \grabbufferdata command the content beginning from \startframe until \stopframe is stored in a buffer with the name “simplesteps”. (1) What does the \begingroup do? I could not find a \endgroup in the patch, nor in the module code. (2) I've approximately documented grabbufferdata here: http://wiki.contextgarden.net/Command/grabbufferdata But when I tried to write a minimal example, I couldn't get it to compile. %% begin example \grabbufferdata[mybuffer][thisisthestart][thisistheend] \thisisthestart My friend, you would not tell with such high zest To children ardent for some desparate glory, The old Lie: Dulce et decorum est Pro patria mori. \thisistheend \typebuffer[mybuffer] %% end example What am I doing wrong? And is the description I put on the wiki correct? Cheers, Sietse ___ 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] New module: simplesteps.
···date: 2012-12-15, Saturday···from: Sietse Brouwer··· \begingroup \grabbufferdata[simplesteps][startframe][stopframe]% } With the \grabbufferdata command the content beginning from \startframe until \stopframe is stored in a buffer with the name “simplesteps”. (1) What does the \begingroup do? I could not find a \endgroup in the patch, nor in the module code. It’s in the definition of \buff_stop in buff-ini.mkiv. The first thing \startbuffer does is to insert a bgroup, too. Philipp pgpeFsXMBI40v.pgp 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] New module: simplesteps.
%% begin example \grabbufferdata[mybuffer][thisisthestart][thisistheend] \thisisthestart My friend, you would not tell with such high zest To children ardent for some desparate glory, The old Lie: Dulce et decorum est Pro patria mori. \thisistheend \typebuffer[mybuffer] %% end example What am I doing wrong? And is the description I put on the wiki correct? It's just a guess... but I think the \grabbufferdata has to be invoked *after* the \thisisthestart, \thisistheend pair. André Caldas. ___ 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] New module: simplesteps.
On 2012–12–15 Sietse Brouwer wrote: But when I tried to write a minimal example, I couldn't get it to compile. %% begin example \grabbufferdata[mybuffer][thisisthestart][thisistheend] \thisisthestart My friend, you would not tell with such high zest To children ardent for some desparate glory, The old Lie: Dulce et decorum est Pro patria mori. \thisistheend \typebuffer[mybuffer] %% end example What am I doing wrong? You have to wrap it in a macro: \starttext \define\thisisthestart {\grabbufferdata[mybuffer][thisisthestart][thisistheend]} \let\thisistheend\relax %% not necessary \thisisthestart My friend, you would not tell with such high zest To children ardent for some desparate glory, The old Lie: Dulce et decorum est Pro patria mori. \thisistheend \typebuffer[mybuffer] \stoptext Marco signature.asc Description: Digital 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] New module: simplesteps.
On 12/15/2012 7:02 AM, Wolfgang Schuster wrote: Am 15.12.2012 um 00:07 schrieb Andre Caldas andre.em.cal...@gmail.com: thanks for the interesting contribution! Have a look at the patch I hopefully don’t forget to append. I didn't quite understood how this works: \unexpanded\def\startframe{\dosingleempty\frame_start} This creates the new command \startframe which calls the internal command \frame_start which has one optional argument. \def\frame_start[#1]{% \iffirstargument \section{#1}%% solution needed here! \fi This block checks if the optional argument is used by the user, when the argument is used the content is typeset as \section. \begingroup \grabbufferdata[simplesteps][startframe][stopframe]% } With the \grabbufferdata command the content beginning from \startframe until \stopframe is stored in a buffer with the name “simplesteps”. \let\stopframe\simplestepsplaybuffer This makes the \stopframe command a synonym for \simplestepsplaybuffer which is now called when the frame environment ends. best use a namespace: \simplesteps_start_frame (dangerous name: \startframe ... could be core name) 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 ___
Re: [NTG-context] New module: simplesteps.
Am 15.12.2012 um 11:40 schrieb Philipp Gesang philipp.ges...@alumni.uni-heidelberg.de: ···date: 2012-12-15, Saturday···from: Sietse Brouwer··· \begingroup \grabbufferdata[simplesteps][startframe][stopframe]% } With the \grabbufferdata command the content beginning from \startframe until \stopframe is stored in a buffer with the name “simplesteps”. (1) What does the \begingroup do? I could not find a \endgroup in the patch, nor in the module code. It’s in the definition of \buff_stop in buff-ini.mkiv. The first thing \startbuffer does is to insert a bgroup, too. The \begingroup shouldn’t be here because the buffer code does end all groups it opens and the extra group you open is never closed. 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 ___
Re: [NTG-context] New module: simplesteps.
···date: 2012-12-15, Saturday···from: Wolfgang Schuster··· Am 15.12.2012 um 11:40 schrieb Philipp Gesang philipp.ges...@alumni.uni-heidelberg.de: ···date: 2012-12-15, Saturday···from: Sietse Brouwer··· \begingroup \grabbufferdata[simplesteps][startframe][stopframe]% } With the \grabbufferdata command the content beginning from \startframe until \stopframe is stored in a buffer with the name “simplesteps”. (1) What does the \begingroup do? I could not find a \endgroup in the patch, nor in the module code. It’s in the definition of \buff_stop in buff-ini.mkiv. The first thing \startbuffer does is to insert a bgroup, too. The \begingroup shouldn’t be here because the buffer code does end all groups it opens and the extra group you open is never closed. Argh, yes of course, there it is: “\end occurred inside group.” Tracing back I think it’s a leftover. Thanks for checking! Philipp pgppzwwU1GXt2.pgp 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] New module: simplesteps.
Am 15.12.2012 um 11:28 schrieb Sietse Brouwer sbbrou...@gmail.com: \begingroup \grabbufferdata[simplesteps][startframe][stopframe]% } With the \grabbufferdata command the content beginning from \startframe until \stopframe is stored in a buffer with the name “simplesteps”. (1) What does the \begingroup do? I could not find a \endgroup in the patch, nor in the module code. (2) I've approximately documented grabbufferdata here: http://wiki.contextgarden.net/Command/grabbufferdata But when I tried to write a minimal example, I couldn't get it to compile. %% begin example \grabbufferdata[mybuffer][thisisthestart][thisistheend] \thisisthestart My friend, you would not tell with such high zest To children ardent for some desparate glory, The old Lie: Dulce et decorum est Pro patria mori. \thisistheend \typebuffer[mybuffer] %% end example What am I doing wrong? And is the description I put on the wiki correct? The \grabbufferdata command reads only all text until the end command (e.g. \thisistheend) but the beginning command for the buffer (e.g. thisisthestart) has to be defined by the user. You have to give the name of begin command because context has to know it when buffers are nested (I will a explanation about this in another thread). \starttext \def\thisisthestart {\grabbufferdata[mybuffer][thisisthestart][thisistheend]} \thisisthestart My friend, you would not tell with such high zest To children ardent for some desparate glory, The old Lie: Dulce et decorum est Pro patria mori. \thisistheend \typebuffer[mybuffer] \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 ___
Re: [NTG-context] New module: simplesteps.
Thank you both, Philipp and Wolfgang, I've updated the wiki. Wolfgang wrote: You have to give the name of begin command because context has to know it when buffers are nested (I will a explanation about this in another thread). Ah, I was wondering about that. Yes, I'd be interested in the background explanation. Cheers, Sietse On Sat, Dec 15, 2012 at 1:38 PM, Wolfgang Schuster wolfgang.schus...@gmail.com wrote: Am 15.12.2012 um 11:28 schrieb Sietse Brouwer sbbrou...@gmail.com: \begingroup \grabbufferdata[simplesteps][startframe][stopframe]% } With the \grabbufferdata command the content beginning from \startframe until \stopframe is stored in a buffer with the name “simplesteps”. (1) What does the \begingroup do? I could not find a \endgroup in the patch, nor in the module code. (2) I've approximately documented grabbufferdata here: http://wiki.contextgarden.net/Command/grabbufferdata But when I tried to write a minimal example, I couldn't get it to compile. %% begin example \grabbufferdata[mybuffer][thisisthestart][thisistheend] \thisisthestart My friend, you would not tell with such high zest To children ardent for some desparate glory, The old Lie: Dulce et decorum est Pro patria mori. \thisistheend \typebuffer[mybuffer] %% end example What am I doing wrong? And is the description I put on the wiki correct? The \grabbufferdata command reads only all text until the end command (e.g. \thisistheend) but the beginning command for the buffer (e.g. thisisthestart) has to be defined by the user. You have to give the name of begin command because context has to know it when buffers are nested (I will a explanation about this in another thread). \starttext \def\thisisthestart {\grabbufferdata[mybuffer][thisisthestart][thisistheend]} \thisisthestart My friend, you would not tell with such high zest To children ardent for some desparate glory, The old Lie: Dulce et decorum est Pro patria mori. \thisistheend \typebuffer[mybuffer] \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 ___ ___ 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] New module: simplesteps.
thanks for the interesting contribution! Have a look at the patch I hopefully don’t forget to append. I didn't quite understood how this works: \unexpanded\def\startframe{\dosingleempty\frame_start} \def\frame_start[#1]{% \iffirstargument \section{#1}%% solution needed here! \fi \begingroup \grabbufferdata[simplesteps][startframe][stopframe]% } \let\stopframe\simplestepsplaybuffer Cheers, André Caldas. ___ 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] New module: simplesteps.
Am 15.12.2012 um 00:07 schrieb Andre Caldas andre.em.cal...@gmail.com: thanks for the interesting contribution! Have a look at the patch I hopefully don’t forget to append. I didn't quite understood how this works: \unexpanded\def\startframe{\dosingleempty\frame_start} This creates the new command \startframe which calls the internal command \frame_start which has one optional argument. \def\frame_start[#1]{% \iffirstargument \section{#1}%% solution needed here! \fi This block checks if the optional argument is used by the user, when the argument is used the content is typeset as \section. \begingroup \grabbufferdata[simplesteps][startframe][stopframe]% } With the \grabbufferdata command the content beginning from \startframe until \stopframe is stored in a buffer with the name “simplesteps”. \let\stopframe\simplestepsplaybuffer This makes the \stopframe command a synonym for \simplestepsplaybuffer which is now called when the frame environment ends. 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 ___
Re: [NTG-context] New module: simplesteps.
Hey André, thanks for the interesting contribution! Have a look at the patch I hopefully don’t forget to append. ···date: 2012-12-13, Thursday···from: Andre Caldas··· Well since Raw Steps did not work with mkiv, I tried making a very very simple module for a beamer-like behaviour. I don't really know how to write a module... but here is what I did: https://bitbucket.org/andrecaldas/math-video-classes/src/9116599821fc246cb54d3e6d7b8e6304649eaffb/lib?at=default I use \startbuffer and \stopbuffer, and also Lua. As I said, I don't really know how to write a module... comments are very welcome. Honestly, it doesn’t work, but that’s a minor flaw! If you want to use buffers with indirection you have to take care of the argument delimiters. \grabbufferdata is excellent for that. I did some rewriting: stray globals and rough namespacing, mostly. On the practice of calling TeX macros from Lua, the cld manual can give you a boost: http://www.pragma-ade.com/general/manuals/cld-mkiv.pdf This explains how to properly use the context.*() namespace instead of tex.print and the likes. I could not figure out how exactly the section block thingy is supposed to work. It does not create the \startframe macro at all -- is this something custom? I infer it’s about the slide title so I have \startframe call \section but that should be taken as a placeholder at most. In my own slide module I use \{start,stop}section with the option placehead=no and rely on the page header to display the slide title (i.e. current section running head). That was the laziest way I could imagine :P Some remarks: - you should rename simplesteps.mkiv to t-simplesteps.mkiv, indicating that it is a thirdparty module - if you plan on expanding the code you eventually will come to love this bit: http://wiki.contextgarden.net/System_Macros - Context has a namespacing system which you might consider switching to in the long term: http://tex.stackexchange.com/q/58654 but it’s arguably an advanced method - maybe switch to mkvi as named parameters make rewriting macros a breeze Is it ok if I send a PDF sample to the list? For uploading docs and such to the “downloads” section on bitbucket is great. Then just post a link. Happy TeXing! Philipp diff -r 9116599821fc lib/simplesteps.lua --- a/lib/simplesteps.lua Thu Dec 13 20:49:38 2012 -0200 +++ b/lib/simplesteps.lua Fri Dec 14 01:59:00 2012 +0100 @@ -7,10 +7,12 @@ license = GPL version 3.0 or any later version } -simplesteps = simplesteps or {} +thirddata = thirddata or {} +thirddata.simplesteps = thirddata.simplesteps or {} +local simplesteps = thirddata.simplesteps -local stepcounter = 0 -local maxstepcount = 1 +local stepcounter = 0 +local maxstepcount = 1 function simplesteps.distance_to_step(str) @@ -51,7 +53,7 @@ function simplesteps.update_maxstepcount(steps) for i=1,#steps do -step = steps[i] +local step = steps[i] if maxstepcount step then maxstepcount = step diff -r 9116599821fc lib/simplesteps.mkiv --- a/lib/simplesteps.mkiv Thu Dec 13 20:49:38 2012 -0200 +++ b/lib/simplesteps.mkiv Fri Dec 14 01:59:00 2012 +0100 @@ -18,7 +18,7 @@ \unprotect %D \macros -%D {simplesteps} +%D {startframe,stopframe} %D %D \startframe[Slide 1] %D \startitemize @@ -31,49 +31,53 @@ \unexpanded\def\uncover[#1]% {\ctxlua{ - distance = simplesteps.distance_to_step(#1) + local distance = thirddata.simplesteps.distance_to_step(#1) if 0 == distance then elseif 1 == distance then -tex.sprint('\\simplestepscoverednext') +context.simplestepscoverednext() elseif 2 == distance then -tex.sprint('\\simplestepscoveredfar') +context.simplestepscoveredfar() else -tex.sprint('\\simplestepscoveredveryfar') +context.simplestepscoveredveryfar() end }} \unexpanded\def\only[#1]% {\ctxlua{ - if not simplesteps.instep(#1) + if not thirddata.simplesteps.instep(#1) then -tex.sprint('\\simplestepshidden') +context.simplestepshidden() end }} \unexpanded\def\simplestepsplaybuffer% - {\ctxlua{simplesteps.playbuffer()}} + {\ctxlua{thirddata.simplesteps.playbuffer()}} -\definecolor[hidden1][s=0.75] -\definecolor[hidden2][s=0.90] -\definecolor[hidden3][s=0.95] +\definecolor[simplesteps:hidden1][s=0.75] +\definecolor[simplesteps:hidden2][s=0.90] +\definecolor[simplesteps:hidden3][s=0.95] \unexpanded\def\simplestepshidden#1{} -\unexpanded\def\simplestepscoverednext#1{\color[hidden1]{#1}} -\unexpanded\def\simplestepscoveredfar#1{\color[hidden2]{#1}} -\unexpanded\def\simplestepscoveredveryfar#1{\color[hidden3]{#1}} +\unexpanded\def\simplestepscoverednext#1{\color[simplesteps:hidden1]{#1}} +\unexpanded\def\simplestepscoveredfar#1{\color[simplesteps:hidden2]{#1}} +\unexpanded\def\simplestepscoveredveryfar#1{\color
[NTG-context] A strange problem, probably with \startitemize[columns]
Hello, I am a bit afraid to gain a nickname the itemize-column guy, but it seems that again there's a problem with this feature... Unfortunately, I did not manage to isolate the problem, so maybe it lies somewhere completely else. Anyway, sorry for spamming the list again with a complete file of one of my documents (it's all Polish to most of you anyway;)), but it compiles succesfully, but very strangely (it looks like \vsize \paperheight) on newest ConTeXt (it used to look just fine about three weeks ago). Any clues? -- Marcin Borkowski http://mbork.pl % Äwiczenia na Newtona o grach \mainlanguage[pl] \usetypescript[pagella] \setupbodyfont[pagella] \usemodule[tikz] \usetikzlibrary[calc] \let\origstarttikzpicture=\starttikzpicture \let\origstoptikzpicture=\stoptikzpicture \def\starttikzpicture{\hbox\bgroup\origstarttikzpicture} \def\stoptikzpicture {\origstoptikzpicture\egroup} \def\todo#1{{\em \kap{do dopisania}: #1}} %\setupinteraction[state=start] \enablemode[nauczyciel] %\disablemode[nauczyciel] \def\startteacher{\grabbufferdata[teacher][startteacher][stopteacher]} \doifmodeelse{nauczyciel}{\def\stopteacher{\par{\switchtobodyfont[small]\getbuffer[teacher]\par}}}{\def\stopteacher{}} \def\startanswer{\par\dostartbuffer[answer][startanswer][stopanswer]} \doifmodeelse{nauczyciel}{\def\stopanswer{{\switchtobodyfont[small]\blank[small]{\sl Odpowiedź.} \getbuffer[answer]\par}}}{\def\stopanswer{}} \def\putdotafter#1{#1.} \setuphead[subject][style=bold,after={},alternative=text,distance=0.25em,textcommand=\putdotafter] %\setuphead[section][numbercommand=\putdotafter] \setuphead[chapter][sectionstopper=.,page=no] \def\teacheronly#1{\doifmode{nauczyciel}{#1}} \def\time#1{\doifmode{nauczyciel}{\removeunwantedspaces \hskip 0pt plus 6em\penalty20\ \hskip 0pt plus -6em (#1~minut)}} \defineitemgroup[exercises] \setupitemgroup[exercises][1][n,broad,intro][left={\headnumber[chapter]},before={},inbetween={\blank[medium]}] \def\ppauza{\unskip\kern.2em--\hskip.2em\ignorespaces} \starttext \noheaderandfooterlines \startalignment[middle] \tfd Gry (materiaÅy na Äwiczenia w~czwartek) \par\blank[big] \stopalignment \startnotmode[nauczyciel] \placefigure[bottom,none]{}{% \hbox to \textwidth{ \externalfigure[logo-1-t][height=1.5cm]\hfil \externalfigure[logo-2-t][height=1.5cm]\hfil \externalfigure[logo-3-t][height=1.5cm] }} \stopnotmode \completecontent[alternative=a,pagestyle=slanted,distance=2pt] \page \startchapter[title={Gry macierzowe\time{15--20}}] \startexercises \startitem Jakie sÄ strategie optymalne dla obu graczy w~grze o~poniższej macierzy? \startformula \startmathmatrix[n=2,left={\left(\,},right={\,\right)},align=right] \NC 1 \NC 2 \NR \NC 3 \NC 4 \NR \stopmathmatrix \stopformula \startteacher Macierz interpretujemy nastÄpujÄ co: I~gracz wybiera wiersz, II~gracz wybiera kolumnÄ (obaj robiÄ to równoczeÅnie), po czym II~gracz wypÅaca pierwszemu kwotÄ z~przeciÄcia wybranego wiersza i~kolumny (gra o~sumie zero: wygrana jednego gracza jest równa przegranej drugiego). \stopteacher \startanswer Pierwszy gracz, wybierajÄ c drugi wiersz, w~każdym wypadku wygrywa wiÄcej, niż gdyby wybraÅ pierwszy; powinien wiÄc wybraÄ drugi wiersz (dominujÄ cy). Drugi gracz, wybierajÄ c pierwszÄ kolumnÄ, w~każdym przypadku traci mniej, niż gdyby wybraÅ drugÄ ; powinien wiÄc wybraÄ pierwszÄ (dominujÄ cÄ ) kolumnÄ. \stopanswer \stopitem \startitem Rozważmy grÄ z~nastÄpujÄ cÄ macierzÄ : \startformula \startmathmatrix[n=3,left={\left(\,},right={\,\right)},align=right] \NC 4 \NC 1 \NC -1 \NR \NC 0 \NC 1 \NC 6 \NR \NC 3 \NC 2 \NC 5 \NR \stopmathmatrix \stopformula Jaka jest optymalna strategia dla każdego z~graczy? \startanswer Å»aden wiersz ani kolumna nie sÄ dominujÄ ce, ale ponieważ \math{2} w~trzecim rzÄdzie i~drugiej kolumnie jest {\em najmniejszÄ } wartoÅciÄ w~swoim rzÄdzie i~{\em najwiÄkszÄ } wartoÅciÄ w~swojej kolumnie, optymalnÄ strategiÄ dla I~gracza jest trzecia (wygra co najmniej~\math{2} niezależnie od strategii II~gracza), a~dla II~gracza druga (przegra co najwyżej~\math{2} niezależnie od strategii I~gracza). \stopanswer \stopitem \startitem Gra {\em parzyste czy nieparzyste} polega na tym, że dwóch graczy wybiera (równoczeÅnie) liczbÄ \math{1} lub~\math{2}. JeÅli suma wybranych liczb jest nieparzysta, wygrywa gracz~I; jeÅli jest parzysta, wygrywa gracz~II. Gracz, który przegraÅ, oddaje drugiemu kwotÄ równÄ sumie wybranych liczb. Narysujcie macierz tej gry. Jaka jest optymalna strategia każdego z~graczy? Czy gra jest sprawiedliwa? \startteacher To zadanie możemy opuÅciÄ lub omówiÄ pobieżnie bez wiÄkszej szkody. \stopteacher
[NTG-context] Two questions about buffers
Hello, I have two questions concerning buffers. 1. What is the difference between \grabbufferdata and \dostartbuffer? 2. I wanted to use buffers to define my own environment (as Wolfgang suggested to me a few days ago). However, there's a problem with \baselineskip; here is an example: \starttext \def\startMyEnv{\dostartbuffer[MyEnv][startMyEnv][stopMyEnv]} \def\stopMyEnv{{\tfxx\getbuffer[MyEnv]\par}} \input tufte \startMyEnv \input knuth \stopMyEnv \input tufte \stoptext Am I doing something wrong here? TIA -- Marcin Borkowski http://mbork.pl ___ 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] Two questions about buffers
On 30-6-2012 14:25, Marcin Borkowski wrote: Hello, I have two questions concerning buffers. 1. What is the difference between \grabbufferdata and \dostartbuffer? 2. I wanted to use buffers to define my own environment (as Wolfgang suggested to me a few days ago). However, there's a problem with \baselineskip; here is an example: \starttext \def\startMyEnv{\dostartbuffer[MyEnv][startMyEnv][stopMyEnv]} \def\stopMyEnv{{\tfxx\getbuffer[MyEnv]\par}} \input tufte \startMyEnv \input knuth \stopMyEnv \input tufte \stoptext Am I doing something wrong here? \tfxx just switches a font and does not adapt the baseline use \switchtobodyfont[small] or \tfxx\setupinterlinespace instead - 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 ___
Re: [NTG-context] Two questions about buffers
Am 30.06.2012 um 14:25 schrieb Marcin Borkowski: Hello, I have two questions concerning buffers. 1. What is the difference between \grabbufferdata and \dostartbuffer? 2. I wanted to use buffers to define my own environment (as Wolfgang suggested to me a few days ago). However, there's a problem with \baselineskip; here is an example: \starttext \def\startMyEnv{\dostartbuffer[MyEnv][startMyEnv][stopMyEnv]} \def\stopMyEnv{{\tfxx\getbuffer[MyEnv]\par}} \input tufte \startMyEnv \input knuth \stopMyEnv \input tufte \stoptext Am I doing something wrong here? You can use the annotation module for your environment. \usemodule[annotation] \defineannotation[MyEnv][style=\txx] \starttext \input tufte \startMyEnv \input knuth \stopMyEnv \input tufte \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 ___
Re: [NTG-context] Two questions about buffers
Am 30.06.2012 um 14:25 schrieb Marcin Borkowski: Hello, I have two questions concerning buffers. 1. What is the difference between \grabbufferdata and \dostartbuffer? There is no difference, \grabbufferdata is just the new name for \dostartbuffer in MkIV and it’s recommended to use the name name. 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 ___
Re: [NTG-context] itemize in two columns and pagebreaks
Dnia 2012-06-29, o godz. 23:30:13 Marcin Borkowski mb...@wmi.amu.edu.pl napisał(a): Hello, I encountered a weird problem with \startitemize[columns] Namely, sometimes ConTeXt (MkIV) puts a pagebreak before the itemization. I tried to distill the problem to a minimal example, until now without success, but I'll post a ME if I'm able to reproduce a problem in a small file. OK, so I didn't succeed in isolating this problem. I attach the complete file (it's in Polish, sorry;)). The problem appears at page 3 in the resulting pdf (line 141 of the source file). Anybody encountered this, too? Are there any solutions/workarounds known? I naively tried putting \page[no] in various places around the problematic line, but to no avail. Also, while trying to isolate the problem, for instance by removing things before the itemization, it turned out that it's difficult to reproduce it: often, everything is fine (at the beginning of the page as well as near the end). Any ideas? -- Marcin Borkowski http://mbork.pl % Äwiczenia na Newtona o grach \mainlanguage[pl] \usetypescript[pagella] \setupbodyfont[pagella] \def\todo#1{{\em \kap{do dopisania}: #1}} \enablemode[nauczyciel] \def\startteacher{\grabbufferdata[teacher][startteacher][stopteacher]} \doifmodeelse{nauczyciel}{\def\stopteacher{\getbuffer[teacher]}}{\def\stopteacher{}} \def\startanswer{\grabbufferdata[answer][startanswer][stopanswer]} \doifmodeelse{nauczyciel}{\def\stopanswer{\blank[small]{\sl Odpowiedź.} \getbuffer[answer]}}{\def\stopanswer{}} \def\putdotafter#1{#1.} \setuphead[subsubject][style=bold,after={},alternative=text,distance=0.25em,textcommand=\putdotafter] \setuphead[section][numbercommand=\putdotafter] \setuphead[chapter][numbercommand=\putdotafter,page=no] \defineitemgroup[exercises] \setupitemgroup[exercises][1][n][before={},inbetween={\blank[medium]}] \def\ppauza{\unskip\kern.2em--\hskip.2em\ignorespaces} \starttext \startalignment[middle] \tfb Gry (materiaÅy na Äwiczenia w~czwartek) \par\blank[big] \stopalignment \completecontent \startchapter[title={Gry macierzowe}] \startexercises \startitem Jakie sÄ strategie optymalne dla obu graczy w~grze o~poniższej macierzy? \startformula \startmathmatrix[n=2,left={\left(\,},right={\,\right)},align=right] \NC 1 \NC 2 \NR \NC 3 \NC 4 \NR \stopmathmatrix \stopformula \startanswer Pierwszy gracz, wybierajÄ c drugi wiersz, w~każdym wypadku wygrywa wiÄcej, niż gdyby wybraÅ pierwszy; powinien wiÄc wybraÄ drugi wiersz (dominujÄ cy). Drugi gracz, wybierajÄ c pierwszÄ kolumnÄ, w~każdym przypadku traci mniej, niż gdyby wybraÅ drugÄ ; powinien wiÄc wybraÄ pierwszÄ (dominujÄ cÄ ) kolumnÄ. \stopanswer \stopitem \startitem Rozważmy grÄ z~nastÄpujÄ cÄ macierzÄ : \startformula \startmathmatrix[n=3,left={\left(\,},right={\,\right)},align=right] \NC 4 \NC 1 \NC -1 \NR \NC 0 \NC 1 \NC 6 \NR \NC 3 \NC 2 \NC 5 \NR \stopmathmatrix \stopformula Jaka jest optymalna strategia dla każdego z~graczy? \startanswer Å»aden wiersz ani kolumna nie sÄ dominujÄ ce, ale ponieważ \math{2} w~trzecim rzÄdzie i~drugiej kolumnie jest {\em najmniejszÄ } wartoÅciÄ w~swoim rzÄdzie i~{\em najwiÄkszÄ } wartoÅciÄ w~swojej kolumnie, optymalnÄ strategiÄ dla I~gracza jest trzecia, a~dla II~gracza druga. \stopanswer \stopitem \startitem Gra {\em parzyste czy nieparzyste} polega na tym, że dwóch graczy wybiera (równoczeÅnie) liczbÄ \math{1} lub~\math{2}. JeÅli suma wybranych liczb jest nieparzysta, wygrywa gracz~I; jeÅli jest parzysta, wygrywa gracz~II. Gracz, który przegraÅ, oddaje drugiemu kwotÄ równÄ sumie wybranych liczb. Narysuj macierz tej gry. Jaka jest optymalna strategia każdego z~graczy? Czy gra jest sprawiedliwa? \startanswer Macierz: \startformula \startmathmatrix[n=2,left={\left(\,},right={\,\right)},align=right] \NC -2 \NC 3 \NR \NC 3 \NC -4 \NR \stopmathmatrix \stopformula Powyższa macierz nie ma strategii dominujÄ cych ani punktów siodÅowych, trzeba wiÄc zastosowaÄ innÄ metodÄ. ZaÅóżmy, że gracz~I wybiera~\math{1} z~prawdopodobieÅstwem~\math{p} i~\math{2} z~prawdopodobieÅstwem~\math{1-p}. Wyznaczymy~\math{p} tak, żeby gracz~I wygrywaÅ przeciÄtnie {\em tyle samo}, obojÄtnie, co zrobi gracz~II. JeÅli gracz~II wybierze~\math{1}, przeciÄtna wygrana~I wynosi \math{-2p+3(1-p)}. JeÅli II wybierze~\math{2}, przeciÄtna wygrana~I wynosi~\math{3p-4(1-p)}. Aby wartoÅci te byÅy równe, musi byÄ \math{p=\frac{7}{12}}. Zatem gracz~I powinien wybraÄ~\math{1} z~prawdopodobieÅstwem \math{\frac{7}{12}}, a~\math{2} z~prawdopodobieÅstwem~\math{\frac{5}{12}}. Jego przeciÄtna wygrana
Re: [NTG-context] A problem with modes
Am 26.06.2012 um 22:12 schrieb Marcin Borkowski: Hello, this doesn't work for me: \definestartstop[amode][before={\startmode[a]}, after={\stopmode}] \starttext All modes. \startamode ``A'' mode. \stopamode \stoptext Can I use \startmode with \definestartstop? No you can’t. Or is there a better way to do something like this? It depends on what you want to do. You can create a buffer command: \def\startamode{\grabbufferdata[amode][startamode][stopamode]} %\def\stopamode {\getbuffer[amode]} \starttext All modes. \startamode “A” mode. \stopamode \stoptext or you use my annotation module: \usemodule[annotation] \defineannotation[amode][alternative=text] %\defineannotation[amode][alternative=none] \starttext All modes. \startamode “A” mode. \stopamode \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 ___
Re: [NTG-context] A problem with modes
Dnia 2012-06-26, o godz. 22:44:40 Wolfgang Schuster schuster.wolfg...@googlemail.com napisał(a): Am 26.06.2012 um 22:12 schrieb Marcin Borkowski: Hello, this doesn't work for me: \definestartstop[amode][before={\startmode[a]}, after={\stopmode}] \starttext All modes. \startamode ``A'' mode. \stopamode \stoptext Can I use \startmode with \definestartstop? No you can’t. I was afraid of this... Or is there a better way to do something like this? It depends on what you want to do. You can create a buffer command: \def\startamode{\grabbufferdata[amode][startamode][stopamode]} %\def\stopamode {\getbuffer[amode]} \starttext All modes. \startamode “A” mode. \stopamode \stoptext Thanks, it worked. One question: is there any difference between \def\starta{...} \def\stopa{...} and \definestartstop[a][before={...},after={...}] ? Wolfgang Best, -- Marcin Borkowski http://mbork.pl ___ 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] A problem with modes
Am 26.06.2012 um 23:25 schrieb Marcin Borkowski: Or is there a better way to do something like this? It depends on what you want to do. You can create a buffer command: \def\startamode{\grabbufferdata[amode][startamode][stopamode]} %\def\stopamode {\getbuffer[amode]} \starttext All modes. \startamode “A” mode. \stopamode \stoptext Thanks, it worked. One question: is there any difference between \def\starta{...} \def\stopa{...} and \definestartstop[a][before={...},after={…}] Yes because in my definition for \startamode I start a buffer which reads everything untill the delimiting \stopamode and stores it in memory, afterwards you can access the stored content with \getbuffer[…]. When you use \definestartstop to create the environment you have only two commands which perform a few things at the begin and end of the environment but you can do much with the content itself, the only way to gobble the content is to store it in a box but than the buffer method is easier. 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 ___