diff options
author | Karl Berry <karl@freefriends.org> | 2020-05-10 20:50:29 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-05-10 20:50:29 +0000 |
commit | 4089354da92e3f04e88143fb7ab741315a17fb17 (patch) | |
tree | d8e1a631629ce23d32bd43a69b3ad422bd20f83f /Master/texmf-dist/tex/latex/acro | |
parent | be9c569650668cf1f39d05db60ea78d27aed7a0c (diff) |
acro (10may20)
git-svn-id: svn://tug.org/texlive/trunk@55090 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/acro')
-rw-r--r-- | Master/texmf-dist/tex/latex/acro/acro.sty | 378 |
1 files changed, 209 insertions, 169 deletions
diff --git a/Master/texmf-dist/tex/latex/acro/acro.sty b/Master/texmf-dist/tex/latex/acro/acro.sty index 2d1d88f020b..d272acdc82e 100644 --- a/Master/texmf-dist/tex/latex/acro/acro.sty +++ b/Master/texmf-dist/tex/latex/acro/acro.sty @@ -27,9 +27,9 @@ % setup package: \tl_const:Nn \c_acro_package_name_tl {acro} -\tl_const:Nn \c_acro_date_tl {2020/05/04} +\tl_const:Nn \c_acro_date_tl {2020/05/10} \tl_const:Nn \c_acro_version_major_number_tl {3} -\tl_const:Nn \c_acro_version_minor_number_tl {1} +\tl_const:Nn \c_acro_version_minor_number_tl {2} \tl_const:Nn \c_acro_version_subrelease_tl {} \tl_const:Nx \c_acro_version_number_tl { @@ -653,8 +653,11 @@ \NewDocumentCommand \AcroNeedPackage {m} { - \acro_package_if_loaded:nF {m} - { \msg_error:nnen {acro} {package-needed} { \TemplateName } {#1} } + \clist_map_inline:nn {#1} + { + \acro_package_if_loaded:nF {##1} + { \msg_error:nnen {acro} {package-needed} { \TemplateName } {##1} } + } } % -------------------------------------------------------------------------- @@ -693,13 +696,31 @@ { \acro_switch_on: } % -------------------------------------------------------------------------- -\NewDocumentCommand \DeclareAcroProperty {st?t!t|m} - { \acro_property_declare:nnnnn {#1} {#2} {#3} {#4} {#5} } +\NewDocumentCommand \DeclareAcroProperty {st?t!t|t>m} + { + \acro_property_declare:en + { + \IfBooleanT {#1} {unique=true,} + \IfBooleanT {#2} {boolean=true,} + \IfBooleanT {#3} {mandatory=true,} + \IfBooleanT {#4} {static=true,} + \IfBooleanT {#5} {display=true} + } + {#6} + } -\NewDocumentCommand \DeclareAcroPropertyAlias {st?t!t|mm} +\NewDocumentCommand \DeclareAcroPropertyAlias {st?t!t|t>mm} { - \acro_property_declare:nnnnn {#1} {#2} {#3} {#4} {#5} - \acro_property_make_alias:nn {#5} {#6} + \acro_property_declare:en + { + \IfBooleanT {#1} {unique=true,} + \IfBooleanT {#2} {boolean=true,} + \IfBooleanT {#3} {mandatory=true,} + \IfBooleanT {#4} {static=true,} + \IfBooleanT {#5} {display=true} + } + {#6} + \acro_property_make_alias:nn {#6} {#7} } \NewDocumentCommand \MakeAcroPropertyAlias {mm} @@ -714,6 +735,12 @@ \NewDocumentCommand \RenewAcroTemplate {O{acronym}m+m} { \use:c {acro_#1_template_renew:nn} {#2} {#3} } +\NewDocumentCommand \SetupAcroTemplate {O{acronym}m+m} + { \acro_template_setup:nnn {#1} {#2} {#3} } + +\NewDocumentCommand \SetupNextAcroTemplate {O{acronym}m+m} + { \acro_next_template_setup:nnn {#1} {#2} {#3} } + \NewDocumentCommand \DeclareAcronym {m+m} { \acro_declare_acronym:nn {#1} {#2} } @@ -848,16 +875,12 @@ \NewExpandableDocumentCommand \acroifbooleanF {m} { \acro_boolean_property_if:enF { \AcronymID } {#1} } -\NewExpandableDocumentCommand \acroifTF {+m+m+m} - { - \acro_property_if_set:enTF { \AcronymID } {#1} - { \acro_check_foreign:nn {#1} {#2} } - {#3} - } -\NewExpandableDocumentCommand \acroifT {+m+m} - { \acroifTF {#1} {#2} {} } -\NewExpandableDocumentCommand \acroifF {+m+m} - { \acroifTF {#1} {} {#2} } +\NewExpandableDocumentCommand \acroifTF {m} + { \acro_property_if_set:enTF { \AcronymID } {#1} } +\NewExpandableDocumentCommand \acroifT {m} + { \acro_property_if_set:enT { \AcronymID } {#1} } +\NewExpandableDocumentCommand \acroifF {m} + { \acro_property_if_set:enF { \AcronymID } {#1} } \NewDocumentCommand \acroifanyTF {m+m+m} { \acro_property_if_any:enTF { \AcronymID } {#1} {#2} {#3} } @@ -1154,44 +1177,73 @@ \acro_attribute_new:n {mandatory} \acro_attribute_new:n {dynamic} -% \seq_new:N \l__acro_mandatory_properties_seq \tl_new:N \l__acro_mandatory_properties_tl +\bool_new:N \l__acro_property_define_unique_bool +\bool_new:N \l__acro_property_define_boolean_bool +\bool_new:N \l__acro_property_define_mandatory_bool +\bool_new:N \l__acro_property_define_static_bool +\bool_new:N \l__acro_property_define_display_bool + +\cs_new_protected:Npn \__acro_setup_property:nn #1#2 + { \use:c {bool_set_#2:c} {l__acro_property_define_#1_bool} } +\cs_new_protected:Npn \__acro_setup_property:n #1 + { \__acro_setup_property:nn {#1} {true} } + % new property: -% #1: boolean (true = unique) -% #2: boolean (true = boolean) -% #3: boolean (true = mandatory) -% #4: boolean (true = static != dynamic) -% #5: property name -\cs_new_protected:Npn \acro_property_declare:nnnnn #1#2#3#4#5 - { - \acro_property_if_exist:nF {#5} - { - \seq_put_right:Ne \l__acro_properties_seq { \tl_to_str:n {#5} } - \acro_attribute_new:n {property::#5} - \bool_if:nF {#4} - { \acro_attribute_set:nnn {dynamic} {#5} {true} } - \__acro_auxlist_new:n {#5} - \bool_if:nT {#3} +% #1: attributes +% #2: property name +\cs_new_protected:Npn \acro_property_declare:nn #1#2 + { + \acro_property_if_exist:nF {#2} + { + \seq_put_right:Ne \l__acro_properties_seq { \tl_to_str:n {#2} } + \acro_attribute_new:n {property::#2} + \bool_set_false:N \l__acro_property_define_unique_bool + \bool_set_false:N \l__acro_property_define_boolean_bool + \bool_set_false:N \l__acro_property_define_mandatory_bool + \bool_set_false:N \l__acro_property_define_static_bool + \bool_set_false:N \l__acro_property_define_display_bool + \keyval_parse:NNn + \__acro_setup_property:n + \__acro_setup_property:nn + {#1} + \bool_if:NF \l__acro_property_define_static_bool + { \acro_attribute_set:nnn {dynamic} {#2} {true} } + \__acro_auxlist_new:n {#2} + \bool_if:NT \l__acro_property_define_mandatory_bool { - \acro_attribute_set:nnn {mandatory} {#5} {true} - % \seq_put_right:Nn \l__acro_mandatory_properties_seq {#5} - \tl_put_right:Nn \l__acro_mandatory_properties_tl {{#5}} + \acro_attribute_set:nnn {mandatory} {#2} {true} + \tl_put_right:Nn \l__acro_mandatory_properties_tl {{#2}} } - \bool_if:nT {#2} - { \acro_attribute_set:nnn {boolean} {#5} {true} } - \bool_if:nT {#1} + \bool_if:NT \l__acro_property_define_boolean_bool + { \acro_attribute_set:nnn {boolean} {#2} {true} } + \bool_if:NT \l__acro_property_define_unique_bool { - \acro_attribute_set:nnn {unique} {#5} {true} - \seq_new:c {l__acro_unique_#5_seq} + \acro_attribute_set:nnn {unique} {#2} {true} + \seq_new:c {l__acro_unique_#2_seq} } - \bool_if:nT {#4} + \bool_if:NT \l__acro_property_define_static_bool { - \AtEndDocument { \__acro_auxlist_update:n {#5} } - \acro_at_begin_document:n { \__acro_property_set_from_auxlist:n {#5} } + \AtEndDocument { \__acro_auxlist_update:n {#2} } + \acro_at_begin_document:n + { \__acro_property_set_from_auxlist:n {#2} } + } + \bool_if:NT \l__acro_property_define_display_bool + { + \bool_new:c {l__acro_#2_display_bool} + \bool_new:c {l__acro_#2_list_display_bool} + \keys_define:nn {acro} + { + #2/display .bool_set:c = {l__acro_#2_display_bool} , + #2/display .initial:n = true , + list/#2/display .bool_set:c = {l__acro_#2_list_display_bool} , + list/#2/display .initial:n = true + } } } } +\cs_generate_variant:Nn \acro_property_declare:nn {e} % ---------------------------------------------------------------------------- % property conditionals: @@ -1208,7 +1260,17 @@ \prg_new_conditional:Npnn \acro_property_if_set:nn #1#2 {p,T,F,TF} { \acro_attribute_if_set:neTF {#2} { \acro_case_insensitive:n {#1} } - { \prg_return_true: } + { + \cs_if_exist:cTF {l__acro_#2_display_bool} + { + \bool_if:NTF \l__acro_list_bool + { \bool_if:cTF {l__acro_#2_list_display_bool} } + { \bool_if:cTF {l__acro_#2_display_bool} } + { \prg_return_true: } + { \prg_return_false: } + } + { \prg_return_true: } + } { \prg_return_false: } } \prg_generate_conditional_variant:Nnn \acro_property_if_set:nn @@ -1651,7 +1713,7 @@ \DeclareAcroProperty {pdfcomment} % locale: -\DeclareAcroProperty {foreign} +\DeclareAcroProperty>{foreign} \DeclareAcroProperty {foreign-babel} \DeclareAcroProperty {foreign-locale} @@ -1861,22 +1923,9 @@ { \tl_if_empty:cTF {l__acro_format_ #1 _tl} { \use:n } - { \tl_use:c {l__acro_format_ #1 _tl} } - } - { - \acro_property_if_alias:nTF {#1} - { - \tl_if_exist:cTF - {l__acro_format_ \acro_property_alias:n {#1} _tl} - { - \tl_if_empty:cTF {l__acro_format_ \acro_property_alias:n {#1} _tl} - { \use:n } - { \tl_use:c {l__acro_format_ \acro_property_alias:n {#1} _tl} } - } - { \use:n } - } - { \use:n } + { \exp_not:v {l__acro_format_ #1 _tl} } } + { \use:n } } % #1: id @@ -1932,7 +1981,7 @@ \__acro_global_format:n {#2} { \__acro_property_format:nn {#1} {#2} - { \__acro_pdf_comment:nnn {#1} {#2} {#3} } + { \__acro_pdf_comment:nnn {#1} {#2} {#3} } } } } @@ -1993,9 +2042,7 @@ \cs_new_protected:Npn \acro_article_declare:nn #1#2 { \tl_gput_right:Nn \g__acro_articles_tl {{#1}} - \acro_property_declare:nnnnn - { \c_false_bool } { \c_false_bool } { \c_false_bool } { \c_false_bool } - {#1} + \acro_property_declare:nn {} {#1} \acro_list_map:nn {short} { \DeclareAcroPropertyAlias {##1-#1} {#1} @@ -2049,12 +2096,8 @@ \cs_new_protected:Npn \__acro_declare_ending_properties:n #1 { - \acro_property_declare:nnnnn - { \c_false_bool } { \c_false_bool } { \c_false_bool } { \c_false_bool } - {#1} - \acro_property_declare:nnnnn - { \c_false_bool } { \c_false_bool } { \c_false_bool } { \c_false_bool } - {#1-form} + \acro_property_declare:nn {} {#1} + \acro_property_declare:nn {} {#1-form} } % #1: ending @@ -2571,10 +2614,10 @@ \cs_new_protected:Npn \acro_footnote:n #1 { - \tl_set:Ne \l__acro_fnpct_check_tl { \l__acro_fnpct_check_tl } + \tl_set:Ne \l__acro_tmpa_tl { \l__acro_fnpct_check_tl } \exp_last_unbraced:Nno \footnote {#1} - \l__acro_fnpct_check_tl + \l__acro_tmpa_tl } % options for activating actions: @@ -2932,30 +2975,33 @@ % #2: property \cs_new_protected:Npn \acro_write:nn #1#2 { - \group_begin: - \acro_if_short:nT {#2} { \acro_soft_upper: } - \__acro_make_link:nnn {#1} {#2} - { - \acro_locale:nnn {#1} {#2} + \acro_property_if_set:nnT {#1} {#2} + { + \group_begin: + \acro_if_short:nT {#2} { \acro_soft_upper: } + \__acro_make_link:nnn {#1} {#2} { - \__acro_write:nn {#1} {#2} - \bool_if:NT \l__acro_include_endings_bool + \acro_locale:nnn {#1} {#2} { - \acro_if_ending_form:nnF {#1} {#2} - { \__acro_ending:nn {#1} {#2} } + \__acro_write:nn {#1} {#2} + \bool_if:NT \l__acro_include_endings_bool + { + \acro_if_ending_form:nnF {#1} {#2} + { \__acro_ending:nn {#1} {#2} } + } } } - } - \group_end: - \acro_if_ending_form:nnF {#1} {#2} - { - \bool_if:NF \l__acro_include_endings_bool - { \__acro_ending:nn {#1} {#2} } + \group_end: + \acro_if_ending_form:nnF {#1} {#2} + { + \bool_if:NF \l__acro_include_endings_bool + { \__acro_ending:nn {#1} {#2} } + } + \acro_property_if_eq:nnT {#2} {long} + { \acro_property_get:nn {#1} {long-post} } + \bool_set_false:N \l__acro_upper_bool + \bool_set_false:N \l__acro_article_bool } - \acro_property_if_eq:nnT {#2} {long} - { \acro_property_get:nn {#1} {long-post} } - \bool_set_false:N \l__acro_upper_bool - \bool_set_false:N \l__acro_article_bool } \cs_generate_variant:Nn \acro_write:nn {e} @@ -3139,6 +3185,7 @@ \cs_new_protected:Npn \__acro_template_add:nnn #1#2#3 { \tl_new:c {l__acro_template_#1_#2_setup_tl} + \tl_new:c {l__acro_next_template_#1_#2_setup_tl} \acro_attribute_set:nnn {template::#1} {#2} {#3} } @@ -3181,28 +3228,33 @@ % #3: setup code \cs_new_protected:Npn \acro_template_setup:nnn #1#2#3 { \tl_set:cn {l__acro_template_#1_#2_setup_tl} {#3} } -\cs_generate_variant:Nn \acro_template_setup:nnn {nnV,nVn} + +\cs_new_protected:Npn \acro_next template_setup:nnn #1#2#3 + { \tl_set:cn {l__acro_next_template_#1_#2_setup_tl} {#3} } % #1: template type % #2: template name -\cs_new_protected:Npn \__acro_template_setup:nn #1#2 - { \tl_use:c {l__acro_template_#1_#2_setup_tl} } +\cs_new_protected:Npn \__acro_template_do_setup:nn #1#2 + { + \tl_use:c {l__acro_template_#1_#2_setup_tl} + \tl_use:c {l__acro_next_template_#1_#2_setup_tl} + } % #1: template type % #2: template name \cs_new_protected:Npn \__acro_clear_template_setup:nn #1#2 - { \tl_clear:c {l__acro_template_#1_#2_setup_tl} } + { \tl_clear:c {l__acro_next_template_#1_#2_setup_tl} } % #1: template type % #2: template name \cs_new_protected:Npn \__acro_template_start:nn #1#2 { \group_begin: - \__acro_template_setup:nn {#1} {#2} - \tl_clear_new:N \TemplateType - \tl_set:Nn \TemplateType {#1} - \tl_clear_new:N \TemplateName - \tl_set:Nn \TemplateName {#2} + \__acro_template_do_setup:nn {#1} {#2} + \tl_clear_new:N \AcroTemplateType + \tl_set:Nn \AcroTemplateType {#1} + \tl_clear_new:N \AcroTemplateName + \tl_set:Nn \AcroTemplateName {#2} } % #1: template type @@ -3852,9 +3904,7 @@ { You~ need~ to~ give~ a~ value~ to~ `#1'~ \msg_line_context: } % -------------------------------------------------------------------------- -\bool_new:N \l__acro_show_foreign_bool \bool_new:N \l__acro_show_locale_bool -\bool_new:N \l__acro_list_show_locale_bool \tl_new:N \l__acro_locale_format_tl % #1: property @@ -3865,15 +3915,6 @@ { \prg_return_false: } } -% #1: property -% #2: text -\cs_new:Npn \acro_check_foreign:nn #1#2 - { - \acro_if_foreign:nTF {#1} - { \bool_if:NT \l__acro_show_foreign_bool {#2} } - {#2} - } - % #1: id % #2: property \prg_new_conditional:Npnn \acro_if_locale:nn #1#2 {p,T,F,TF} @@ -3896,37 +3937,30 @@ { \acro_if_foreign:nTF {#2} { - \bool_if:NT \l__acro_show_foreign_bool + \acro_if_locale:nnTF {#1} {#2} { - \acro_if_locale:nnTF {#1} {#2} + \bool_if:NTF \l__acro_list_bool + { \bool_if:NT \l__acro_list_show_locale_bool } + { \bool_if:NT \l__acro_show_locale_bool } { - \bool_lazy_or:nnT - { \l__acro_show_locale_bool } - { - \bool_lazy_and_p:nn - { \l__acro_list_bool } - { \l__acro_list_show_locale_bool } - } - { + { + \l__acro_locale_format_tl { - \l__acro_locale_format_tl + \acro_property_if_set:nnTF {#1} {foreign-locale} + { \acro_property_get:nn {#1} {foreign-locale} } { - \acro_property_if_set:nnTF {#1} {foreign-locale} - { \acro_property_get:nn {#1} {foreign-locale} } - { - \baselanguage - { \acro_property_get:nn {#1} {foreign-babel} } - } + \baselanguage + { \acro_property_get:nn {#1} {foreign-babel} } } } - :~ - } - \__acro_foreign_language:en - { \str_lowercase:e { \acro_property_get:nn {#1} {foreign-babel} } } - {#3} + } + :~ } + \__acro_foreign_language:en + { \str_lowercase:e { \acro_property_get:nn {#1} {foreign-babel} } } {#3} } + {#3} } {#3} } @@ -3955,12 +3989,6 @@ display .initial:n = false } -\keys_define:nn {acro/foreign} - { - display .bool_set:N = \l__acro_show_foreign_bool , - display .initial:n = true - } - % -------------------------------------------------------------------------- \bool_new:N \l__acro_language_auto_bool @@ -4104,13 +4132,6 @@ \cs_generate_variant:Nn \__acro_hyper_target:nn {e} \cs_generate_variant:Nn \__acro_hyper_link:nn {e} -% \acro_property_declare:nnnnn -% { \c_false_bool } % not unique -% { \c_true_bool } % boolean -% { \c_false_bool } % not mandatory -% { \c_false_bool } % dynamic -% {target-set} - \cs_new_protected:Npn \__acro_activate_hyperref_support: { \bool_lazy_and:nnT @@ -4987,8 +5008,7 @@ \NewAcroTemplate[list] {longtable} { - \AcroNeedPackage {array} - \AcroNeedPackage {longtable} + \AcroNeedPackage {array,longtable} \acronymsmapF { \AcroAddRow @@ -5013,16 +5033,14 @@ \acroheading \acropreamble \par \noindent - \begin {longtabu} {>{\bfseries}lp{.7\linewidth}} + \begin {longtable} {>{\bfseries}lp{.7\linewidth}} \AcronymTable - \end {longtabu} + \end {longtable} } \NewAcroTemplate[list] {longtabu} { - \AcroNeedPackage {array} - \AcroNeedPackage {longtable} - \AcroNeedPackage {tabu} + \AcroNeedPackage {array,longtable,tabu} \acronymsmapF { \AcroAddRow @@ -5040,7 +5058,7 @@ \acropages { \acrotranslate {page} \nobreakspace } { \acrotranslate {pages} \nobreakspace } - \tabularnewline + \strut \tabularnewline } } { \AcroRerun } @@ -5052,6 +5070,38 @@ \end {longtabu} } +\NewAcroTemplate[list] {supertabular} + { + \AcroNeedPackage {array,supertabular} + \acronymsmapF + { + \AcroAddRow + { + \acrowrite {short} + \acroifT {alt} { / } \acrowrite {alt} + & + \acrowrite {list} + \acroifanyT {foreign,extra} {~(} + \acrowrite {foreign} + \acroifallT {foreign,extra} {,~} + \acrowrite {extra} + \acroifanyT {foreign,extra} {)} + \acropagefill + \acropages + { \acrotranslate {page} \nobreakspace } + { \acrotranslate {pages} \nobreakspace } + \tabularnewline + } + } + { \AcroRerun } + \acroheading + \acropreamble + \par \noindent + \begin {supertabular} {>{\bfseries}lp{.7\linewidth}} + \AcronymTable + \end {supertabular} + } + \NewAcroTemplate [list] {lof} { \acroheading @@ -5332,24 +5382,14 @@ \cs_new_protected:Npn \acro_deprecated_property:nn #1#2 { \acro_deprecate:nn {#1} {#2} - \acro_property_declare:nnnnn - { \c_false_bool } - { \c_false_bool } - { \c_false_bool } - { \c_false_bool } - {#1} + \acro_property_declare:nn {} {#1} } % #1: old \cs_new_protected:Npn \acro_removed_property:n #1 { \acro_remove:n {#1} - \acro_property_declare:nnnnn - { \c_false_bool } - { \c_false_bool } - { \c_false_bool } - { \c_false_bool } - {#1} + \acro_property_declare:nn {} {#1} } % ---------------------------------------------------------------------------- |