From: Henning Hraban Ramm <texml@fiee.net>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: [NTG-context] how to define an environment with key=value arguments
Date: Fri, 8 Sep 2023 12:22:51 +0200 [thread overview]
Message-ID: <dc07763d-d4a8-a0f5-cccc-e7f47b7d1778@fiee.net> (raw)
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
___________________________________________________________________________________
next reply other threads:[~2023-09-08 10:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-08 10:22 Henning Hraban Ramm [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dc07763d-d4a8-a0f5-cccc-e7f47b7d1778@fiee.net \
--to=texml@fiee.net \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).