-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlangsci-affiliations.dtx
769 lines (736 loc) · 29.3 KB
/
langsci-affiliations.dtx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
% \iffalse meta-comment
% !TeX program = xelatex
% !TeX encoding = utf-8
%<*internal>
\begingroup
%</internal>
%<*install>
\input{l3docstrip.tex}
\keepsilent
\askforoverwritefalse
\preamble
------------------------------------------------------------------------------
langsci-affiliations collects, orders, and outputs author-affiliation pairs.
It makes use of data types from LaTeX3.
The package is aimed to be helpful to class authors, i.e. those who design
and maintain document templates in publishing houses, universities, etc. The
package is probably of only limited use to document authors/end users.
langsci-affiliations was developed at Language Science Press to help in the
production of scientific texts in linguistics.
Copyright (C) 2023–2024 by Language Science Press
This work consists of the file langsci-affiliations.dtx
and the derived files langsci-affiliations.sty,
langsci-affiliations.pdf.
It may be distributed and/or modified under the conditions of the
LaTeX Project Public License (LPPL), either version 1.3c of this
license or (at your option) any later version. The latest version
of this license is at <http://www.latex-project.org/lppl.txt>.
This work is ``maintained'' (per LPPL maintenance status) by
Felix Kopecky <[email protected]>.
The development version can be found at
https://github.com/langsci/langsci-affiliations
for those who are interested. Pull requests are welcome.
Please report any bugs or feature requests to
https://github.com/langsci/langsci-affiliations/issues
------------------------------------------------------------------------------
\endpreamble
\declarepreamble\minimalpreamble
\endpreamble
\postamble
\endpostamble
\usedir{tex/latex/langsci-affiliations}
\generate{\file{\jobname.sty}{\from{\jobname.dtx}{package}}}
%</install>
%<install>\endbatchfile
%<*internal>
\usepreamble\minimalpreamble
\usepostamble\defaultpostamble
\endgroup
%</internal>
%<*driver>
\documentclass{l3doc}
\usepackage{langsci-affiliations}
\usepackage[british]{babel}
\usepackage{tikz}
\usetikzlibrary{arrows, arrows.meta, positioning}
\usepackage{enumitem}
\setlist[description]{font=\normalfont}
\begin{document}
\DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
% \title{\pkg{langsci-affiliations}}
% \author{Felix Kopecky\thanks{\protect\url{mailto:[email protected]}.
% Please submit bug reports and feature requests to
% \protect\url{https://github.com/langsci/langsci-affiliations/issues}.
% }}
% \date{Version 1.4 -- \today}
% \maketitle
% \frenchspacing
% \begin{documentation}
% \section{User guide}
% This package provides a command \cmd{\ResolveAffiliations}, which collects author--affiliation pairs and outputs them according to the user configuration. It is aimed at class authors, i.e. maintainers of document templates in publishing houses, universities, etc.
% \begin{function}{\ResolveAffiliations}
% \begin{syntax}
% \cs{ResolveAffiliations} \oarg{options} \marg{pairs of authors and affiliations}
% \end{syntax}
% Takes the \marg{pairs of authors and affiliations}, orders them internally and outputs them according to the \oarg{options}.
%
% \marg{Pairs of authors and affiliations} is a list of authors and affiliations, separated by a customisable string. The defaults for the separators are \verb+and+ for authors and \verb+;+ for affiliations. The conventional author separator \cs{and} is automatically converted to the chosen author separator. Affiliations are given within \cs{affiliation} within the \marg{pairs} argument. This command is not defined by this package and possibly existing definitions are left unchanged.
%
% For example:
%
% \begin{verbatim}
% \ResolveAffiliations{
% A. U. Thor\affiliation{University of the Moon; University of Mars}
% and B. U. Thor\affiliation{University of Mars}
% }
% \end{verbatim}
% results in:
%
% \ResolveAffiliations[output authors font=\normalsize]{
% A. U. Thor\affiliation{University of the Moon; University of Mars}
% and B. U. Thor\affiliation{University of Mars}
% }\\
%
% \noindent The output can be customised using the \oarg{options}. They are described below.
% \end{function}
% \begin{function}{\SetupAffiliations}
% \begin{syntax}
% \cs{SetupAffiliations} \marg{options}
% \end{syntax}
% Options can be set either globally or locally. With \cs{SetupAffiliations}\marg{options}, they apply globally. If they are set with \cs{ResolveAffiliations}\oarg{options}, they apply locally.
% \end{function}
%
% \begin{description}[style=nextline]
% \item[|mark style =| \meta{style}\hfill (initially |alphabetic|)] Controls which markers should be used in the indexes of affiliations. Can be a either of \{|alphabetic|, |numeric|, |circled|, |none|\}.
% \item[|output affiliation =| \meta{boolean}\hfill (initially |true|)] Affiliations are output if true, otherwise not.
% \item[|orcid placement =| \meta{choice}\hfill (initially |none|)] Decide whether and where to place ORCIDs around author names. Valid choices are \{|none|, |before|, |after|\}.
% \item[|output in groups =| \meta{boolean}\hfill (initially |true|)] If |true|, authors and affiliations are output in the same line. When |false| each author and affiliation gets its own line. Only available if |output affiliation=true|.
% \item[|output authors font =| \meta{font commands}\hfill (initially |\cs{Large}|)] Stores the font settings for the ouput of authors.
% \item[|output affiliation font =| \meta{font commands}\hfill (initially |\cs{normalsize}|)] Stores the font settings for outputting affiliations.
% \item[|output authors paragraph format =| \meta{layout}\hfill (initially |\cs{raggedright}|)] Stores the paragraph settings for the author block. These settings are only applied if |output in groups=true|.
% \item[|output affiliation paragraph format =| \meta{layout}\hfill (initially |\cs{raggedright}|)] Stores the paragraph settings for the affiliation block. These settings are only applied if |output in groups=true|.
% \end{description}
%
% \noindent Output separators between authors and affiliations are customisable as well:
%
% \begin{description}[style=nextline]
% \item[|separator between two =| \meta{tokens}\hfill (initially |\char`~\&\char`~|)]
% If there are only two authors, use these \meta{tokens} to separate them.
% \item[|separator between multiple =| \meta{tokens}\hfill (initially |,\char`~|)]
% If there are more than two authors, use these \meta{tokens} to separate every pair except the last one.
% \item[|separator between final two =| \meta{tokens}\hfill (initially |\char`~\&\char`~|)]
% Use these \meta{tokens} to separate the last pair of authors if ther are more than two.
% \item[|separator between indices =| \meta{tokens}\hfill (initially |,|)]
% Use these to separate affiliation indices after each author.
% \item[|separator between affiliations =| \meta{tokens}\hfill (initially |\textvisiblespace |)]
% Separates the affiliations in the affiliation line.
% \item[|author affiliation skip =| \meta{dimexpr}\hfill (initially \cs{smallskipamount})]
% Distance between author(s) and affiliation(s).
% \end{description}
%
% \noindent The way the input is digested can be customised with these two settings:
%
% \begin{description}[style=nextline]
% \item[|input names separator =| \meta{tokens}\hfill (initially |\char`~and\char`~|)]
% Separates the author names in the input.
% \item[|input affiliation separator =| \meta{tokens}\hfill (intially |;|)]
% Separates the affiliations in the input, within dummy command \cs{affiliation}.
% \end{description}
%
% \begin{function}[added=2021-12-06]{\CountAuthorsFromAffiliations}
% \begin{syntax}
% \cs{CountAuthorsFromAffiliations} \oarg{options} \marg{pairs of authors and affiliations}
% \end{syntax}
% A document command to count the numbers of authors given in a list. Useful
% for conditional behaviour of document classes based on the numbers of authors.
% It takes the same optional arguments as \cmd{\ResolveAffiliations}. For example,
% a custom author separator is recognised by this command.
%
% The result is stored in the global integer variable \cs{g__affiliations_num_authors_int}.
% \end{function}
% \begin{function}[added=2022-09-27]{\LinkToORCIDinAffiliations}
% \begin{syntax}
% \cs{LinkToORCIDinAffiliations} \marg{orcid}
% \end{syntax}
% This document command is intended as a user interface to customise the way
% ORCIDs are output. For example, it can be set to forward the input ORCIDs to
% \cs{orcidlink} from the \pkg{orcidlink} package:
%
% \begin{verbatim}
% \RenewDocumentCommand{\LinkToORCIDinAffiliations}{ +m }
% {%
% \,\orcidlink{#1}%
% }
% \end{verbatim}
% \end{function}
%
% \end{documentation}
%
% \begin{implementation}
% \section{Implementation}
% \begin{macrocode}
%<*package>
% \end{macrocode}
% \begin{macrocode}
%<@@=affiliations>
% \end{macrocode}
% \begin{macrocode}
\RequirePackage{xparse}
\ProvidesExplPackage {langsci-affiliations} {2024-04-09} {1.4}
{A LaTeX3 package to collect and order authors and affiliations}
% \end{macrocode}
% \begin{macro}{\ResolveAffiliations}
% The top-level document command. It is grouped to keep assignments local.
% \begin{macrocode}
\NewDocumentCommand{\ResolveAffiliations}{ O{} +m }
{%
\group_begin:
\keys_set:nn { affiliations } { #1 }%
\exp_args:No \affiliations_resolve:n { #2 }%
\group_end:
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\LinkToORCIDinAffiliations}
% The action taken to link to an ORCID. Designed to be overwritten by the user.
% \begin{macrocode}
\ProvideDocumentCommand{\LinkToORCIDinAffiliations}{ +m }{ #1 }
% \end{macrocode}
% \end{macro}
% \begin{macro}{\CountAuthorsFromAffiliations}
% Count authors and leave the result in the global integer variable
% \cs{g__affiliations_num_authors_int}.
% \begin{macrocode}
\NewExpandableDocumentCommand{\CountAuthorsFromAffiliations}{ O{} +m }
{%
\group_begin:
\keys_set:nn { affiliations } { #1 }%
\exp_args:No \affiliations_count_authors:n { #2 }%
\group_end:
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\SetupAffiliations}
% A command to define options.
% \begin{macrocode}
\NewDocumentCommand{\SetupAffiliations}{ m }
{%
\keys_set:nn { affiliations } { #1 }
}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
\keys_define:nn { affiliations }
{
mark~style .tl_set:N
= \l__affiliations_style_tl,
mark~style .initial:n
= { alphabetic },
output~affiliation .bool_set:N
= \l__affiliations_output_affiliation_bool,
output~affiliation .initial:n
= { true },
orcid~placement .tl_set:N
= \l__affiliations_orcid_place_tl,
orcid~placement .initial:n
= { none },
output~in~groups .bool_set:N
= \l__affiliations_output_grouped_bool,
output~in~groups .initial:n
= { true },
separator~between~two .tl_set:N
= \l__affiliations_separator_between_two_tl,
separator~between~two .initial:n
= {~\&~},
separator~between~multiple .tl_set:N
= \l__affiliations_separator_between_mult_tl,
separator~between~multiple .initial:n
= {,~},
separator~between~final~two .tl_set:N
= \l__affiliations_separator_between_last_two_tl,
separator~between~final~two .initial:n
= {~\&~},
separator~between~indices .tl_set:N
= \l__affiliations_indices_separator_tl,
separator~between~indices .initial:n
= {,},
separator~between~affiliations .tl_set:N
= \l__affiliations_afil_separator_tl,
separator~between~affiliations .initial:n
= {~},
output~authors~paragraph~format .cs_set:Np
= \__affiliations_output_authors_paragraph_format:,
output~authors~paragraph~format .initial:n
= {\raggedright},
output~authors~font .cs_set:Np
= \__affiliations_output_authors_font:,
output~authors~font .initial:n
= {\Large},
output~affiliation~font .cs_set:Np
= \__affiliations_output_affiliation_font:,
output~affiliation~font .initial:n
= {\normalsize},
output~affiliation~paragraph~format .cs_set:Np
= \__affiliations_output_affiliation_paragraph_format:,
output~affiliation~paragraph~format .initial:n
= {\raggedright},
input~names~separator .tl_set:N
= \l__affiliations_input_names_sep_tl,
input~names~separator .initial:n
= {~and~},
input~affiliation~separator .tl_set:N
= \l_affiliations_input_afil_sep_tl,
input~affiliation~separator .initial:n
= {;},
author~affiliation~skip .dim_set:N
= \l__author_affil_sep_dim,
author~affiliation~skip .initial:n
= {\smallskipamount}
}
% \end{macrocode}
% \begin{variable}[int]{
% \prop_put:Nxx,
% \prop_put:Nnx,
% \seq_set_split:Nvn,
% \l__affiliations_tmpa_clist,
% \l__affiliations_tmpa_int,
% \g__affiliations_num_authors_int,
% \l__affiliations_affiliations_seq,
% \l__affiliations_authors_seq,
% \l__affiliations_names_seq,
% \l__affiliations_tmpa_seq,
% \l__affiliations_tmpb_seq,
% \l__affiliations_tmpa_tl,
% \l__affiliations_tmpb_tl,
% \l__affiliations_output_prop,
% \l__affiliations_affiliations_prop}
% Variants and variables
% \begin{macrocode}
\cs_generate_variant:Nn \prop_put:Nnn { Nxx }
\cs_generate_variant:Nn \prop_put:Nnn { Nnx }
\cs_generate_variant:Nn \seq_set_split:Nnn { NVV }
\cs_generate_variant:Nn \seq_set_split:Nnn { NVn }
\cs_generate_variant:Nn \tl_replace_all:Nnn { NnV }
\clist_new:N \l__affiliations_tmpa_clist
\int_new:N \l__affiliations_tmpa_int
\int_new:N \g__affiliations_num_authors_int
\seq_new:N \l__affiliations_affiliations_seq
\seq_new:N \l__affiliations_authors_seq
\seq_new:N \l__affiliations_names_seq
\seq_new:N \l__affiliations_tmpa_seq
\seq_new:N \l__affiliations_tmpb_seq
\seq_new:N \l__affiliations_tmp_affil_seq
\seq_new:N \l__affiliations_tmp_orcid_seq
\tl_new:N \l__affiliations_tmpa_tl
\tl_new:N \l__affiliations_tmpb_tl
\tl_new:N \l__affiliations_tmpc_tl
\prop_new:N \l__affiliations_tmpa_prop
\prop_new:N \l__affiliations_output_prop
\prop_new:N \l__affiliations_affiliations_prop
\prop_new:N \l__affiliations_orcids_prop
% \end{macrocode}
% \end{variable}
% \begin{variable}[int]{\l__affiliations_icons_prop}
% The data for the |circled| mark style. Since this uses the \cs{char}, it is
% only available in XeLaTeX.
% \begin{macrocode}
\prop_const_from_keyval:Nn \l__affiliations_icons_prop
{
0 = \char"2460, 1 = \char"2461, 2 = \char"2462, 3 = \char"2463,
4 = \char"2464, 5 = \char"2465, 6 = \char"2466, 7 = \char"2467,
8 = \char"2468, 9 = \char"2469, 10 = \char"246A, 11 = \char"246B,
12 = \char"246C, 13 = \char"246D, 14 = \char"246E, 15 = \char"246F,
16 = \char"2470, 17 = \char"2471, 18 = \char"2472, 19 = \char"2473
}
% \end{macrocode}
% \end{variable}
% \begin{macro}[int]{\__affiliations_resolve_affiliations:}
% A helper macro to order affiliations. Is called by
% \cs{affiliations_resolve:n}.
% \begin{macrocode}
\cs_new:Npn \__affiliations_resolve_affiliations: #1#2
{
\clist_clear:N \l__affiliations_tmpa_clist
\tl_if_empty:nTF {#2}
{
\prop_put:Nnn \l__affiliations_output_prop {#1} {}
}
{
\seq_set_split:NVn \l__affiliations_tmpa_seq
\l_affiliations_input_afil_sep_tl
{ #2 }
\seq_map_inline:Nn \l__affiliations_tmpa_seq
{
\prop_get:NnNTF \l__affiliations_affiliations_prop
{##1}
\l__affiliations_tmpa_tl
{
\clist_put_right:NV \l__affiliations_tmpa_clist
\l__affiliations_tmpa_tl
}
{
%Not yet present
\clist_put_right:Nx \l__affiliations_tmpa_clist
{
\prop_count:N \l__affiliations_affiliations_prop
}
\prop_put:Nnx \l__affiliations_affiliations_prop {##1}
{ \prop_count:N \l__affiliations_affiliations_prop }
}
}
\prop_put:NnV \l__affiliations_output_prop
{#1}
\l__affiliations_tmpa_clist
}
}
% \end{macrocode}
% \end{macro}
% \begin{macro}[int]{\__affiliations_output_affiliations:}
% A helper macro that outputs the list of affiliations, usually below
% the list of authors.
% \begin{macrocode}
\cs_new:Nn \__affiliations_output_affiliations:
{
\prop_map_inline:Nn \l__affiliations_affiliations_prop
{
\int_set:Nn \l__affiliations_tmpa_int { ##2 }
\str_case_e:nn { \l__affiliations_style_tl }
{
{alphabetic}
{
\textsuperscript{\int_to_alph:n{ \int_eval:n
{ \l__affiliations_tmpa_int + 1 }
} }
}
{numeric}
{ \textsuperscript{\int_eval:n {\l__affiliations_tmpa_int + 1} } }
{circled}
{
\prop_item:Nn \l__affiliations_icons_prop
{\l__affiliations_tmpa_int}
}
{none} { }
}
\tl_rescan:nn {} {##1}
\int_compare:nNnT
{ \int_eval:n {\l__affiliations_tmpa_int + 1} }
<
{ \prop_count:N \l__affiliations_affiliations_prop }
{ \tl_use:N \l__affiliations_afil_separator_tl }
}
}
% \end{macrocode}
% \end{macro}
% \begin{macro}[int]{\__affiliations_return_afil_text:n}
% A helper macro that returns the affiliation marks.
% \begin{macrocode}
\cs_new:Npn \__affiliations_return_afil_text:n #1
{
\int_set:Nn \l__affiliations_tmpa_int { #1 }
\str_case_e:nn { \l__affiliations_style_tl }
{
{alphabetic}
{
\seq_put_right:Nx \l__affiliations_tmpb_seq
{ \int_to_alph:n{ \int_eval:n {#1 + 1} } }
}
{numeric}
{
\seq_put_right:Nx \l__affiliations_tmpb_seq
{ \int_eval:n {\l__affiliations_tmpa_int + 1} }
}
{circled}
{
\seq_put_right:Nx \l__affiliations_tmpb_seq
{ \prop_item:Nn \l__affiliations_icons_prop
{ \l__affiliations_tmpa_int} }
}
{none} { }
}
}
% \end{macrocode}
% \end{macro}
% \begin{macro}[int]{\__affiliations_output_authors:}
% A helper macro to output the list of authors, with affiliation marks
% (if any).
% \begin{macrocode}
\cs_new:Nn \__affiliations_output_authors:
{
\seq_clear:N \l__affiliations_tmpa_seq
\prop_map_inline:Nn \l__affiliations_output_prop
{
\seq_clear:N \l__affiliations_tmpb_seq
\clist_map_function:nN {##2} \__affiliations_return_afil_text:n
\tl_set:Nn \l__affiliations_tmpb_tl
{
\seq_use:Nn \l__affiliations_tmpb_seq
{\l__affiliations_indices_separator_tl}
}
\str_case_e:nn { \l__affiliations_orcid_place_tl }
{
{none}
{
\seq_put_right:Nx \l__affiliations_tmpa_seq
{
\tl_rescan:nn {} {##1}
\exp_not:N
\textsuperscript{\tl_use:N \l__affiliations_tmpb_tl}
}
}
{before}
{
\seq_put_right:Nx \l__affiliations_tmpa_seq
{
\exp_not:N \__affiliations_recover_orcid:n { ##1 }
\tl_rescan:nn {} {##1}
\exp_not:N
\textsuperscript{\tl_use:N \l__affiliations_tmpb_tl}
}
}
{after}
{
\seq_put_right:Nx \l__affiliations_tmpa_seq
{
\tl_rescan:nn {} {##1}
\exp_not:N \__affiliations_recover_orcid:n { ##1 }
\exp_not:N
\textsuperscript{\tl_use:N \l__affiliations_tmpb_tl}
}
}
}
}
\seq_use:Nnnn \l__affiliations_tmpa_seq
{\l__affiliations_separator_between_two_tl}
{\l__affiliations_separator_between_mult_tl}
{\l__affiliations_separator_between_last_two_tl}
}
% \end{macrocode}
% \end{macro}
% \begin{macro}[int]{\affiliations_resolve:n}
% The main macro.
% \begin{macrocode}
\cs_new:Npn \affiliations_resolve:n #1
{
\tl_set:Nn \l__affiliations_tmpc_tl { #1 }
\tl_replace_all:NnV \l__affiliations_tmpc_tl
{ \and }
\l__affiliations_input_names_sep_tl
\seq_set_split:NVV \l__affiliations_names_seq
\l__affiliations_input_names_sep_tl
\l__affiliations_tmpc_tl
\seq_map_inline:Nn \l__affiliations_names_seq
{
\tl_clear_new:N \l__affiliations_names_tmp_tl
\tl_set:Nn \l__affiliations_names_tmp_tl { ##1 }
% \end{macrocode}
% Regex-parsing: We store the \marg{affiliations} found in \cs{affiliation} to
% a separate sequence, and the \marg{orcid} found in \cs{orcid} to another
% sequence.
% \begin{macrocode}
\regex_extract_once:nnN
{\c{affiliation} \cB. (\c[^BE].*) \cE.}
{ ##1 }
\l__affiliations_tmp_affil_seq
\regex_extract_once:nnN
{\c{orcid} \cB. (\c[^BE].*) \cE.}
{ ##1 }
\l__affiliations_tmp_orcid_seq
% \end{macrocode}
% Now strip all instances of \cs{affiliations}\marg{list} and \cs{orcid}
% \marg{id} to receive the name of the author.
% Also trim all leading and trailing spaces that remain after affiliation and
% ORCiD replacement.
% \begin{macrocode}
\regex_replace_all:nnN {\c{orcid} \cB. (\c[^BE].*) \cE.}
{}
\l__affiliations_names_tmp_tl
\regex_replace_all:nnN {\c{affiliation} \cB. (\c[^BE].*) \cE.}
{}
\l__affiliations_names_tmp_tl
\tl_trim_spaces:N \l__affiliations_names_tmp_tl
% \end{macrocode}
% And store the data in two separate property lists.
% \begin{macrocode}
\prop_put:Nxx \l__affiliations_tmpa_prop
{ \tl_use:N \l__affiliations_names_tmp_tl }
{ \seq_item:Nn \l__affiliations_tmp_affil_seq {2} }
\prop_put:Nxx \l__affiliations_orcids_prop
{ \tl_use:N \l__affiliations_names_tmp_tl }
{ \seq_item:Nn \l__affiliations_tmp_orcid_seq {2} }
}
\bool_if:NTF \l__affiliations_output_affiliation_bool
{
\bool_if:NTF \l__affiliations_output_grouped_bool
{
\prop_map_function:NN \l__affiliations_tmpa_prop
\__affiliations_resolve_affiliations:
\group_begin:
\noindent
\parbox {\linewidth}
{
\__affiliations_output_authors_paragraph_format:
\__affiliations_output_authors_font:
\__affiliations_output_authors:
}
\group_end:
\skip_vertical:N \l__author_affil_sep_dim
\group_begin:
\noindent
\parbox {\linewidth}
{
\__affiliations_output_affiliation_paragraph_format:
\__affiliations_output_affiliation_font:
\__affiliations_output_affiliations:
}
\group_end:
}
{
\seq_clear:N \l__affiliations_tmpa_seq
\prop_map_inline:Nn \l__affiliations_tmpa_prop
{
\str_case_e:nn { \l__affiliations_orcid_place_tl }
{
{none}
{
\seq_put_right:Nx \l__affiliations_tmpa_seq
{
\group_begin:
\exp_not:N \__affiliations_output_authors_font:
\tl_rescan:nn {} {##1}
\group_end:\\[\dim_use:N \l__author_affil_sep_dim]
\group_begin:
\exp_not:N \__affiliations_output_affiliation_font:
\tl_rescan:nn {} {##2}
\group_end:
}
}
{before}
{
\seq_put_right:Nx \l__affiliations_tmpa_seq
{
\group_begin:
\exp_not:N \__affiliations_output_authors_font:
\exp_not:N \__affiliations_recover_orcid:n { ##1 }
\tl_rescan:nn {} {##1}\\[\dim_use:N \l__author_affil_sep_dim]
\group_end:
\group_begin:
\exp_not:N \__affiliations_output_affiliation_font:
\tl_rescan:nn {} {##2}
\group_end:
}
}
{after}
{
\seq_put_right:Nx \l__affiliations_tmpa_seq
{
\group_begin:
\exp_not:N \__affiliations_output_authors_font:
\tl_rescan:nn {} {##1}
\exp_not:N \__affiliations_recover_orcid:n { ##1 }
\\[\dim_use:N \l__author_affil_sep_dim]
\group_end:
\group_begin:
\exp_not:N \__affiliations_output_affiliation_font:
\tl_rescan:nn {} {##2}
\group_end:
}
}
}
}
\noindent
\seq_use:Nnnn \l__affiliations_tmpa_seq
{\l__affiliations_separator_between_two_tl}
{\l__affiliations_separator_between_mult_tl}
{\l__affiliations_separator_between_last_two_tl}
}
}
{
\group_begin:
\__affiliations_output_authors_font:
\seq_clear:N \l__affiliations_tmpa_seq
\prop_map_inline:Nn \l__affiliations_tmpa_prop
{
\str_case_e:nn { \l__affiliations_orcid_place_tl }
{
{none}
{
\seq_put_right:Nx
\l__affiliations_tmpa_seq
{ \tl_rescan:nn {} {##1} }
}
{before}
{
\seq_put_right:Nx
\l__affiliations_tmpa_seq
{
\exp_not:N \__affiliations_recover_orcid:n { ##1 }
\tl_rescan:nn {} {##1}
}
}
{after}
{
\seq_put_right:Nx
\l__affiliations_tmpa_seq
{
\tl_rescan:nn {} {##1}
\exp_not:N \__affiliations_recover_orcid:n { ##1 }
}
}
}
}
\seq_use:Nnnn \l__affiliations_tmpa_seq
{\l__affiliations_separator_between_two_tl}
{\l__affiliations_separator_between_mult_tl}
{\l__affiliations_separator_between_last_two_tl}
\group_end:
}
}
% \end{macrocode}
% \end{macro}
% \begin{macro}[int]{\affiliations_count_authors:n}
% Count the numbers of authors and saves the result in the global integer
% variable \cs{g__affiliations_num_authors_int}.
% \begin{macrocode}
\cs_new:Npn \affiliations_count_authors:n #1
{
\tl_set:Nn \l__affiliations_tmpc_tl { #1 }
\tl_replace_all:NnV \l__affiliations_tmpc_tl
{ \and }
\l__affiliations_input_names_sep_tl
\seq_set_split:NVV \l__affiliations_names_seq
\l__affiliations_input_names_sep_tl
\l__affiliations_tmpc_tl
\int_gset:Nn \g__affiliations_num_authors_int
{ \seq_count:N \l__affiliations_names_seq }
}
% \end{macrocode}
% \end{macro}
% \begin{macro}[int]{\__affiliations_recover_orcid:n}
% Return the ORCID associated with an author.
% \begin{macrocode}
\cs_new:Npn \__affiliations_recover_orcid:n #1
{
\prop_get:NnNTF \l__affiliations_orcids_prop { #1 }
\l__affiliations_tmpd_tl
{
\tl_if_empty:NTF \l__affiliations_tmpd_tl
% No ORCID present; no action done.
{ }
{
\LinkToORCIDinAffiliations{\tl_use:N \l__affiliations_tmpd_tl}
}
}
% No database entry for author; no action done.
{ }
}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
%</package>
% \end{macrocode}
%
% \end{implementation}
% \PrintIndex