ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] Better option for a macro with lots of arguments
@ 2023-08-23  2:12 Andres Conrado Montoya
  2023-08-23  8:07 ` [NTG-context] " Hans Hagen via ntg-context
  0 siblings, 1 reply; 2+ messages in thread
From: Andres Conrado Montoya @ 2023-08-23  2:12 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 2228 bytes --]

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.

-- 
Andrés Conrado Montoya
Andi Kú
andresconrado@gmail.com
http://sesentaycuatro.com
http://messier87.com
http://chiquitico.org
----------------------------------------
Los fines no justifican los medios, porque la medida verdadera de nuestro
carácter está dada por los medios que estamos dispuestos a utilizar, no por
los fines que proclamamos.
----------------------------------------

“You develop an instant global consciousness, a people orientation, an
intense dissatisfaction with the state of the world, and a compulsion to do
something about it. From out there on the moon, international politics look
so petty. You want to grab a politician by the scruff of the neck and drag
him a quarter of a million miles out and say, ‘Look at that, you son of a
bitch.’” — Apollo 14 astronaut Edgar Mitchell

[-- Attachment #1.2: Type: text/html, Size: 2851 bytes --]

[-- Attachment #2: Type: text/plain, Size: 495 bytes --]

___________________________________________________________________________________
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] 2+ messages in thread

* [NTG-context] Re: Better option for a macro with lots of arguments
  2023-08-23  2:12 [NTG-context] Better option for a macro with lots of arguments Andres Conrado Montoya
@ 2023-08-23  8:07 ` Hans Hagen via ntg-context
  0 siblings, 0 replies; 2+ messages in thread
From: Hans Hagen via ntg-context @ 2023-08-23  8:07 UTC (permalink / raw)
  To: Andres Conrado Montoya, mailing list for ConTeXt users; +Cc: Hans Hagen

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-08-23  8:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-23  2:12 [NTG-context] Better option for a macro with lots of arguments Andres Conrado Montoya
2023-08-23  8:07 ` [NTG-context] " Hans Hagen via ntg-context

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).