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
___________________________________________________________________________________