Re: [NTG-context] source code and result side by side
Am 2017-08-04 um 06:30 schrieb Henri Menke : > On 08/04/2017 07:46 AM, Henning Hraban Ramm wrote: >> Am 2017-07-31 um 03:26 schrieb Aditya Mahajan : >> >>> 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 : > 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 : > 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 : 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 ___
Re: [NTG-context] source code and result side by side
On 07/30/2017 07:13 PM, Henning Hraban Ramm wrote: > [...] > 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}} > > Compilation just stops, maybe some infinite loop? This is what I get from your sample above. > Simpler: > > \def\CodeExample#1{% > \startTEX > #1 > \stopTEX > #1 > } > > Stops with the error: Without or without definitions, there should be no expansion inside \starttyping...\stoptyping. Even with some expansion, I get an infinite loop: \starttext \setuptyping[TEX][escape=yes] \def\CodeExample#1{% \startTEX /BTEX #1/ETEX \stopTEX #1 } \CodeExample{\framed[frame=off,leftframe=on,rulethickness=1em,framecolor=blue]{Klotz am Bein}} \stoptext Pablo -- http://www.ousia.tk ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] source code and result side by side
Am 2017-07-29 um 00:57 schrieb Aditya Mahajan : > 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}} Compilation just stops, maybe some infinite loop? Simpler: \def\CodeExample#1{% \startTEX #1 \stopTEX #1 } Stops with the error: Use of \m_syst_action_yes doesn't match its definition 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 07/29/2017 10:58 AM, Pablo Rodriguez wrote: > On 07/29/2017 12:57 AM, Aditya Mahajan wrote: >> [...] >> \placesidebyside >> {\typebuffer[example-1]} >> {\getbuffer[setups, example-1]} > [...] > Is there now hay to avoid the forced horizontal mode on both sides? Replying to my own question, a fast fix (although far from perfect) would be using xtables: \def\replacesidebyside#1{% \blank\startembeddedxtable[frame=off, option=stretch] \startxrow \startxcell\typebuffer[#1][option=TEX]\stopxcell \startxcell\getbuffer[setups, #1]\stopxcell \stopxrow \stopembeddedxtable\blank} \def\replaceontopofeachother#1{% \blank\startembeddedxtable[frame=off, option=stretch] \startxrow \startxcell\typebuffer[#1][option=TEX]\stopxcell \stopxrow \startxrow[toffset=1em, split=yes] \startxcell\getbuffer[setups, #1]\stopxcell \stopxrow \stopembeddedxtable\blank} \starttext \startbuffer[example-1] \setupexternalfigures[location=default] \starttext \ConTeXt\ is awesome! \externalfigure[cow.pdf][scale=250] \stoptext \stopbuffer Frames won’t be split accross pages. There may be other issues, but none tham I’m aware of ;-). Just in case it helps, Pablo -- http://www.ousia.tk ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] source code and result side by side
On 07/29/2017 12:57 AM, Aditya Mahajan wrote: > [...] > \startbuffer[example-1] > > \stopbuffer > > > \placesidebyside > {\typebuffer[example-1]} > {\getbuffer[setups, example-1]} Many thanks for your suggestion, Aditya. I’m afraid everything is forced to be in horizontal mode: \starttext \startbuffer[example-1] \setupexternalfigures[location=default] \starttext \ConTeXt\ is awesome! \externalfigure[cow.pdf][scale=250] \stoptext \stopbuffer \placesidebyside {\typebuffer[example-1]} {\getbuffer[setups, example-1]} \stoptext \placeontopofeachother has the same feature. This causes that \placefigure cannot be used. Is there now hay to avoid the forced horizontal mode on both sides? Many thanks for your help, Pablo -- http://www.ousia.tk ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] source code and result side by side
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]} 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 ___