Combine \setupdelimitedtext with an author (define custom variable?)
Hi, I like to achieve something that looks like this: ``` \definedelimitedtext[extract][blockquote] \setupdelimitedtext [extract] [leftmargin=1.5pc, style={\italic}, before={\setupindenting[next]}, after={\blank[1ex] \hrule \blank[1ex] \startalignment[flushright] \tfx\italic{René Descartes} \stopalignment}] \starttext \startextract Cogito ergo sum. \stopextract \stoptext ``` So it should setup a quotation and mentions the author. However, here the author is hardcoded within the blockquote. I would like it to use like this: ``` \definedelimitedtext[extract][blockquote] \setupdelimitedtext [extract] [leftmargin=1.5pc, style={\italic}, before={\setupindenting[next]}, after={\blank[1ex] \hrule \blank[1ex] \startalignment[flushright] \tfx\italic{\getcustomvariable{author}} \stopalignment}] \starttext \startextract[author=René Descartes] Cogito ergo sum. \stopextract \stoptext ``` Is there an easy way to achieve that? I tried with \structureuservariable (like possible in \startchapter) but it does not work. Best, Gerion
On 6/6/2024 12:30 PM, Gerion Entrup wrote:
Hi,
I like to achieve something that looks like this: ``` \definedelimitedtext[extract][blockquote] \setupdelimitedtext [extract] [leftmargin=1.5pc, style={\italic}, before={\setupindenting[next]}, after={\blank[1ex] \hrule \blank[1ex] \startalignment[flushright] \tfx\italic{René Descartes} \stopalignment}]
\starttext \startextract Cogito ergo sum. \stopextract \stoptext ```
So it should setup a quotation and mentions the author. However, here the author is hardcoded within the blockquote. I would like it to use like this: ``` \definedelimitedtext[extract][blockquote] \setupdelimitedtext [extract] [leftmargin=1.5pc, style={\italic}, before={\setupindenting[next]}, after={\blank[1ex] \hrule \blank[1ex] \startalignment[flushright] \tfx\italic{\getcustomvariable{author}} \stopalignment}]
\starttext \startextract[author=René Descartes] Cogito ergo sum. \stopextract \stoptext ```
Is there an easy way to achieve that? I tried with \structureuservariable (like possible in \startchapter) but it does not work.
not all constructs hav ethese user variables (yet) i'll add an option for arguments tostart/stop so that you can do \starttext \definedelimitedtext [dextract] [blockquote] [leftmargin=1.5pc, style=italic, before=\setupindenting[next], after=\setups{extract:whatever}] \definestartstop [extract] [arguments=yes, before=\setups{extract:start}, after=\setups{extract:stop}] \startsetups extract:start \startdextract \stopsetups \startsetups extract:stop \startstopparameter{author} \stopdextract \blank[1ex,samepage] \hrule \blank[1ex,samepage] \dontleavehmode \wordright{\itx\startstopparameter{author}} \stopsetups \starttext \startextract[author=René Descartes] Cogito ergo sum. \stopextract \stoptext but first i want Wolfgang to check the patch, 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 -----------------------------------------------------------------
Am Donnerstag, 6. Juni 2024, 13:51:53 MESZ schrieb Hans Hagen via ntg-context:
On 6/6/2024 12:30 PM, Gerion Entrup wrote:
Hi,
I like to achieve something that looks like this: ``` \definedelimitedtext[extract][blockquote] \setupdelimitedtext [extract] [leftmargin=1.5pc, style={\italic}, before={\setupindenting[next]}, after={\blank[1ex] \hrule \blank[1ex] \startalignment[flushright] \tfx\italic{René Descartes} \stopalignment}]
\starttext \startextract Cogito ergo sum. \stopextract \stoptext ```
So it should setup a quotation and mentions the author. However, here the author is hardcoded within the blockquote. I would like it to use like this: ``` \definedelimitedtext[extract][blockquote] \setupdelimitedtext [extract] [leftmargin=1.5pc, style={\italic}, before={\setupindenting[next]}, after={\blank[1ex] \hrule \blank[1ex] \startalignment[flushright] \tfx\italic{\getcustomvariable{author}} \stopalignment}]
\starttext \startextract[author=René Descartes] Cogito ergo sum. \stopextract \stoptext ```
Is there an easy way to achieve that? I tried with \structureuservariable (like possible in \startchapter) but it does not work.
not all constructs hav ethese user variables (yet)
i'll add an option for arguments tostart/stop so that you can do
\starttext
\definedelimitedtext [dextract] [blockquote] [leftmargin=1.5pc, style=italic, before=\setupindenting[next], after=\setups{extract:whatever}]
\definestartstop [extract] [arguments=yes, before=\setups{extract:start}, after=\setups{extract:stop}]
\startsetups extract:start \startdextract \stopsetups
\startsetups extract:stop \startstopparameter{author} \stopdextract \blank[1ex,samepage] \hrule \blank[1ex,samepage] \dontleavehmode \wordright{\itx\startstopparameter{author}} \stopsetups
\starttext
\startextract[author=René Descartes] Cogito ergo sum. \stopextract
\stoptext
but first i want Wolfgang to check the patch,
For me, Wolfgang's answer fulfills all my needs. So, from my point of view, this is not needed anymore. Thank you for your effort anyway! Gerion
Gerion Entrup schrieb am 06.06.2024 um 12:30:
Hi,
I like to achieve something that looks like this: ``` \definedelimitedtext[extract][blockquote] \setupdelimitedtext [extract] [leftmargin=1.5pc, style={\italic}, before={\setupindenting[next]}, after={\blank[1ex] \hrule \blank[1ex] \startalignment[flushright] \tfx\italic{René Descartes} \stopalignment}]
\starttext \startextract Cogito ergo sum. \stopextract \stoptext ```
So it should setup a quotation and mentions the author. However, here the author is hardcoded within the blockquote. I would like it to use like this: ``` \definedelimitedtext[extract][blockquote] \setupdelimitedtext [extract] [leftmargin=1.5pc, style={\italic}, before={\setupindenting[next]}, after={\blank[1ex] \hrule \blank[1ex] \startalignment[flushright] \tfx\italic{\getcustomvariable{author}} \stopalignment}]
\starttext \startextract[author=René Descartes] Cogito ergo sum. \stopextract \stoptext ```
Is there an easy way to achieve that? I tried with \structureuservariable (like possible in \startchapter) but it does not work.
\startsetups [userdata:extract] \startnarrower \setupindenting[next] \getuserdata \hairline \dontleavehmode\wordright{\itx\userdataparameter{author}} \stopnarrower \stopsetups \defineuserdataalternative [extract] [renderingsetup=userdata:extract] \defineuserdata [extract] [style=italic, alternative=extract] \starttext \startextract[author=René Descartes] Cogito ergo sum. \stopextract \stoptext Wolfgang
On 6/6/2024 4:34 PM, Wolfgang Schuster wrote:
Gerion Entrup schrieb am 06.06.2024 um 12:30:
Hi,
I like to achieve something that looks like this: ``` \definedelimitedtext[extract][blockquote] \setupdelimitedtext [extract] [leftmargin=1.5pc, style={\italic}, before={\setupindenting[next]}, after={\blank[1ex] \hrule \blank[1ex] \startalignment[flushright] \tfx\italic{René Descartes} \stopalignment}]
\starttext \startextract Cogito ergo sum. \stopextract \stoptext ```
So it should setup a quotation and mentions the author. However, here the author is hardcoded within the blockquote. I would like it to use like this: ``` \definedelimitedtext[extract][blockquote] \setupdelimitedtext [extract] [leftmargin=1.5pc, style={\italic}, before={\setupindenting[next]}, after={\blank[1ex] \hrule \blank[1ex] \startalignment[flushright] \tfx\italic{\getcustomvariable{author}} \stopalignment}]
\starttext \startextract[author=René Descartes] Cogito ergo sum. \stopextract \stoptext ```
Is there an easy way to achieve that? I tried with \structureuservariable (like possible in \startchapter) but it does not work.
\startsetups [userdata:extract] \startnarrower \setupindenting[next] \getuserdata \hairline \dontleavehmode\wordright{\itx\userdataparameter{author}} \stopnarrower \stopsetups
\defineuserdataalternative [extract] [renderingsetup=userdata:extract]
\defineuserdata [extract] [style=italic, alternative=extract]
\starttext
\startextract[author=René Descartes] Cogito ergo sum. \stopextract
\stoptext ah, i start forgetting about these mechanisms ... i added this example to th etest suite
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 -----------------------------------------------------------------
Am Donnerstag, 6. Juni 2024, 16:34:03 MESZ schrieb Wolfgang Schuster:
Gerion Entrup schrieb am 06.06.2024 um 12:30:
Hi,
I like to achieve something that looks like this: ``` \definedelimitedtext[extract][blockquote] \setupdelimitedtext [extract] [leftmargin=1.5pc, style={\italic}, before={\setupindenting[next]}, after={\blank[1ex] \hrule \blank[1ex] \startalignment[flushright] \tfx\italic{René Descartes} \stopalignment}]
\starttext \startextract Cogito ergo sum. \stopextract \stoptext ```
So it should setup a quotation and mentions the author. However, here the author is hardcoded within the blockquote. I would like it to use like this: ``` \definedelimitedtext[extract][blockquote] \setupdelimitedtext [extract] [leftmargin=1.5pc, style={\italic}, before={\setupindenting[next]}, after={\blank[1ex] \hrule \blank[1ex] \startalignment[flushright] \tfx\italic{\getcustomvariable{author}} \stopalignment}]
\starttext \startextract[author=René Descartes] Cogito ergo sum. \stopextract \stoptext ```
Is there an easy way to achieve that? I tried with \structureuservariable (like possible in \startchapter) but it does not work.
\startsetups [userdata:extract] \startnarrower \setupindenting[next] \getuserdata \hairline \dontleavehmode\wordright{\itx\userdataparameter{author}} \stopnarrower \stopsetups
\defineuserdataalternative [extract] [renderingsetup=userdata:extract]
\defineuserdata [extract] [style=italic, alternative=extract]
\starttext
\startextract[author=René Descartes] Cogito ergo sum. \stopextract
\stoptext
Really cool! Thank you. If I see it right, this is completely generic, so with this it is possible to define any start<something> stop<something> with completely variable arguments. Gerion
Am Donnerstag, 6. Juni 2024, 16:34:03 MESZ schrieb Wolfgang Schuster:
\startsetups [userdata:extract] \startnarrower \setupindenting[next] \getuserdata \hairline \dontleavehmode\wordright{\itx\userdataparameter{author}} \stopnarrower \stopsetups
\defineuserdataalternative [extract] [renderingsetup=userdata:extract]
\defineuserdata [extract] [style=italic, alternative=extract]
\starttext
\startextract[author=René Descartes] Cogito ergo sum. \stopextract
\stoptext
Wolfgang
I tried to combine this with the code of the mail thread: "setuphead in connection with the command argument" but had not luck. ConTeXt always stops with: ``` close source > level 1, order 2, name './mwe.tex' tex error > runaway error: end of file encountered mtx-context | fatal error: return code: 1 ``` Here is the MWE: ``` \startsetups [userdata:extract] \getuserdata \hairline \itx\userdataparameter{author} \stopsetups % original definition (also does not work) % \startsetups [userdata:extract] % \startnarrower % \setupindenting[next] % \getuserdata % \hairline % \dontleavehmode\wordright{\itx\userdataparameter{author}} % \stopnarrower % \stopsetups \defineuserdataalternative [extract] [renderingsetup=userdata:extract] \defineuserdata [extract] [style=italic, alternative=extract] \defineframed[chapter_frame][ width=\textwidth, align=flushright, offset=0pt, rulethickness=0pt ] \startsetups[my_chapter] \startlocalheadsetup \startframed[chapter_frame] \blank[2cm] \startfont[Serif sa 8] \color[darkgray]{\headnumbercontent} \stopfont \blank[5mm] \startfont[SerifBold sa 2] \color[m-indigo-800]{\headtextcontent} \stopfont \blank[1cm] \startfont[SerifBold sa 1.5] \color[m-indigo-800]{\structureuservariable{subtitle}} \stopfont \blank[3cm] \startextract[author={\structureuservariable{quoteauthor}}] \structureuservariable{quote} \stopextract \stopframed \stoplocalheadsetup \stopsetups \defineheadalternative[chap][renderingsetup=my_chapter] \setuphead[title, chapter][ alternative=chap, after={\page[yes]}, sectionsegments=2:2, header=high, footer=high, style= ] \starttext % embedded startextract into startchapter does not work \startchapter[title=Foo][subtitle=bla, quoteauthor={René Descartes}, quote={% Cogito ergo sum. }] \stopchapter \startextract[author=René Descartes] Cogito ergo sum. \stopextract \stoptext ``` I also tried to combine it less interleaved, but it fails with the same error: ``` \startsetups [userdata:extract] \getuserdata \hairline \itx\userdataparameter{author} \stopsetups % original definition (also does not work) % \startsetups [userdata:extract] % \startnarrower % \setupindenting[next] % \getuserdata % \hairline % \dontleavehmode\wordright{\itx\userdataparameter{author}} % \stopnarrower % \stopsetups \defineuserdataalternative [extract] [renderingsetup=userdata:extract] \defineuserdata [extract] [style=italic, alternative=extract] \defineframed[chapter_frame][ width=\textwidth, align=flushright, offset=0pt, rulethickness=0pt ] \defineframed[chapter_quote][ width=\textwidth, align=flushright, offset=0pt, rulethickness=0pt ] \startsetups[my_chapter] \startlocalheadsetup \startframed[chapter_frame] \blank[2cm] \startfont[Serif sa 8] \color[darkgray]{\headnumbercontent} \stopfont \blank[5mm] \startfont[SerifBold sa 2] \color[m-indigo-800]{\headtextcontent} \stopfont \blank[1cm] \startfont[SerifBold sa 1.5] \color[m-indigo-800]{\structureuservariable{subtitle}} \stopfont \blank[3cm] \startframed[chapter_quote] \structureuservariable{quote} \stopframed \stopframed \stoplocalheadsetup \stopsetups \defineheadalternative[chap][renderingsetup=my_chapter] \setuphead[title, chapter][ alternative=chap, after={\page[yes]}, sectionsegments=2:2, header=high, footer=high, style= ] \starttext % embedded startextract into startchapter does not work \startchapter[title=Foo][subtitle=bla, quote={% \startextract[author=René Descartes] Cogito ergo sum. \stopextract }] \stopchapter \startchapter[title=Foo][subtitle=bla, quote={bla}] \startextract[author=René Descartes] Cogito ergo sum. \stopextract \stopchapter \stoptext ``` Do you know where the problem is? Gerion
Gerion Entrup schrieb am 17.06.2024 um 13:04:
Am Donnerstag, 6. Juni 2024, 16:34:03 MESZ schrieb Wolfgang Schuster:
[...]
Wolfgang
I tried to combine this with the code of the mail thread: "setuphead in connection with the command argument" but had not luck. ConTeXt always stops with: ``` close source > level 1, order 2, name './mwe.tex' tex error > runaway error: end of file encountered mtx-context | fatal error: return code: 1 ```
Here is the MWE: ``` [...]
\startsetups[my_chapter] \startlocalheadsetup \startframed[chapter_frame] \blank[2cm] \startfont[Serif sa 8] \color[darkgray]{\headnumbercontent} \stopfont \blank[5mm] \startfont[SerifBold sa 2] \color[m-indigo-800]{\headtextcontent} \stopfont \blank[1cm] \startfont[SerifBold sa 1.5] \color[m-indigo-800]{\structureuservariable{subtitle}} \stopfont \blank[3cm] \startextract[author={\structureuservariable{quoteauthor}}] \structureuservariable{quote} \stopextract \stopframed \stoplocalheadsetup \stopsetups
The userdata environment uses the buffer mechanism of Context which has a few limitations where you can use it, e.g. putting the environment in the arguments of other commands (like the setup-environment above) fails. One way to avoid this is to replace the \startextract ... \stopextract in this case with the code for the quoted text, another way is to put all content in a buffer and just load the buffer in the setups-environment. \startbuffer[my_chapter] \startlocalheadsetup \startframed[chapter_frame] ... \stopframed \stoplocalheadsetup \stopbuffer \startsetups[my_chapter] \getbuffer[my_chapter] \stopsetups Wolfgang
Am Montag, 17. Juni 2024, 21:20:19 MESZ schrieb Wolfgang Schuster:
Gerion Entrup schrieb am 17.06.2024 um 13:04:
Am Donnerstag, 6. Juni 2024, 16:34:03 MESZ schrieb Wolfgang Schuster:
[...]
Wolfgang
I tried to combine this with the code of the mail thread: "setuphead in connection with the command argument" but had not luck. ConTeXt always stops with: ``` close source > level 1, order 2, name './mwe.tex' tex error > runaway error: end of file encountered mtx-context | fatal error: return code: 1 ```
Here is the MWE: ``` [...]
\startsetups[my_chapter] \startlocalheadsetup \startframed[chapter_frame] \blank[2cm] \startfont[Serif sa 8] \color[darkgray]{\headnumbercontent} \stopfont \blank[5mm] \startfont[SerifBold sa 2] \color[m-indigo-800]{\headtextcontent} \stopfont \blank[1cm] \startfont[SerifBold sa 1.5] \color[m-indigo-800]{\structureuservariable{subtitle}} \stopfont \blank[3cm] \startextract[author={\structureuservariable{quoteauthor}}] \structureuservariable{quote} \stopextract \stopframed \stoplocalheadsetup \stopsetups
The userdata environment uses the buffer mechanism of Context which has a few limitations where you can use it, e.g. putting the environment in the arguments of other commands (like the setup-environment above) fails. One way to avoid this is to replace the \startextract ... \stopextract in this case with the code for the quoted text, another way is to put all content in a buffer and just load the buffer in the setups-environment.
\startbuffer[my_chapter] \startlocalheadsetup \startframed[chapter_frame] ... \stopframed \stoplocalheadsetup \stopbuffer
\startsetups[my_chapter] \getbuffer[my_chapter] \stopsetups
Wolfgang
Thanks, I solved it by embedding the extract code directly (more less). Gerion
participants (3)
-
Gerion Entrup
-
Hans Hagen
-
Wolfgang Schuster