|
| 1 | +%% |
| 2 | +%% This is file `langsci-affiliations.sty', |
| 3 | +%% generated with the docstrip utility. |
| 4 | +%% |
| 5 | +%% The original source files were: |
| 6 | +%% |
| 7 | +%% langsci-affiliations.dtx (with options: `package') |
| 8 | +%% ------------------------------------------------------------------------------ |
| 9 | +%% |
| 10 | +%% langsci-affiliations collects, orders, and outputs author-affiliation pairs. |
| 11 | +%% It makes use of data types from LaTeX3. |
| 12 | +%% |
| 13 | +%% The package is aimed to be helpful to class authors, i.e. those who design |
| 14 | +%% and maintain document templates in publishing houses, universities, etc. The |
| 15 | +%% package is probably of only limited use to document authors/end users. |
| 16 | +%% |
| 17 | +%% langsci-affiliations was developed at Language Science Press to help in the |
| 18 | +%% production of scientific texts in linguistics. |
| 19 | +%% |
| 20 | +%% Copyright (C) 2021 by Felix Kopecky, Language Science Press |
| 21 | +%% |
| 22 | +%% This work consists of the file langsci-affiliations.dtx |
| 23 | +%% and the derived files langsci-affiliations.ins, |
| 24 | +%% langsci-affiliations.pdf. |
| 25 | +%% |
| 26 | +%% It may be distributed and/or modified under the conditions of the |
| 27 | +%% LaTeX Project Public License (LPPL), either version 1.3c of this |
| 28 | +%% license or (at your option) any later version. The latest version |
| 29 | +%% of this license is at <http://www.latex-project.org/lppl.txt>. |
| 30 | +%% |
| 31 | +%% This work is ``maintained'' (per LPPL maintenance status) by |
| 32 | +%% Felix Kopecky <felix.kopecky@langsci-press.org>. |
| 33 | +%% |
| 34 | +%% The development version can be found at |
| 35 | +%% |
| 36 | +%% https://github.com/langsci/langsci-affiliations |
| 37 | +%% |
| 38 | +%% for those who are interested. Pull requests are welcome. |
| 39 | +%% |
| 40 | +%% Please report any bugs or feature requests to |
| 41 | +%% |
| 42 | +%% https://github.com/langsci/langsci-affiliations/issues |
| 43 | +%% |
| 44 | +%% ------------------------------------------------------------------------------ |
| 45 | + |
| 46 | + |
| 47 | +\RequirePackage{xparse} |
| 48 | +\ProvidesExplPackage {langsci-affiliations} |
| 49 | +{2021-02-25} {1.0.2} |
| 50 | +{A LaTeX3 package to collect and order authors and affiliations} |
| 51 | + |
| 52 | +\NewDocumentCommand{\ResolveAffiliations}{ O{} +m } |
| 53 | + {% |
| 54 | + \group_begin: |
| 55 | + \keys_set:nn { affiliations } { #1 }% |
| 56 | + \exp_args:No \affiliations_resolve:n { #2 }% |
| 57 | + \group_end: |
| 58 | + } |
| 59 | + |
| 60 | +\NewDocumentCommand{\SetupAffiliations}{ m } |
| 61 | + {% |
| 62 | + \keys_set:nn { affiliations } { #1 } |
| 63 | + } |
| 64 | +\keys_define:nn { affiliations } |
| 65 | + { |
| 66 | + mark~style .tl_set:N |
| 67 | + = \l__affiliations_style_tl, |
| 68 | + mark~style .initial:n |
| 69 | + = { alphabetic }, |
| 70 | + output~affiliation .bool_set:N |
| 71 | + = \l__affiliations_output_affiliation_bool, |
| 72 | + output~affiliation .initial:n |
| 73 | + = { true }, |
| 74 | + output~in~groups .bool_set:N |
| 75 | + = \l__affiliations_output_grouped_bool, |
| 76 | + output~in~groups .initial:n |
| 77 | + = { true }, |
| 78 | + separator~between~two .tl_set:N |
| 79 | + = \l__affiliations_separator_between_two_tl, |
| 80 | + separator~between~two .initial:n |
| 81 | + = {~\&~}, |
| 82 | + separator~between~multiple .tl_set:N |
| 83 | + = \l__affiliations_separator_between_mult_tl, |
| 84 | + separator~between~multiple .initial:n |
| 85 | + = {,~}, |
| 86 | + separator~between~final~two .tl_set:N |
| 87 | + = \l__affiliations_separator_between_last_two_tl, |
| 88 | + separator~between~final~two .initial:n |
| 89 | + = {~\&~}, |
| 90 | + separator~between~affiliations .tl_set:N |
| 91 | + = \l__affiliations_afil_separator_tl, |
| 92 | + separator~between~affiliations .initial:n |
| 93 | + = {,}, |
| 94 | + output~authors~font .cs_set:Np |
| 95 | + = \__affiliations_output_authors_font:, |
| 96 | + output~authors~font .initial:n |
| 97 | + = {\Large}, |
| 98 | + output~affiliation~font .cs_set:Np |
| 99 | + = \__affiliations_output_affiliation_font:, |
| 100 | + output~affiliation~font .initial:n |
| 101 | + = {\normalsize}, |
| 102 | + input~names~separator .tl_set:N |
| 103 | + = \l__affiliations_input_names_sep_tl, |
| 104 | + input~names~separator .initial:n |
| 105 | + = {~and~}, |
| 106 | + input~affiliation~separator .tl_set:N |
| 107 | + = \l_affiliations_input_afil_sep_tl, |
| 108 | + input~affiliation~separator .initial:n |
| 109 | + = {;} |
| 110 | + } |
| 111 | + |
| 112 | +\cs_generate_variant:Nn \prop_put:Nnn { Nxx } |
| 113 | +\cs_generate_variant:Nn \prop_put:Nnn { Nnx } |
| 114 | +\cs_generate_variant:Nn \seq_set_split:Nnn { NVn } |
| 115 | +\clist_new:N \l__affiliations_tmpa_clist |
| 116 | +\int_new:N \l__affiliations_tmpa_int |
| 117 | +\prop_new:N \l__affiliations_tmpa_prop |
| 118 | +\seq_new:N \l__affiliations_affiliations_seq |
| 119 | +\seq_new:N \l__affiliations_authors_seq |
| 120 | +\seq_new:N \l__affiliations_names_seq |
| 121 | +\seq_new:N \l__affiliations_tmpa_seq |
| 122 | +\seq_new:N \l__affiliations_tmpb_seq |
| 123 | +\tl_new:N \l__affiliations_tmpa_tl |
| 124 | +\tl_new:N \l__affiliations_tmpb_tl |
| 125 | +\prop_new:N \l__affiliations_output_prop |
| 126 | +\prop_new:N \l__affiliations_affiliations_prop |
| 127 | +\prop_const_from_keyval:Nn \l__affiliations_icons_prop |
| 128 | + { |
| 129 | + 0 = \char"2460, 1 = \char"2461, 2 = \char"2462, 3 = \char"2463, |
| 130 | + 4 = \char"2464, 5 = \char"2465, 6 = \char"2466, 7 = \char"2467, |
| 131 | + 8 = \char"2468, 9 = \char"2469, 10 = \char"246A, 11 = \char"246B, |
| 132 | + 12 = \char"246C, 13 = \char"246D, 14 = \char"246E, 15 = \char"246F, |
| 133 | + 16 = \char"2470, 17 = \char"2471, 18 = \char"2472, 19 = \char"2473 |
| 134 | + } |
| 135 | +\cs_new:Npn \__affiliations_resolve_affiliations: #1#2 |
| 136 | + { |
| 137 | + \clist_clear:N \l__affiliations_tmpa_clist |
| 138 | + \tl_if_empty:nTF {#2} |
| 139 | + { |
| 140 | + \prop_put:Nnn \l__affiliations_output_prop {#1} {} |
| 141 | + } |
| 142 | + { |
| 143 | + \seq_set_split:NVn \l__affiliations_tmpa_seq |
| 144 | + \l_affiliations_input_afil_sep_tl |
| 145 | + { #2 } |
| 146 | + \seq_map_inline:Nn \l__affiliations_tmpa_seq |
| 147 | + { |
| 148 | + \prop_get:NnNTF \l__affiliations_affiliations_prop |
| 149 | + {##1} |
| 150 | + \l__affiliations_tmpa_tl |
| 151 | + { |
| 152 | + \clist_put_right:NV \l__affiliations_tmpa_clist |
| 153 | + \l__affiliations_tmpa_tl |
| 154 | + } |
| 155 | + { |
| 156 | + %Not yet present |
| 157 | + \clist_put_right:Nx \l__affiliations_tmpa_clist |
| 158 | + { |
| 159 | + \prop_count:N \l__affiliations_affiliations_prop |
| 160 | + } |
| 161 | + \prop_put:Nnx \l__affiliations_affiliations_prop {##1} |
| 162 | + { \prop_count:N \l__affiliations_affiliations_prop } |
| 163 | + } |
| 164 | + } |
| 165 | + \prop_put:NnV \l__affiliations_output_prop |
| 166 | + {#1} |
| 167 | + \l__affiliations_tmpa_clist |
| 168 | + } |
| 169 | + } |
| 170 | +\cs_new:Nn \__affiliations_output_affiliations: |
| 171 | + { |
| 172 | + \prop_map_inline:Nn \l__affiliations_affiliations_prop |
| 173 | + { |
| 174 | + \int_set:Nn \l__affiliations_tmpa_int { ##2 } |
| 175 | + \str_case_e:nn { \l__affiliations_style_tl } |
| 176 | + { |
| 177 | + {alphabetic} |
| 178 | + { |
| 179 | + \textsuperscript{\int_to_alph:n{ \int_eval:n |
| 180 | + { \l__affiliations_tmpa_int + 1 } |
| 181 | + } } |
| 182 | + } |
| 183 | + {numeric} |
| 184 | + { \textsuperscript{\int_eval:n {\l__affiliations_tmpa_int + 1} } } |
| 185 | + {circled} |
| 186 | + { |
| 187 | + \prop_item:Nn \l__affiliations_icons_prop |
| 188 | + {\l__affiliations_tmpa_int} |
| 189 | + } |
| 190 | + {none} { } |
| 191 | + } |
| 192 | + ##1 ~ |
| 193 | + } |
| 194 | + } |
| 195 | +\cs_new:Npn \__affiliations_return_afil_text:n #1 |
| 196 | + { |
| 197 | + \int_set:Nn \l__affiliations_tmpa_int { #1 } |
| 198 | + \str_case_e:nn { \l__affiliations_style_tl } |
| 199 | + { |
| 200 | + {alphabetic} |
| 201 | + { |
| 202 | + \seq_put_right:Nx \l__affiliations_tmpb_seq |
| 203 | + { \int_to_alph:n{ \int_eval:n {#1 + 1} } } |
| 204 | + } |
| 205 | + {numeric} |
| 206 | + { |
| 207 | + \seq_put_right:Nx \l__affiliations_tmpb_seq |
| 208 | + { \int_eval:n {\l__affiliations_tmpa_int + 1} } |
| 209 | + } |
| 210 | + {circled} |
| 211 | + { |
| 212 | + \seq_put_right:Nx \l__affiliations_tmpb_seq |
| 213 | + { \prop_item:Nn \l__affiliations_icons_prop |
| 214 | + { \l__affiliations_tmpa_int} } |
| 215 | + } |
| 216 | + {none} { } |
| 217 | + } |
| 218 | + } |
| 219 | + |
| 220 | +\cs_new:Nn \__affiliations_output_authors: |
| 221 | + { |
| 222 | + \seq_clear:N \l__affiliations_tmpa_seq |
| 223 | + \prop_map_inline:Nn \l__affiliations_output_prop |
| 224 | + { |
| 225 | + \seq_clear:N \l__affiliations_tmpb_seq |
| 226 | + \clist_map_function:nN {##2} \__affiliations_return_afil_text:n |
| 227 | + \tl_set:Nn \l__affiliations_tmpb_tl |
| 228 | + { |
| 229 | + \seq_use:Nn \l__affiliations_tmpb_seq |
| 230 | + {\l__affiliations_afil_separator_tl} |
| 231 | + } |
| 232 | + \seq_put_right:Nx \l__affiliations_tmpa_seq |
| 233 | + { |
| 234 | + \tl_rescan:nn {} {##1} |
| 235 | + \exp_not:N \textsuperscript{\tl_use:N \l__affiliations_tmpb_tl} |
| 236 | + } |
| 237 | + } |
| 238 | + \seq_use:Nnnn \l__affiliations_tmpa_seq |
| 239 | + {\l__affiliations_separator_between_two_tl} |
| 240 | + {\l__affiliations_separator_between_mult_tl} |
| 241 | + {\l__affiliations_separator_between_last_two_tl} |
| 242 | + } |
| 243 | + |
| 244 | +\cs_new:Npn \affiliations_resolve:n #1 |
| 245 | + { |
| 246 | + \seq_set_split:NVn \l__affiliations_names_seq |
| 247 | + \l__affiliations_input_names_sep_tl |
| 248 | + { #1 } |
| 249 | + \seq_map_inline:Nn \l__affiliations_names_seq |
| 250 | + { |
| 251 | + \seq_clear_new:N \l__affiliations_names_tmp_seq |
| 252 | + \seq_set_split:Nnn \l__affiliations_names_tmp_seq { \affiliation } |
| 253 | + { ##1 } |
| 254 | + \prop_put:Nxx \l__affiliations_tmpa_prop |
| 255 | + { \seq_item:Nn \l__affiliations_names_tmp_seq {1} } |
| 256 | + { \seq_item:Nn \l__affiliations_names_tmp_seq {2} } |
| 257 | + } |
| 258 | + \bool_if:NTF \l__affiliations_output_affiliation_bool |
| 259 | + { |
| 260 | + \bool_if:NTF \l__affiliations_output_grouped_bool |
| 261 | + { |
| 262 | + \prop_map_function:NN \l__affiliations_tmpa_prop |
| 263 | + \__affiliations_resolve_affiliations: |
| 264 | + \group_begin: |
| 265 | + \__affiliations_output_authors_font: |
| 266 | + \__affiliations_output_authors: |
| 267 | + \group_end:\\[0.5ex] |
| 268 | + \group_begin: |
| 269 | + \__affiliations_output_affiliation_font: |
| 270 | + \__affiliations_output_affiliations: |
| 271 | + \group_end: |
| 272 | + } |
| 273 | + { |
| 274 | + \seq_clear:N \l__affiliations_tmpa_seq |
| 275 | + \prop_map_inline:Nn \l__affiliations_tmpa_prop |
| 276 | + { |
| 277 | + \seq_put_right:Nx \l__affiliations_tmpa_seq |
| 278 | + { |
| 279 | + \group_begin: |
| 280 | + \exp_not:N \__affiliations_output_authors_font: |
| 281 | + \tl_rescan:nn {} {##1}\\[0.5ex] |
| 282 | + \group_end: |
| 283 | + \group_begin: |
| 284 | + \exp_not:N \__affiliations_output_affiliation_font: |
| 285 | + \tl_rescan:nn {} {##2} |
| 286 | + \group_end: |
| 287 | + } |
| 288 | + } |
| 289 | + \seq_use:Nnnn \l__affiliations_tmpa_seq |
| 290 | + {\l__affiliations_separator_between_two_tl} |
| 291 | + {\l__affiliations_separator_between_mult_tl} |
| 292 | + {\l__affiliations_separator_between_last_two_tl} |
| 293 | + } |
| 294 | + } |
| 295 | + { |
| 296 | + \group_begin: |
| 297 | + \__affiliations_output_authors_font: |
| 298 | + \seq_clear:N \l__affiliations_tmpa_seq |
| 299 | + \prop_map_inline:Nn \l__affiliations_tmpa_prop |
| 300 | + { |
| 301 | + \seq_put_right:Nx \l__affiliations_tmpa_seq |
| 302 | + {\tl_rescan:nn {} {##1} } |
| 303 | + } |
| 304 | + \seq_use:Nnnn \l__affiliations_tmpa_seq |
| 305 | + {\l__affiliations_separator_between_two_tl} |
| 306 | + {\l__affiliations_separator_between_mult_tl} |
| 307 | + {\l__affiliations_separator_between_last_two_tl} |
| 308 | + \group_end: |
| 309 | + } |
| 310 | + } |
| 311 | + |
| 312 | +%% |
| 313 | +%% |
| 314 | +%% End of file `langsci-affiliations.sty'. |
0 commit comments