* [NTG-context] how to define an environment with key=value arguments
@ 2023-09-08 10:22 Henning Hraban Ramm
2023-09-08 10:35 ` [NTG-context] " Wolfgang Schuster
0 siblings, 1 reply; 7+ messages in thread
From: Henning Hraban Ramm @ 2023-09-08 10:22 UTC (permalink / raw)
To: mailing list for ConTeXt users
Hi,
for an involved image placement (full page image starting each chapter,
several stacked elements), I’d like an environment that accepts
key-value arguments, like
\startMyFigure[page=left,title={My caption}]
\externalfigure[dummy]…
\stopMyFigure
I don’t think that a real float makes sense, even if the interface looks
similar, since it’s always a full page in a fixed place, I need no
numbering and can place the caption myself.
Does it make sense to use \definestartstop?
How would I “plugin“ the argument handling?
Or should I better define start and stop separately?
\def\startMyFigure[#1]{
% e.g. use utilities.parsers.settings_to_hash(#1)
}
\def\stopMyFigure{}
Probably I’ll need to catch the content (\externalfigure, might become
more) and use it in a \setlayer – so perhaps something like
\definebuffer[MyFigure]
\define\stopMyFigure{%
\setlayer[page]{\getMyFigure}}}
}
?
But then I don’t know how to handle the arguments.
Probably it makes most sense to do it in Lua, like
\startluacode
interfaces.implement {
name = "startMyFigure",
public = true,
arguments = {"hash",},
actions = function(h, a)
-- …
end, }
\stopluacode
But I didn’t find how to do environments.
Hraban
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* [NTG-context] Re: how to define an environment with key=value arguments
2023-09-08 10:22 [NTG-context] how to define an environment with key=value arguments Henning Hraban Ramm
@ 2023-09-08 10:35 ` Wolfgang Schuster
2023-09-08 11:09 ` Henning Hraban Ramm
0 siblings, 1 reply; 7+ messages in thread
From: Wolfgang Schuster @ 2023-09-08 10:35 UTC (permalink / raw)
To: mailing list for ConTeXt users, Henning Hraban Ramm
Henning Hraban Ramm schrieb am 08.09.2023 um 12:22:
> Hi,
> for an involved image placement (full page image starting each
> chapter, several stacked elements), I’d like an environment that
> accepts key-value arguments, like
>
> \startMyFigure[page=left,title={My caption}]
> \externalfigure[dummy]…
> \stopMyFigure
>
> I don’t think that a real float makes sense, even if the interface
> looks similar, since it’s always a full page in a fixed place, I need
> no numbering and can place the caption myself.
>
> Does it make sense to use \definestartstop?
> How would I “plugin“ the argument handling?
>
>
> Or should I better define start and stop separately?
>
> \def\startMyFigure[#1]{
> % e.g. use utilities.parsers.settings_to_hash(#1)
> }
> \def\stopMyFigure{}
>
>
> Probably I’ll need to catch the content (\externalfigure, might become
> more) and use it in a \setlayer – so perhaps something like
>
> \definebuffer[MyFigure]
> \define\stopMyFigure{%
> \setlayer[page]{\getMyFigure}}}
> }
>
> ?
> But then I don’t know how to handle the arguments.
>
> Probably it makes most sense to do it in Lua, like
>
> \startluacode
> interfaces.implement {
> name = "startMyFigure",
> public = true,
> arguments = {"hash",},
> actions = function(h, a)
> -- …
> end, }
> \stopluacode
>
> But I didn’t find how to do environments.
When you just need an environment with a optional argument to pass user
values you can
use the userdata environment but be aware that you have some limitations
(like verbatim)
because the mechanism uses a buffer to store the content.
For images (and other content) which are placed on a separate page at
the start of a chapter
you can use the pageinjection mechanism which was added for this purpose.
Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* [NTG-context] Re: how to define an environment with key=value arguments
2023-09-08 10:35 ` [NTG-context] " Wolfgang Schuster
@ 2023-09-08 11:09 ` Henning Hraban Ramm
2023-09-08 14:21 ` Wolfgang Schuster
0 siblings, 1 reply; 7+ messages in thread
From: Henning Hraban Ramm @ 2023-09-08 11:09 UTC (permalink / raw)
To: mailing list for ConTeXt users
Am 08.09.23 um 12:35 schrieb Wolfgang Schuster:
> For images (and other content) which are placed on a separate page at
> the start of a chapter
> you can use the pageinjection mechanism which was added for this purpose.
Thank you!
You’re right, that might be enough.
(Documented only in https://wiki.contextgarden.net/Command/setuphead so
far. Even the source browser can’t find anything.)
But my “image” consists of a background color (with bleed), a
transparent overlay image (with bleed), a tilted image with a shadow on
top and a caption (so far) – and pageinjection looks fixed to one image.
How can I hook my own placement code in there?
Hraban
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* [NTG-context] Re: how to define an environment with key=value arguments
2023-09-08 11:09 ` Henning Hraban Ramm
@ 2023-09-08 14:21 ` Wolfgang Schuster
2023-09-08 15:02 ` Henning Hraban Ramm
0 siblings, 1 reply; 7+ messages in thread
From: Wolfgang Schuster @ 2023-09-08 14:21 UTC (permalink / raw)
To: mailing list for ConTeXt users, Henning Hraban Ramm
Henning Hraban Ramm schrieb am 08.09.2023 um 13:09:
> Am 08.09.23 um 12:35 schrieb Wolfgang Schuster:
>
>> For images (and other content) which are placed on a separate page at
>> the start of a chapter
>> you can use the pageinjection mechanism which was added for this
>> purpose.
>
> Thank you!
> You’re right, that might be enough.
>
> (Documented only in https://wiki.contextgarden.net/Command/setuphead
> so far. Even the source browser can’t find anything.)
https://source.contextgarden.net/tex/context/base/mkxl/page-inj.mklx
> But my “image” consists of a background color (with bleed), a
> transparent overlay image (with bleed), a tilted image with a shadow
> on top and a caption (so far) – and pageinjection looks fixed to one
> image. How can I hook my own placement code in there?
We can discuss the details next week and you put the resulting template
on the wiki.
Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* [NTG-context] Re: how to define an environment with key=value arguments
2023-09-08 14:21 ` Wolfgang Schuster
@ 2023-09-08 15:02 ` Henning Hraban Ramm
2023-09-08 17:37 ` Henning Hraban Ramm
0 siblings, 1 reply; 7+ messages in thread
From: Henning Hraban Ramm @ 2023-09-08 15:02 UTC (permalink / raw)
To: mailing list for ConTeXt users
Am 08.09.23 um 16:21 schrieb Wolfgang Schuster:
> Henning Hraban Ramm schrieb am 08.09.2023 um 13:09:
>> Am 08.09.23 um 12:35 schrieb Wolfgang Schuster:
>>
>>> For images (and other content) which are placed on a separate page at
>>> the start of a chapter
>>> you can use the pageinjection mechanism which was added for this
>>> purpose.
>>
>> Thank you!
>> You’re right, that might be enough.
>>
>> (Documented only in https://wiki.contextgarden.net/Command/setuphead
>> so far. Even the source browser can’t find anything.)
> https://source.contextgarden.net/tex/context/base/mkxl/page-inj.mklx
Seems like I didn’t search right (just “pageinjections“?)
>> But my “image” consists of a background color (with bleed), a
>> transparent overlay image (with bleed), a tilted image with a shadow
>> on top and a caption (so far) – and pageinjection looks fixed to one
>> image. How can I hook my own placement code in there?
> We can discuss the details next week and you put the resulting template
> on the wiki.
Ah, I guess I understand the template mechanism. Yet again glorious
setups. Will probably manage.
Hraban
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* [NTG-context] Re: how to define an environment with key=value arguments
2023-09-08 15:02 ` Henning Hraban Ramm
@ 2023-09-08 17:37 ` Henning Hraban Ramm
2023-09-09 10:56 ` Henning Hraban Ramm
0 siblings, 1 reply; 7+ messages in thread
From: Henning Hraban Ramm @ 2023-09-08 17:37 UTC (permalink / raw)
To: ntg-context
Am 08.09.23 um 17:02 schrieb Henning Hraban Ramm:
>> We can discuss the details next week and you put the resulting
>> template on the wiki.
>
> Ah, I guess I understand the template mechanism. Yet again glorious
> setups. Will probably manage.
So far:
\definepageinjection[chapter:start][
page=left,
alternative=setups,
setups=frontispiz,
color=white,
background=color,
backgroundcolor=Eifel,
]
\startsetups[frontispiz]
\starttransparent[tlumi]%
\externalfigure[\structureuservariable{image}][
width=\measure{MaxWidth},
]%
\stoptransparent%
\stopsetups
\setuphead[chapter][
page=right,
style=\ChapterFont,
beforesection={\pageinjection[chapter:start]},
command=\ChapterStart,
before={\startcolumnset[Spalten]},
after={\vskip-\lineheight}, % fix column start
inbetween=,
aftersection={\stopcolumnset},
]
\startchapter[title={Prolog 2: Reiseführer}][
motto={(quotation.}}, % used in \ChapterStart
image={00 Lavakeller Mendig g}, % wrong
blank=2,
]
Not a MWE, I know.
Here’s a screenshot:
https://yemaya.fiee.net/s/G2NcwE8qQrLAx8B
(Funny, I never needed all of before, after, beforesection and
aftersection so far.)
The injection is a frame, that’s great, because I can set the
background, and \externalfigure starts at (0,0).
But it uses its own page size, I don’t understand why. I need the
bleed/trim area.
If I use \setlayer in the setup, the content gets placed on the next
page, i.e. under the text.
\structureuservariable{image} in the setup gets the value from the
_next_ chapter. Maybe the approach in from the source with
\dummyparameter\c!name
would work better, but I don’t know how to transfer it.
Hraban
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* [NTG-context] Re: how to define an environment with key=value arguments
2023-09-08 17:37 ` Henning Hraban Ramm
@ 2023-09-09 10:56 ` Henning Hraban Ramm
0 siblings, 0 replies; 7+ messages in thread
From: Henning Hraban Ramm @ 2023-09-09 10:56 UTC (permalink / raw)
To: ntg-context
Am 08.09.23 um 19:37 schrieb Henning Hraban Ramm:
> But it uses its own page size, I don’t understand why. I need the
> bleed/trim area.
>
> If I use \setlayer in the setup, the content gets placed on the next
> page, i.e. under the text.
>
> \structureuservariable{image} in the setup gets the value from the
> _next_ chapter. Maybe the approach in from the source with
> \dummyparameter\c!name
> would work better, but I don’t know how to transfer it.
I gave up, ran into too many problems.
Tried to avoid injections and put everything in before/beforesection
macros, but \structureuservariable there also always picks up the values
from the next chapter (while I would expect the current or maybe the
previous).
So I copy-pasted the whole bunch of ugly commands in front of every
chapter, and it works.
It’s only for one book with 18 chapters, doesn’t make much sense to
spend even more time on a more elegant solution.
Hraban
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-09-09 10:59 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-08 10:22 [NTG-context] how to define an environment with key=value arguments Henning Hraban Ramm
2023-09-08 10:35 ` [NTG-context] " Wolfgang Schuster
2023-09-08 11:09 ` Henning Hraban Ramm
2023-09-08 14:21 ` Wolfgang Schuster
2023-09-08 15:02 ` Henning Hraban Ramm
2023-09-08 17:37 ` Henning Hraban Ramm
2023-09-09 10:56 ` Henning Hraban Ramm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox