Macro for a comma separated list of authors
I'm trying to produce a document with several authors, using macros for comma separated lists. My MWE is as follows: %%%%%%%%%%%%%%%%%%%%%% \def\autores{% {Luis David Gómez-Méndez, Ph. D.}, {Adriana del Pilar Pulido-Villamarín, M. Sc.}, {Rubiela Castañeda-Salazar, M. Sc.}, {Juan Carlos Ulloa-Rubiano, Ph. D.}, {Adriana Matiz-Villamil, M. Sc.}% } \def\lastAutor{Fidson Juarismy Vesga-Pérez, Ph. D} \def\autorParaLista#1{#1;\space} \def\listaAutores{\processcommacommand[\autores]\autorParaLista & \lastAutor: autores.} \starttext \listaAutores \stoptext %%%%%%%%%%%%%%%%%%%%%%% So far, no luck trying to extract the last item from a comma separated list. That's the reason I created a "\lastAutor" macro, so I can treat the last one differently. This produces: %%%%%% Luis David Gómez-Méndez, Ph.D.; Adriana del Pilar Pulido-Villamarín, M. Sc.; Rubiela Castañeda-Salazar, M. Sc.; Juan Carlos Ulloa-Rubiano, Ph.D.; Adriana Matiz-Villamil, M. Sc.; & Fidson Juarismy Vesga-Pérez, Ph.D: autores. %%%%%% However, what I'm trying to get is: %%%%%% Luis David Gómez-Méndez, Ph.D.; Adriana del Pilar Pulido-Villamarín, M. Sc.; Rubiela Castañeda-Salazar, M. Sc.; Juan Carlos Ulloa-Rubiano, Ph.D.; Adriana Matiz-Villamil, M. Sc. & Fidson Juarismy Vesga-Pérez, Ph.D: autores. %%%%%% Which is very close to what I need, except the ";" just before the "&". So the question is: is it possible to do this in a more effective or simpler, or better way, and write a macro that outputs something like "Author1; Author2; Author3 & Author4: authors.", given a comma separated list of authors? -- 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
Hola. Maybe you need \commalistsentence? \def\Autores{% {Luis David Gómez-Méndez, Ph. D.}, {Adriana del Pilar Pulido-Villamarín, M. Sc.}, {Rubiela Castañeda-Salazar, M. Sc.}, {Juan Carlos Ulloa-Rubiano, Ph. D.}, {Adriana Matiz-Villamil, M. Sc.}, {Fidson Juarismy Vesga-Pérez, Ph. D}% } \starttext \commalistsentence[\Autores][{;\space},{\space\letterampersand\space}] \stoptext Check lang-lab.mkxl for other goodies and examples. Best regards, Jairo El mié, 24 de nov. de 2021 a la(s) 19:10, Andres Conrado Montoya via ntg-context (ntg-context@ntg.nl) escribió:
I'm trying to produce a document with several authors, using macros for comma separated lists. My MWE is as follows:
%%%%%%%%%%%%%%%%%%%%%% \def\autores{% {Luis David Gómez-Méndez, Ph. D.}, {Adriana del Pilar Pulido-Villamarín, M. Sc.}, {Rubiela Castañeda-Salazar, M. Sc.}, {Juan Carlos Ulloa-Rubiano, Ph. D.}, {Adriana Matiz-Villamil, M. Sc.}% }
\def\lastAutor{Fidson Juarismy Vesga-Pérez, Ph. D}
\def\autorParaLista#1{#1;\space} \def\listaAutores{\processcommacommand[\autores]\autorParaLista & \lastAutor: autores.}
\starttext
\listaAutores
\stoptext %%%%%%%%%%%%%%%%%%%%%%%
So far, no luck trying to extract the last item from a comma separated list. That's the reason I created a "\lastAutor" macro, so I can treat the last one differently.
This produces:
%%%%%% Luis David Gómez-Méndez, Ph.D.; Adriana del Pilar Pulido-Villamarín, M. Sc.; Rubiela Castañeda-Salazar, M. Sc.; Juan Carlos Ulloa-Rubiano, Ph.D.; Adriana Matiz-Villamil, M. Sc.; & Fidson Juarismy Vesga-Pérez, Ph.D: autores. %%%%%%
However, what I'm trying to get is:
%%%%%% Luis David Gómez-Méndez, Ph.D.; Adriana del Pilar Pulido-Villamarín, M. Sc.; Rubiela Castañeda-Salazar, M. Sc.; Juan Carlos Ulloa-Rubiano, Ph.D.; Adriana Matiz-Villamil, M. Sc. & Fidson Juarismy Vesga-Pérez, Ph.D: autores. %%%%%%
Which is very close to what I need, except the ";" just before the "&". So the question is: is it possible to do this in a more effective or simpler, or better way, and write a macro that outputs something like "Author1; Author2; Author3 & Author4: authors.", given a comma separated list of authors?
-- 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
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net
___________________________________________________________________________________
participants (2)
-
Andres Conrado Montoya
-
Jairo A. del Rio