ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [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

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;
as well as URLs for NNTP newsgroup(s).