diff options
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/latex/acro/acro.sty | 349 |
1 files changed, 216 insertions, 133 deletions
diff --git a/Master/texmf-dist/tex/latex/acro/acro.sty b/Master/texmf-dist/tex/latex/acro/acro.sty index 1dab58409c2..67a429a5a4b 100644 --- a/Master/texmf-dist/tex/latex/acro/acro.sty +++ b/Master/texmf-dist/tex/latex/acro/acro.sty @@ -31,8 +31,8 @@ \RequirePackage{expl3,l3sort,xparse,l3keys2e,xtemplate} \ProvidesExplPackage {acro} - {2015/08/25} - {2.0a} + {2015/08/29} + {2.0b} {Typeset Acronyms} % -------------------------------------------------------------------------- @@ -223,6 +223,7 @@ \tl_new:N \l__acro_list_long_format_tl \tl_new:N \l__acro_default_indefinite_tl \tl_set:Nn \l__acro_default_indefinite_tl { a } +\tl_new:N \l__acro_extra_tl \tl_new:N \l__acro_extra_format_tl \tl_new:N \l__acro_foreign_tl \tl_new:N \l__acro_foreign_sep_tl @@ -452,61 +453,6 @@ { \keys_set:nn {acro} {#1} \ignorespaces } % -------------------------------------------------------------------------- -% typeset the short form: -% #1: ID -% #2: short form -\cs_new_protected:Npn \acro_write_short:nn #1#2 - { - \mode_if_horizontal:F { \leavevmode } - \group_begin: - \bool_if:NTF \l__acro_custom_format_bool - { \l__acro_custom_format_tl } - { \l__acro_short_format_tl } - {#2} - \group_end: - } -\cs_generate_variant:Nn \acro_write_short:nn { nV , nv } - -% #1: ID -% #2: alt form -\cs_new_protected:Npn \acro_write_alt:nn #1#2 - { - \mode_if_horizontal:F { \leavevmode } - \group_begin: - \bool_if:NTF \l__acro_custom_format_bool - { \l__acro_custom_format_tl } - { \l__acro_alt_format_tl } - {#2} - \group_end: - } -\cs_generate_variant:Nn \acro_write_alt:nn { nV , nv } - -% typeset the longform,...: -% TODO: rethink the formatting mechanism -% right now a custom format gets applied additionally to the global one -% although before it -% #1: tl holding format -% #2: long form -\cs_new_protected:Npn \acro_write_long:Nn #1#2 - { - \mode_if_horizontal:F { \leavevmode } - \group_begin: - \bool_if:NTF \l__acro_custom_long_format_bool - { \l__acro_custom_long_format_tl } - { \use:n } - { - \exp_args:Nx #1 - { - \bool_if:NTF \l__acro_first_upper_bool - { \exp_not:N \__acro_first_upper_case:n { \exp_not:n {#2} } } - { \exp_not:n {#2} } - } - } - \group_end: - } -\cs_generate_variant:Nn \acro_write_long:Nn { NV,No,Nf } - -% -------------------------------------------------------------------------- % hyperref support \cs_new_eq:NN \acro_hyper_target:nn \use_ii:nn \cs_new_eq:NN \acro_hyper_link:nn \use_ii:nn @@ -597,8 +543,7 @@ \bool_if:nT { !\l__acro_first_only_short_bool && !\l__acro_first_reversed_bool } { \acro_write_indefinite:nn {#1} {long} - \acro_write_long:No \l__acro_first_long_format_tl {#3} - \acro_endings:nn {#1} {long} + \acro_write_expanded:nnn {#1} {first-long} {#3} \acro_space: \tl_if_blank:VF \l__acro_first_between_tl { @@ -635,6 +580,7 @@ \prop_map_inline:Nn \l__acro_trailing_tokens_prop { \acro_deactivate_trailing_action:n {##1} } } + \acro_get_ending_form:nn {#1} {short} \acro_acc_supp:nn {#1} { \acro_write_short:nn {#1} {#2} } \acro_endings:nn {#1} {short} \group_end: @@ -656,7 +602,7 @@ \tl_use:N \c_space_tl \bool_if:NT \l__acro_first_use_brackets_bool { \tl_head:N \l__acro_first_brackets_tl } - \acro_write_long:No \l__acro_first_long_format_tl {#3} + \acro_write_long:Vo \l__acro_first_long_format_tl {#3} \bool_if:NT \l__acro_foreign_bool { \prop_get:NnNT \l__acro_foreign_prop {#1} \l__acro_foreign_tl @@ -703,7 +649,7 @@ { \__acro_note_command:n { - \acro_write_long:No \l__acro_first_long_format_tl {#3} + \acro_write_long:Vo \l__acro_first_long_format_tl {#3} \bool_if:NT \l__acro_foreign_bool { \prop_get:NnNT \l__acro_foreign_prop {#1} \l__acro_foreign_tl @@ -796,7 +742,7 @@ { \tl_use:N \l__acro_extra_punct_tl \tl_use:N \c_space_tl } \bool_if:NT \l__acro_extra_use_brackets_bool { \tl_head:N \l__acro_extra_brackets_tl } - \acro_write_long:Nn \l__acro_extra_format_tl {#1} + \acro_write_long:Vn \l__acro_extra_format_tl {#1} \bool_if:NT \l__acro_extra_use_brackets_bool { \tl_tail:N \l__acro_extra_brackets_tl } } @@ -1115,11 +1061,14 @@ } } +\cs_new_protected:Npn \acro_for_all_acronyms_do:n #1 + { \prop_map_inline:Nn \l__acro_short_prop {#1} } + % Test, if acronyms should be printed or not; needs testing for in/excluded % classes and options `only-used' and `single': \cs_new_protected:Npn \acro_list_allow_items:nn #1#2 { - \prop_map_inline:Nn \l__acro_short_prop + \acro_for_all_acronyms_do:n { \acro_get:n {##1} \bool_if:nT @@ -1205,7 +1154,7 @@ } \cs_set:Npn \acro_print_list_long:n ##1 { - \acro_write_long:Nf \l__acro_list_long_format_tl + \acro_write_long:Vf \l__acro_list_long_format_tl { \prop_if_in:NnTF \l__acro_list_prop {##1} { \prop_item:Nn \l__acro_list_prop {##1} } @@ -1261,7 +1210,7 @@ } \cs_set:Npn \acro_print_list_long:n ##1 { - \acro_write_long:Nf \l__acro_list_long_format_tl + \acro_write_long:Vf \l__acro_list_long_format_tl { \prop_if_in:NnTF \l__acro_list_prop {##1} { \prop_item:Nn \l__acro_list_prop {##1} } @@ -1321,7 +1270,7 @@ } \cs_set:Npn \acro_print_list_long:n ##1 { - \acro_write_long:Nf \l__acro_list_long_format_tl + \acro_write_long:Vf \l__acro_list_long_format_tl { \prop_if_in:NnTF \l__acro_list_prop {##1} { \prop_item:Nn \l__acro_list_prop {##1} } @@ -1378,7 +1327,7 @@ { \bool_if:NT \l__acro_capitalize_list_bool { \bool_set_true:N \l__acro_first_upper_bool } - \acro_write_long:Nf \l__acro_long_format_tl + \acro_write_long:Vf \l__acro_long_format_tl { \prop_if_in:NnTF \l__acro_list_prop {##1} { \prop_item:Nn \l__acro_list_prop {##1} } @@ -1441,10 +1390,7 @@ { % this is not the first time \acro_write_indefinite:nn {#1} {short} - \acro_acc_supp:nn - {#1} - { \acro_write_short:nV {#1} \l__acro_short_tl } - \acro_endings:nn {#1} {short} + \acro_write_compact:nn {#1} {short} \acro_after:n {#1} } { @@ -1461,14 +1407,15 @@ } } +% #1: ID +% #2: long|first|<other> \cs_new_protected:Npn \acro_single_form:nn #1#2 { \acro_write_indefinite:nn {#1} {#2} \str_case:nnF {#2} { {long} { - \acro_write_long:NV \l__acro_long_format_tl \l__acro_long_tl - \acro_endings:nn {#1} {#2} + \acro_write_expanded:nnV {#1} {long} \l__acro_long_tl \acro_cite:n {#1} } {first} { @@ -1478,9 +1425,8 @@ { \l__acro_long_tl } } } - { - \use:c {acro_write_#2:nv} {#1} {l__acro_#2_tl} - \acro_endings:nn {#1} {#2} + { % other (e.g. short) + \acro_write_compact:nn {#1} {#2} \acro_cite:n {#1} } } @@ -1519,6 +1465,10 @@ { \tl_set_eq:NN \l__acro_alt_tl \l__acro_short_tl } % long: \prop_get:NnNF \l__acro_long_prop {#1} \l__acro_long_tl {} + % foreign: + \prop_get:NnNF \l__acro_foreign_prop {#1} \l__acro_foreign_tl {} + % extra: + \prop_get:NnNF \l__acro_extra_prop {#1} \l__acro_extra_tl {} % formatting \prop_get:NnNTF \l__acro_long_format_prop {#1} \l__acro_custom_long_format_tl @@ -1530,7 +1480,7 @@ \prop_get:NnNTF \l__acro_format_prop {#1} \l__acro_custom_format_tl { \bool_set_true:N \l__acro_custom_format_bool } { \bool_set_false:N \l__acro_custom_format_bool } - \seq_map_inline:Nn \l__acro_endings_seq + \acro_for_endings_do:n { \bool_if:cT {l__acro_##1_bool} { \__acro_set_ending_for:nnn {##1} {#1} {long} } @@ -1545,6 +1495,9 @@ % plural endings and similar concepts: \seq_new:N \l__acro_endings_seq +\cs_new_protected:Npn \acro_for_endings_do:n #1 + { \seq_map_inline:Nn \l__acro_endings_seq {#1} } + % #1: ending % #2: ID \cs_new_protected:Npn \__acro_set_ending:nn #1#2 @@ -1559,6 +1512,8 @@ \tl_new:N \l__acro_endings_tl +\bool_new:N \l__acro_use_ending_form_bool + % #1: ending % #2: id % #3: short|alt|long @@ -1574,10 +1529,19 @@ \cs_new_protected:Npn \__acro_set_endings:n #1 { - \seq_map_inline:Nn \l__acro_endings_seq + \acro_for_endings_do:n { \__acro_set_ending:nn {##1} {#1} } } +\cs_new_protected:Npn \acro_get_ending_form:nn #1#2 + { + \acro_for_endings_do:n + { + \bool_if:nT { \prop_item:cn {l__acro_#2_##1_form_prop} {#1} } + { \prop_get:cncF {l__acro_#2_##1_prop} {#1} {l__acro_#2_tl} {} } + } + } + \cs_new_protected:Npn \acro_endings:nn #1#2 { \group_begin: @@ -1589,7 +1553,7 @@ } { \use:n } { - \seq_map_inline:Nn \l__acro_endings_seq + \acro_for_endings_do:n { \__acro_set_ending_for:nnn {##1} {#1} {#2} \bool_if:cT {l__acro_##1_bool} @@ -1717,7 +1681,7 @@ % -------------------------------------------------------------------------- % enable us to know if the acronym is used only once and provide a different % style for that: -\prg_new_protected_conditional:Npnn \acro_is_used:n #1 { TF } +\prg_new_protected_conditional:Npnn \acro_is_used:n #1 { T,F,TF } { \bool_if:nTF { @@ -1732,37 +1696,25 @@ ) } { - \if@filesw - \bool_if:NTF \l__acro_mark_as_used_bool - { - \iow_shipout_x:Nn \@auxout - { - \token_to_str:N \acro@used@twice {#1} - { \thepage } - { \arabic{page} } - { \arabic{abspage} } - } - } - { - \iow_shipout_x:Nn \@auxout - { \token_to_str:N \acro@used@twice {#1} {} {} {} } - } - \fi + \bool_if:NTF \l__acro_mark_as_used_bool + { + \__acro_aux_file:Nnnnn \acro@used@twice + {#1} + { \thepage } + { \arabic{page} } + { \arabic{abspage} } + } + { \__acro_aux_file:Nnnnn \acro@used@twice {#1} {} {} {} } \prg_return_true: } { \bool_if:NTF \l__acro_mark_as_used_bool { -% \if@filesw - \iow_shipout_x:Nn \@auxout - { - \token_to_str:N \acro@used@once {#1} - { \thepage } - { \arabic{page} } - { \arabic{abspage} } - } - -% \fi + \__acro_aux_file:Nnnnn \acro@used@once + {#1} + { \thepage } + { \arabic{page} } + { \arabic{abspage} } \bool_if:nT { !\bool_if_p:c { g__acro_#1_label_bool } && @@ -1774,12 +1726,7 @@ } \bool_gset_true:c { g__acro_#1_used_bool } } - { - \if@filesw - \iow_shipout_x:Nn \@auxout - { \token_to_str:N \acro@used@once {#1} {} {} {} } - \fi - } + { \__acro_aux_file:Nnnnn \acro@used@once {#1} {} {} {} } \prg_return_false: } } @@ -1787,6 +1734,15 @@ \cs_new:Npn \acro_is_used:n #1 { \acro_is_used:nTF {#1} { } { } } +\cs_new_protected:Npn \__acro_aux_file:Nnnnn #1#2#3#4#5 + { + % \if@filesw + \iow_shipout_x:Nn \@auxout + { \token_to_str:N #1 {#2} {#3} {#4} {#5} } + % \fi + } + + % -------------------------------------------------------------------------- % the commands for the auxiliary file: \cs_new_protected:Npn \acro@used@once #1#2#3#4 @@ -1832,7 +1788,7 @@ \tl_if_eq:cNF { acro@#1@twice } \l__acro_tmpa_tl { \bool_gset_true:N \g__acro_rerun_bool } } - \prop_map_inline:Nn \l__acro_short_prop + \acro_for_all_acronyms_do:n { \seq_if_empty:cF { g__acro_#1_pages_seq } { @@ -1864,13 +1820,98 @@ \fi % -------------------------------------------------------------------------- +% typeset the short form: +% #1: ID +% #2: short form +\cs_new_protected:Npn \acro_write_short:nn #1#2 + { + \mode_if_horizontal:F { \leavevmode } + \group_begin: + \bool_if:NTF \l__acro_custom_format_bool + { \l__acro_custom_format_tl } + { \l__acro_short_format_tl } + {#2} + \group_end: + } +\cs_generate_variant:Nn \acro_write_short:nn { nV , nv } + +% typeset the alternative form: +% #1: ID +% #2: alt form +\cs_new_protected:Npn \acro_write_alt:nn #1#2 + { + \mode_if_horizontal:F { \leavevmode } + \group_begin: + \bool_if:NTF \l__acro_custom_format_bool + { \l__acro_custom_format_tl } + { \l__acro_alt_format_tl } + {#2} + \group_end: + } +\cs_generate_variant:Nn \acro_write_alt:nn { nV , nv } + +% typeset a long form: +% TODO: rethink the formatting mechanism +% right now a custom format gets applied additionally to the global one +% although before it +% #1: format +% #2: long form +\cs_new_protected:Npn \acro_write_long:nn #1#2 + { + \mode_if_horizontal:F { \leavevmode } + \group_begin: + \bool_if:NTF \l__acro_custom_long_format_bool + { \l__acro_custom_long_format_tl } + { \use:n } + { + \use:x + { + \exp_not:n {#1} + { + \bool_if:NTF \l__acro_first_upper_bool + { \exp_not:N \__acro_first_upper_case:n { \exp_not:n {#2} } } + { \exp_not:n {#2} } + } + } + } + \group_end: + } +\cs_generate_variant:Nn \acro_write_long:nn { VV,Vo,Vf,Vn,vn } + +% -------------------------------------------------------------------------- +% #1: id +% #2: short|alt +\cs_new_protected:Npn \acro_write_compact:nn #1#2 + { + \acro_get_ending_form:nn {#1} {#2} + \acro_acc_supp:nn + {#1} + { \use:c {acro_write_#2:nv} {#1} {l__acro_#2_tl} } + \acro_endings:nn {#1} {#2} + } + +% #1: ID +% #2: long|first-long|list-long|extra +% #3: long form +\cs_new_protected:Npn \acro_write_expanded:nnn #1#2#3 + { + \tl_set:Nn \l__acro_tmpa_tl {#2} + \tl_replace_all:Nnn \l__acro_tmpa_tl {-} {_} + \acro_write_long:vn {l__acro_ \l__acro_tmpa_tl _format_tl} {#3} + \acro_endings:nn {#1} {long} + } +\cs_generate_variant:Nn \acro_write_expanded:nnn { nnV } + +% #1: id \cs_new:Npn \acro_after:n #1 { \acro_cite_if:Nn \l__acro_citation_all_bool {#1} \acro_index_if:Nn \l__acro_addto_index_bool {#1} } +% -------------------------------------------------------------------------- % the standard internals: +% #1: id \cs_new_protected:Npn \acro_short:n #1 { \acro_get:n {#1} @@ -1878,14 +1919,12 @@ \acro_write_indefinite:nn {#1} {short} \acro_if_is_single:nT {#1} { \cs_set_eq:NN \acro_hyper_link:nn \use_ii:nn } - \acro_acc_supp:nn - {#1} - { \acro_write_short:nV {#1} \l__acro_short_tl } - \acro_endings:nn {#1} {short} + \acro_write_compact:nn {#1} {short} \acro_after:n {#1} } % get alternative entry: +% #1: id \cs_new_protected:Npn \acro_alt:n #1 { \acro_get:n {#1} @@ -1894,14 +1933,12 @@ \acro_write_indefinite:nn {#1} {alt} \acro_if_is_single:nT {#1} { \cs_set_eq:NN \acro_hyper_link:nn \use_ii:nn } - \acro_acc_supp:nn - {#1} - { \acro_write_alt:nV {#1} \l__acro_alt_tl } - \acro_endings:nn {#1} {alt} + \acro_write_compact:nn {#1} {alt} \acro_after:n {#1} } % get long entry: +% #1: id \cs_new_protected:Npn \acro_long:n #1 { \acro_get:n {#1} @@ -1909,12 +1946,42 @@ \acro_write_indefinite:nn {#1} {long} \acro_if_is_single:nT {#1} { \cs_set_eq:NN \acro_hyper_link:nn \use_ii:nn } - \acro_write_long:NV \l__acro_long_format_tl \l__acro_long_tl - \acro_endings:nn {#1} {long} + \acro_write_expanded:nnV {#1} {long} \l__acro_long_tl \acro_after:n {#1} } +% get foreign entry: +% #1: id +\cs_new_protected:Npn \acro_foreign:n #1 + { + \acro_get:n {#1} + \tl_if_blank:VF \l__acro_foreign_tl + { + \acro_is_used:n {#1} + \acro_if_is_single:nT {#1} + { \cs_set_eq:NN \acro_hyper_link:nn \use_ii:nn } + \acro_write_long:VV \l__acro_foreign_format_tl \l__acro_foreign_tl + \acro_after:n {#1} + } + } + +% get extra entry: +% #1: id +\cs_new_protected:Npn \acro_extra:n #1 + { + \acro_get:n {#1} + \tl_if_blank:VF \l__acro_extra_tl + { + \acro_is_used:n {#1} + \acro_if_is_single:nT {#1} + { \cs_set_eq:NN \acro_hyper_link:nn \use_ii:nn } + \acro_write_long:VV \l__acro_extra_format_tl \l__acro_extra_tl + \acro_after:n {#1} + } + } + % output like the first time: +% #1: id \cs_new_protected:Npn \acro_first:n #1 { \bool_gset_true:c { g__acro_#1_first_use_bool } @@ -1929,6 +1996,8 @@ } % output like the first time with own long version: +% #1: id +% #2: instead of long entry \cs_new_protected:Npn \acro_first_like:nn #1#2 { \bool_gset_true:c { g__acro_#1_first_use_bool } @@ -2041,7 +2110,7 @@ { \prop_get:NnNF \l__acro_acc_supp_prop {#1} \l__acro_acc_supp_tl { \prop_get:NnNF \l__acro_short_prop {#1} \l__acro_acc_supp_tl {} } - \seq_map_inline:Nn \l__acro_endings_seq + \acro_for_endings_do:n { \bool_if:cT {l__acro_##1_bool} { @@ -2304,12 +2373,11 @@ \fi } - \cs_new_protected:Npn \acro_reset_all: - { \prop_map_inline:Nn \l__acro_short_prop { \acro_reset:n {##1} } } + { \acro_for_all_acronyms_do:n { \acro_reset:n {##1} } } \cs_new_protected:Npn \acro_mark_all_as_used: - { \prop_map_inline:Nn \l__acro_short_prop { \acro_mark_as_used:n {##1} } } + { \acro_for_all_acronyms_do:n { \acro_mark_as_used:n {##1} } } \DeclareExpandableDocumentCommand \acifused { m } { \acro_if_acronym_used:nTF {#1} } @@ -2358,6 +2426,16 @@ \cs_new_protected:Npn \acro_end: { \group_end: } +\cs_new_protected:Npn \acro_reset_specials: + { + \bool_set_false:N \l__acro_indefinite_bool + \bool_set_false:N \l__acro_first_upper_bool + % \bool_set_false:N \l__acro_citation_all_bool + % \bool_set_false:N \l__acro_citation_first_bool + \bool_set_false:N \l__acro_addto_index_bool + \acro_for_endings_do:n { \bool_set_false:c {l__acro_##1_bool} } + } + % #1: ID % #2: true|false \cs_new_protected:Npn \acro_check_acronym:nn #1#2 @@ -2386,6 +2464,7 @@ \exp_args:NNnx #2 ##1 {sm} { \acro_begin: + \acro_reset_specials: \acro_check_and_mark_if:nn {########1} {########2} \exp_not:o { \__acro_tmp_command:n {####2} } \acro_end: @@ -2405,6 +2484,7 @@ \exp_args:NNnx #2 ##1 {smm} { \acro_begin: + \acro_reset_specials: \acro_check_and_mark_if:nn {########1} {########2} \exp_not:o { \__acro_tmp_command:nn {####2} {####3} } \acro_end: @@ -2822,7 +2902,7 @@ \prop_put:Nnn \l__acro_alt_prop {#1} {#2} \prop_put:Nnn \l__acro_pdfstring_short_prop {#1} {#2} \prop_put:Nnn \l__acro_pdfstring_alt_prop {#1} {#2} - \seq_map_inline:Nn \l__acro_endings_seq + \acro_for_endings_do:n { \prop_put:cnv {l__acro_short_##1_prop} {#1} {l__acro_default_short_##1_tl} @@ -2844,12 +2924,12 @@ % long: \acro_declare_key:nnn {long} {long} { - \seq_map_inline:Nn \l__acro_endings_seq + \acro_for_endings_do:n { \prop_put:cnn {l__acro_long_##1_form_prop} {#1} { \c_false_bool } } \prop_put:NnV \l__acro_long_indefinite_prop {#1} \l__acro_default_indefinite_tl - \seq_map_inline:Nn \l__acro_endings_seq + \acro_for_endings_do:n { \bool_if:cF {l__acro_#1_long-##1_set_bool} { \prop_put:cnv {l__acro_long_##1_prop} {#1} {l__acro_default_long_##1_tl} } @@ -2920,7 +3000,7 @@ { \__acro_key_check:nn {#1} { pdfstring } \prop_put:Nnn \l__acro_pdfstring_short_prop {#1} {#2} - \seq_map_inline:Nn \l__acro_endings_seq + \acro_for_endings_do:n { \tl_if_empty:nTF {#3} { @@ -2945,7 +3025,7 @@ { \__acro_key_check:nn {#1} { pdfstring-alt } \prop_put:Nnn \l__acro_pdfstring_alt_prop {#1} {#2} - \seq_map_inline:Nn \l__acro_endings_seq + \acro_for_endings_do:n { \tl_if_empty:nTF {#3} { @@ -3303,8 +3383,11 @@ (https://bitbucket.org/cgnieder/acro/issue/44) - implement https://bitbucket.org/cgnieder/acro/issue/35 - new option `single-form' -2015/08/16 v2.0a - fix https://bitbucket.org/cgnieder/acro/issue/38 and +2015/08/25 v2.0a - fix https://bitbucket.org/cgnieder/acro/issue/38 and https://bitbucket.org/cgnieder/acro/issue/49 +2015/08/29 v2.0b - fix https://bitbucket.org/cgnieder/acro/issue/44 + - fix https://bitbucket.org/cgnieder/acro/issue/45 + - implement https://bitbucket.org/cgnieder/acro/issue/42 % -------------------------------------------------------------------------- update => http://tex.stackexchange.com/questions/236362 |