From: Hans Hagen via ntg-context <ntg-context@ntg.nl>
To: Andres Conrado Montoya <andresconrado@gmail.com>,
mailing list for ConTeXt users <ntg-context@ntg.nl>
Cc: Hans Hagen <j.hagen@freedom.nl>
Subject: [NTG-context] Re: Better option for a macro with lots of arguments
Date: Wed, 23 Aug 2023 10:07:40 +0200 [thread overview]
Message-ID: <2bc1ea1a-e040-f98a-7f9d-37ab77363336@freedom.nl> (raw)
In-Reply-To: <CAGhDZhAHMv5kZUYgncXKB0iHV-hv2=wQTwcg65CpOgy-dGXhhg@mail.gmail.com>
On 8/23/2023 4:12 AM, Andres Conrado Montoya wrote:
> I have been using the following macro to add a bunch of sections to the
> start of chapters in a book, it works but I think is kind of weak:
>
> %%%%%%%%%%%%%%%%%%%
>
> \define[7]\metadatos{
> \startsection[title={Resumen}] #1 \stopsection
> \startsection[title={Palabras clave}] #2 \stopsection
> \start
> \language[en]
> \startsection[title={Abstract}] #3 \stopsection
> \startsection[title={Keywords}] #4 \stopsection
> \stop
> \startsection[title={¿Cómo citar este capítulo? / How to cite this book?}]
> \startsubsection[title={Apa}] #5 \stopsubsection
> \startsubsection[title={Chicago}] #6 \stopsubsection
> \startsubsection[title={MLA}] #7 \stopsubsection
> \stopsection
> }
>
> \starttext
> % Then I call the macro like this:
> \metadatos{spanish abstract \input knuth}{some, comma, separated, keywords,
> in, spanish}{english abstract \input knuth}{same, comma, separated,
> keywords, in, english}{Apa citation style for this article}{Chicago
> citation style for this article}{MLA citation style for this article}
> \stoptext
> %%%%%%%%%%%%%%%%%%%
>
> I've been exploring different ways to do it better, but with not much luck,
> I was thinking something based in key=value assignments? setups? datasets?
> Not really sure, but If you know a better solution or point me in the
> direction of something I can use to replace that macro, it would be greatly
> appreciated.
\startsetups [document:start]
\doifdocumentvariable {englishabstract} {
\startsection[title={Resumen}]
\documentvariable{englishabstract}
\stopsection
}
\doifdocumentvariable {spanisabstract} {
\startsection[title={Palabras clave}]
\documentvariable{spanishabstract}
\stopsection
}
...
\stopsetups
\startbuffer english
...
\stopbuffer
\startbuffer spanish
...
\stopbuffer
\startsetups [document:stop]
...
\stopsetups
\startdocument
[spanisabstract={\getbuffer[spanish]},
....]
...
\stopdocument
untested, just keyed in
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________
prev parent reply other threads:[~2023-08-23 8:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-23 2:12 [NTG-context] " Andres Conrado Montoya
2023-08-23 8:07 ` Hans Hagen via ntg-context [this message]
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=2bc1ea1a-e040-f98a-7f9d-37ab77363336@freedom.nl \
--to=ntg-context@ntg.nl \
--cc=andresconrado@gmail.com \
--cc=j.hagen@freedom.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).