diff --git a/HISTORY b/HISTORY index ea505d3..edf3599 100644 --- a/HISTORY +++ b/HISTORY @@ -30,6 +30,8 @@ The acro package consists of the files If you have any ideas, questions, suggestions or bugs to report, please feel free to contact me. -------------------------------------------------------------------------- +2012 VERSION 0 +-------------------------------------------------------------------------- 2012/06/22 v0.1 - first public release 2012/06/23 v0.1a - bug fix, added `strict' and `macros' option and creation of shortcut macros @@ -63,6 +65,9 @@ feel free to contact me. short entry) resolved - option `xspace' added 2013/01/02 v0.6a - \acuseall +-------------------------------------------------------------------------- +2013 VERSION 1 +-------------------------------------------------------------------------- 2013/01/16 v1.0 - new syntax of \DeclareAcronym - new option `version' - new `accsupp' acronym property @@ -146,6 +151,9 @@ feel free to contact me. 2015/05/10 v1.6b - \ProcessKeysPackageOptions , - correct bug http://tex.stackexchange.com/q/236860/ : option `pages = first' works again +-------------------------------------------------------------------------- +2015 VERSION 2 +-------------------------------------------------------------------------- 2015/08/16 v2.0 - fix https://github.com/cgnieder/acro/issue/36 - implement https://github.com/cgnieder/acro/issue/39 - implement https://github.com/cgnieder/acro/issue/40 @@ -284,7 +292,8 @@ feel free to contact me. 2020/01/24 v2.11b - fix issue #147 2020/02/03 v2.11c - fix issue #76 2020/03/07 v2.11c - fix issues #149 and #150 -2020/04/06 v3.0alpha - pre-release of v3.0 without proper documentation -2020/04/07 v3.0alpha-1 - upgrade module included -2020/04/13 v3.0alpha-2 - mutiple imrovements -2020/04/19 v3.0beta - ready? +-------------------------------------------------------------------------- +2020 VERSION 3 +-------------------------------------------------------------------------- +2020/04/29 v3.0 - complete re-write of acro with new features and all open + issues resolved diff --git a/README b/README index e09d2e2..1af233a 100644 --- a/README +++ b/README @@ -1,5 +1,5 @@ -------------------------------------------------------------------------- -the ACRO package v3.0beta 2020/04/20 +the ACRO package v3.0 2020/04/29 Typeset Acronyms @@ -29,8 +29,6 @@ The acro package consists of the code file: The acro package consists of documentation files: README - LICENSE - HISTORY acro-manual.tex acro-manual.pdf acro-manual.cls @@ -38,14 +36,15 @@ The acro package consists of documentation files: The acro package consists of example files -- these should be placed in a folder examples/ in the same folder as acro-manual.pdf: + acro.example.acflike.pdf, acro.example.acflike.tex acro.example.basic.pdf, acro.example.basic.tex + acro.example.possessive.pdf, acro.example.possessive.tex + acro.example.units.pdf, acro.example.units.tex acro.example.issue-109.pdf, acro.example.issue-109.tex acro.example.issue-111.pdf, acro.example.issue-111.tex acro.example.issue-119.pdf, acro.example.issue-119.tex acro.example.issue-154.pdf, acro.example.issue-154.tex - acro.example.possessive.pdf, acro.example.possessive.tex acro.example.texsx-505891.pdf, acro.example.texsx-505891.tex acro.example.texsx-507726.pdf, acro.example.texsx-507726.tex - acro.example.units.pdf, acro.example.units.tex -------------------------------------------------------------------------- diff --git a/TODO b/TODO index f518093..4b908a3 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,7 @@ - add gender property and extend article mechanism? -undocumented: -- trailing token: comma, \acgobbletrail +willingly undocumented: +- \acgobbletrail option acro/trailing/fnpct-check \acfootnote - options acro/commands diff --git a/acro.build b/acro.build index 43e1f57..2b055f1 100755 --- a/acro.build +++ b/acro.build @@ -255,6 +255,7 @@ if [ "$build" == true ] ; then $pkgname.properties.$moduleext \ $pkgname.acronyms.$moduleext \ $pkgname.formatting.$moduleext \ + $pkgname.ppfixes.$moduleext \ $pkgname.tools.$moduleext \ $pkgname.commands.$moduleext \ $pkgname.templates.$moduleext \ diff --git a/code/acro.acronyms.code.tex b/code/acro.acronyms.code.tex index 774c1f2..d07ef09 100644 --- a/code/acro.acronyms.code.tex +++ b/code/acro.acronyms.code.tex @@ -157,100 +157,6 @@ use-id-as-short .default:n = true } -% -------------------------------------------------------------------------- -% mechanism for endings: -\tl_new:N \l__acro_endings_tl - -\acro_attribute_new:n {short:endings} -\acro_attribute_new:n {long:endings} - -\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} - } - -% #1: ending -% #2: short default -% #3: long default -\cs_new_protected:Npn \acro_declare_ending:nnn #1#2#3 - { - \bool_new:c {l__acro_#1_bool} - \cs_new_protected:cpn {acro_#1:} { \bool_set_true:c {l__acro_#1_bool} } - \exp_args:Nc \NewDocumentCommand {acro#1} {} { \use:c {acro_#1:} } - \prg_new_conditional:cpnn {acro_if_#1:} {p,T,F,TF} - { - \bool_if:cTF {l__acro_#1_bool} - { \prg_return_true: } - { \prg_return_false: } - } - \tl_put_right:Nn \l__acro_endings_tl {{#1}} - \keys_define:nn {acro} - { - short-#1-ending .code:n = - \acro_attribute_set:nnn {short:endings} {#1} {##1} , - short-#1-ending .initial:n = #2 , - long-#1-ending .code:n = - \acro_attribute_set:nnn {long:endings} {#1} {##1} , - long-#1-ending .initial:n = #3 - } - \__acro_declare_ending_properties:n {#1}% plural + plural-form - \acro_list_map:nn {short} - { - % short-plural + short-plural-form - \__acro_declare_ending_properties:n {##1-#1} - % short-plural = plural - \acro_property_make_alias:nn {##1-#1} {#1} - } - \acro_list_map:nn {long} - { - % long-plural + long-plural-form - \__acro_declare_ending_properties:n {##1-#1} - % long-plural = plural - \acro_property_make_alias:nn {##1-#1} {#1} - % long-plural-form = plural-form - \acro_property_make_alias:nn {##1-#1-form} {#1-form} - } - } - -% #1: id -% #2: short|long -\cs_new_protected:Npn \__acro_set_endings:nn #1#2 - { - \acro_list_map:nn {#2} - { - \tl_map_inline:Nn \l__acro_endings_tl - { \__acro_set_ending:nnnn {#1} {#2} {##1} {####1} } - } - } - -% #1: id -% #2: short|long -% #3: property -% #4: ending -\cs_new_protected:Npn \__acro_set_ending:nnnn #1#2#3#4 - { - \acro_property_if_set:nnF {#1} {#3-#4-form} - { - \acro_property_if_set:nnF {#1} {#3-#4} - { - \__acro_property_set:nne {#1} {#3-#4} - { \acro_attribute_get:nn {#2:endings} {#4} } - } - } - } - -% #1: id -\cs_new_protected:Npn \acro_set_endings:n #1 - { - \__acro_set_endings:nn {#1} {short} - \__acro_set_endings:nn {#1} {long} - } - % -------------------------------------------------------------------------- % declaration of acronyms: \seq_new:N \g__acro_acronyms_seq diff --git a/code/acro.commands.code.tex b/code/acro.commands.code.tex index 01ba3a6..18f1c49 100644 --- a/code/acro.commands.code.tex +++ b/code/acro.commands.code.tex @@ -156,8 +156,8 @@ \bool_lazy_and:nnTF { \acro_property_if_eq_p:nn {#2} {long} } { \acro_if_first_p:n {#1} } - { \__acro_format:nnn {#1} {first-#2} } - { \__acro_format:nnn {#1} {#2} } + { \acro_format:nnn {#1} {first-#2} } + { \acro_format:nnn {#1} {#2} } { \__acro_upper:n { diff --git a/code/acro.definitions.code.tex b/code/acro.definitions.code.tex index cda2e30..f21bff8 100644 --- a/code/acro.definitions.code.tex +++ b/code/acro.definitions.code.tex @@ -382,48 +382,59 @@ Italian = Acronimi , Portuguese = Acr\'onimos , Spanish = Siglas , - Catalan = Sigles , - Turkish = K\i saltmalar + Catalan = Sigles } % page name \DeclareAcroTranslation {page} { - Fallback = p. , - English = p. , - French = p. , - German = S. , - Portuguese = p. + Fallback = p\abbrdot , + English = p\abbrdot , + French = p\abbrdot , + German = S\abbrdot , + Italian = p\abbrdot , + Portuguese = p\abbrdot , + Spanish = p\'ag\abbrdot , + Catalan = p\`ag\abbrdot } % pages name \DeclareAcroTranslation {pages} { - Fallback = pp. , - English = pp. , - French = pp. , - German = S. , - Portuguese = pp. + Fallback = pp\abbrdot , + English = pp\abbrdot , + French = pp\abbrdot , + German = S\abbrdot , + Italian = pp\abbrdot , + Portuguese = pp\abbrdot , + Spanish = p\'ags\abbrdot , + Catalan = p\`ag\abbrdot } % following page \DeclareAcroTranslation {sequens} { - Fallback = f. , - English = f. , - French = sq. , - German = f. , - Portuguese = s. + Fallback = f\abbrdot , + English = f\abbrdot , + French = sq\abbrdot , + German = f\abbrdot , + Italian = s\abbrdot , + Portuguese = s\abbrdot , + Spanish = s\abbrdot , + Catalan = seq\abbrdot } % following pages \DeclareAcroTranslation {sequentes} { - Fallback = ff. , - English = ff. , - French = sqq. , - German = ff. , - Portuguese = ss. + Fallback = ff\abbrdot , + English = ff\abbrdot , + French = sqq\abbrdot , + German = ff\abbrdot , + Italian = ss\abbrdot , + Portuguese = ss\abbrdot , + Spanish = ss\abbrdot , + Catalan = et seq\abbrdot } % also @@ -436,8 +447,7 @@ Italian = anche , Portuguese = tamb\'{e}m , Spanish = tambien , - Catalan = tamb\'{e} , - Turkish = ayr\i ca + Catalan = tamb\'{e} } % or @@ -450,8 +460,7 @@ Italian = o , Portuguese = ou , Spanish = o , - Catalan = o , - Turkish = veya + Catalan = o } % and @@ -464,8 +473,7 @@ Italian = e , Portuguese = e , Spanish = y , - Catalan = i , - Turkish = ve + Catalan = i } % -------------------------------------------------------------------------- diff --git a/code/acro.formatting.code.tex b/code/acro.formatting.code.tex index a0e404d..d8a6b67 100644 --- a/code/acro.formatting.code.tex +++ b/code/acro.formatting.code.tex @@ -5,7 +5,7 @@ % sets the format from the global option: % #1: property -\cs_new_protected:Npn \__acro_global_format:n #1 +\cs_new:Npn \__acro_global_format:n #1 { \acro_property_if_alias:nTF {#1} { @@ -26,7 +26,7 @@ % #1: id % #2: property % #3: insert if false -\cs_new_protected:Npn \__acro_property_format:nnF #1#2#3 +\cs_new:Npn \__acro_property_format:nnF #1#2#3 { \acro_property_if_set:nnTF {#1} {#2-format} { \acro_property_get:nn {#1} {#2-format} } @@ -56,29 +56,32 @@ % #1: id % #1: property -\cs_new_protected:Npn \__acro_property_format:nn #1#2 +\cs_new:Npn \__acro_property_format:nn #1#2 { \__acro_property_format:nnF {#1} {#2} {} } % sets the individual format: % #1: id % #2: property % #3: text -\cs_new_protected:Npn \__acro_format:nnn #1#2#3 +\cs_new:Npn \acro_format:nnn #1#2#3 { - \bool_if:NTF \l__acro_format_replace_bool - { - \__acro_property_format:nnF {#1} {#2} - { \__acro_global_format:n {#2} } - {#3} - } - { - \__acro_global_format:n {#2} - { - \__acro_property_format:nn {#1} {#2} - {#3} - } - } + { + \bool_if:NTF \l__acro_format_replace_bool + { + \__acro_property_format:nnF {#1} {#2} + { \__acro_global_format:n {#2} } + {#3} + } + { + \__acro_global_format:n {#2} + { + \__acro_property_format:nn {#1} {#2} + {#3} + } + } + } } +\cs_generate_variant:Nn \acro_format:nnn {e} % #1: property: \cs_new_protected:Npn \acro_new_format:n #1 diff --git a/code/acro.interface.code.tex b/code/acro.interface.code.tex index ee8ba64..cfaf250 100644 --- a/code/acro.interface.code.tex +++ b/code/acro.interface.code.tex @@ -95,6 +95,9 @@ \NewDocumentCommand \DeclareAcroTranslation {m+m} { \acro_declare_translations:nn {#1} {#2} } +\NewDocumentCommand \AddAcroTranslations {m+m} + { \acro_add_translations:nn {#1} {#2} } + \NewExpandableDocumentCommand \acrotranslate {m} { \acro_translate:n {#1} } @@ -109,6 +112,7 @@ \NewExpandableDocumentCommand \acdot {} { \acro_dot: } \NewExpandableDocumentCommand \acspace {} { \acro_space: } +\NewExpandableDocumentCommand \abbrdot {} { .\@ } \NewDocumentCommand \acroupper {} { \acro_upper: } \NewDocumentCommand \acrofull {} { \acro_first: } @@ -186,6 +190,9 @@ \NewDocumentCommand \acrodonotuse {} { \acro_use_false: } +\NewDocumentCommand \acroformat {mm} + { \acro_format:enn { \AcronymID } {#1} {#2} } + \NewDocumentCommand \acrogroupcite {} { \bool_if:NT \l__acro_cite_group_bool diff --git a/code/acro.locale.code.tex b/code/acro.locale.code.tex index 88404e2..21304bf 100644 --- a/code/acro.locale.code.tex +++ b/code/acro.locale.code.tex @@ -10,6 +10,9 @@ Otherwise~ contact~ the~ author~ and~ he'll~ probably~ add~ your~ language. } +\msg_new:nnn {acro} {translation-value} + { You~ need~ to~ give~ a~ value~ to~ `#1'~ \msg_line_context: } + % -------------------------------------------------------------------------- \bool_new:N \l__acro_show_locale_bool \bool_new:N \l__acro_list_show_locale_bool @@ -150,21 +153,28 @@ % #2: csv list: { = , = } \cs_new_protected:Npn \acro_declare_translations:nn #1#2 { - \clist_map_inline:nn {#2} - { \__acro_declare_translation:nw {#1} ##1 \q_stop } + \cs_set:Npn \__acro_declare_translation_aux:n ##1 + { \msg_error:nnn {acro} {translation-value} {##1} } + \cs_set:Npn \__acro_declare_translation_aux:nn ##1##2 + { \acro_declare_translation:nnn {##1} {#1} {##2} } + \keyval_parse:NNn + \__acro_declare_translation_aux:n + \__acro_declare_translation_aux:nn + {#2} } -% #1: keyword -% #2: language -% #3: translation -\cs_new_protected:Npn \__acro_declare_translation:nw #1#2=#3\q_stop +% #1: language +% #2: csv list: { = , = } +\cs_new_protected:Npn \acro_add_translations:nn #1#2 { - \tl_set:Nx \l__acro_tmpa_tl { \tl_trim_spaces:n {#2} } - \tl_set:Nx \l__acro_tmpb_tl { \tl_trim_spaces:n {#3} } - \acro_declare_translation:VnV - \l__acro_tmpa_tl - {#1} - \l__acro_tmpb_tl + \cs_set:Npn \__acro_declare_translation_aux:n ##1 + { \msg_error:nnn {acro} {translation-value} {##1} } + \cs_set:Npn \__acro_declare_translation_aux:nn ##1##2 + { \acro_declare_translation:nnn {#1} {##1} {##2} } + \keyval_parse:NNn + \__acro_declare_translation_aux:n + \__acro_declare_translation_aux:nn + {#2} } % within the loop: diff --git a/code/acro.pages.code.tex b/code/acro.pages.code.tex index d347556..fb507b2 100644 --- a/code/acro.pages.code.tex +++ b/code/acro.pages.code.tex @@ -6,6 +6,9 @@ \msg_new:nnn {acro} {label} { The~ list~ template~ `#1'~ needs~ the~ option~ `labels'~ activated. } +\msg_new:nnn {acro} {threshold} + { The~ sequentes~ threshold~ needs~ to~ be~ at~ least~ 3. } + \group_begin: \char_set_catcode_other:N \@ @@ -158,7 +161,7 @@ } } } - \seq_use:Nn \l__acro_tmpb_seq {,~} + \seq_use:Nn \l__acro_tmpb_seq { \l__acro_pages_sep_tl } } % #1: sequence @@ -167,13 +170,16 @@ \cs_new_protected:Npn \__acro_finish_range:Nnn #1#2#3 { \seq_pop_right:NN #1 \l__acro_tmpa_tl - \int_compare:nNnTF #2 > 1 + \int_compare:nNnTF {#2} > 1 { - \bool_if:NTF \l__acro_sequentes_bool + \bool_lazy_and:nnTF + { \l__acro_seq_use_bool } + { \int_compare_p:nNn {#2} < \l__acro_pages_seq_threshold_int } { \seq_put_right:Ne \l__acro_tmpb_seq { \exp_not:V \l__acro_tmpa_tl + \exp_not:V \l__acro_pages_seq_pre_tl \acro_translate:n {sequentes} } } @@ -187,11 +193,12 @@ } } { - \bool_if:NTF \l__acro_sequentes_bool + \bool_if:NTF \l__acro_seq_use_bool { \seq_put_right:Ne \l__acro_tmpb_seq { \exp_not:V \l__acro_tmpa_tl + \exp_not:V \l__acro_pages_seq_pre_tl \acro_translate:n {sequens} } } @@ -206,7 +213,7 @@ \bool_new:N \l__acro_pages_all_bool \bool_new:N \l__acro_pages_display_bool -\bool_new:N \l__acro_sequentes_bool +\bool_new:N \l__acro_seq_use_bool % #1: id \prg_new_conditional:Npnn \acro_if_pages:n #1 {p,T,F,TF} @@ -241,6 +248,10 @@ \cs_generate_variant:Nn \acro_no_page_ranges:n {e} \tl_new:N \l__acro_pages_fill_tl +\tl_new:N \l__acro_pages_sep_tl +\tl_new:N \l__acro_pages_seq_pre_tl + +\int_new:N \l__acro_pages_seq_threshold_int \keys_define:nn {acro/pages} { @@ -251,14 +262,23 @@ display / first .code:n = \bool_set_true:N \l__acro_pages_display_bool \bool_set_false:N \l__acro_pages_all_bool , - display / none .code:n = + display / none .code:n = \bool_set_false:N \l__acro_pages_display_bool , - seq .bool_set:N = \l__acro_sequentes_bool , - seq .initial:n = true , - fill .tl_set:N = \l__acro_pages_fill_tl , - fill .initial:n = \dotfill , - name .bool_set:N = \l__acro_pages_name_display_bool , - name .initial:n = false + seq / use .bool_set:N = \l__acro_seq_use_bool , + seq / use .initial:n = true , + seq / pre .tl_set:N = \l__acro_pages_seq_pre_tl , + seq / pre .initial:n = \, , + seq / threshold .code:n = + \int_compare:nNnTF {#1} < 3 + { \msg_error:nn {acro} {threshold} } + { \int_set:Nn \l__acro_pages_seq_threshold_int {#1} } , + seq / threshold .initial:n = 3 , + fill .tl_set:N = \l__acro_pages_fill_tl , + fill .initial:n = \dotfill , + sep .tl_set:N = \l__acro_pages_sep_tl , + sep .initial:n = {,~} , + name .bool_set:N = \l__acro_pages_name_display_bool , + name .initial:n = false } % ---------------------------------------------------------------------------- diff --git a/code/acro.pdfsupport.code.tex b/code/acro.pdfsupport.code.tex index 722ebc5..be8bd80 100644 --- a/code/acro.pdfsupport.code.tex +++ b/code/acro.pdfsupport.code.tex @@ -610,7 +610,7 @@ \acro_set_pdf_cs:Nn \Aclp {Long-plural} \acro_set_pdf_cs:Nn \acap {alt-plural} \acro_set_pdf_cs:Nn \Acap {Alt-plural} - \cs_set_eq:NN \__acro_format:nnn \use_iii:nnn + \cs_set_eq:NN \acro_format:nnn \use_iii:nnn \cs_set:Npn \@ {} } \cs_set_protected:Npn \acro_hyper_page:n #1 { \hyperpage {#1} } diff --git a/code/acro.ppfixes.code.tex b/code/acro.ppfixes.code.tex new file mode 100644 index 0000000..6f3da87 --- /dev/null +++ b/code/acro.ppfixes.code.tex @@ -0,0 +1,161 @@ +\AcroModule{ppfixes}{pre- and postfixes to acronyms} +% -------------------------------------------------------------------------- +% articles +\bool_new:N \l__acro_article_bool +\tl_new:N \g__acro_articles_tl + +% #1: name +% #2: default +\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_list_map:nn {short} + { + \DeclareAcroPropertyAlias {##1-#1} {#1} + \str_if_in:nnF {##1} {-acc} + { \DeclareAcroPropertyAlias {##1-acc-#1} {##1-#1} } + } + \acro_list_map:nn {long} + { + \DeclareAcroPropertyAlias {##1-#1} {#1} + \str_if_in:nnF {##1} {acc} + { \DeclareAcroPropertyAlias {##1-acc-#1} {##1-#1} } + } + \bool_new:c {l__acro_article_#1_bool} + \tl_new:c {l__acro_article_#1_tl} + \exp_args:Nc \NewDocumentCommand {acro#1} {} { \use:c {acro_#1:} } + \cs_new_protected:cpn {acro_#1:} + { + \bool_if:NF \l__acro_article_bool + { + \bool_set_true:c {l__acro_article_#1_bool} + \bool_set_true:N \l__acro_article_bool + } + } + \keys_define:nn {acro} + { + #1 .tl_set:c = {l__acro_article_#1_tl} , + #1 .initial:n = #2 + } + } + +% #1: id +\cs_new_protected:Npn \__acro_set_article_defaults:n #1 + { + \tl_map_tokens:Nn \g__acro_articles_tl + { \__acro_default_article:nn {#1} } + } + +% #1: id +% #2: article +\cs_new_protected:Npn \__acro_default_article:nn #1#2 + { \acro_property_set:nnv {#1} {#2} {l__acro_article_#2_tl} } + +% -------------------------------------------------------------------------- +% mechanism for endings: +\tl_new:N \l__acro_endings_tl + +\bool_new:N \l__acro_ending_bool + +\acro_attribute_new:n {short:endings} +\acro_attribute_new:n {long:endings} + +\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} + } + +% #1: ending +% #2: short default +% #3: long default +\cs_new_protected:Npn \acro_declare_ending:nnn #1#2#3 + { + \bool_new:c {l__acro_ending_#1_bool} + \exp_args:Nc \NewDocumentCommand {acro#1} {} { \use:c {acro_#1:} } + \cs_new_protected:cpn {acro_#1:} + { + \bool_if:NF \l__acro_ending_bool + { + \bool_set_true:c {l__acro_ending_#1_bool} + \bool_set_true:N \l__acro_ending_bool + } + } + \prg_new_conditional:cpnn {acro_if_#1:} {p,T,F,TF} + { + \bool_if:cTF {l__acro_ending_#1_bool} + { \prg_return_true: } + { \prg_return_false: } + } + \tl_put_right:Nn \l__acro_endings_tl {{#1}} + \keys_define:nn {acro} + { + short-#1-ending .code:n = + \acro_attribute_set:nnn {short:endings} {#1} {##1} , + short-#1-ending .initial:n = #2 , + long-#1-ending .code:n = + \acro_attribute_set:nnn {long:endings} {#1} {##1} , + long-#1-ending .initial:n = #3 + } + \__acro_declare_ending_properties:n {#1}% plural + plural-form + \acro_list_map:nn {short} + { + % short-plural + short-plural-form + \__acro_declare_ending_properties:n {##1-#1} + % short-plural = plural + \acro_property_make_alias:nn {##1-#1} {#1} + } + \acro_list_map:nn {long} + { + % long-plural + long-plural-form + \__acro_declare_ending_properties:n {##1-#1} + % long-plural = plural + \acro_property_make_alias:nn {##1-#1} {#1} + % long-plural-form = plural-form + \acro_property_make_alias:nn {##1-#1-form} {#1-form} + } + } + +% #1: id +% #2: short|long +\cs_new_protected:Npn \__acro_set_endings:nn #1#2 + { + \acro_list_map:nn {#2} + { + \tl_map_inline:Nn \l__acro_endings_tl + { \__acro_set_ending:nnnn {#1} {#2} {##1} {####1} } + } + } + +% #1: id +% #2: short|long +% #3: property +% #4: ending +\cs_new_protected:Npn \__acro_set_ending:nnnn #1#2#3#4 + { + \acro_property_if_set:nnF {#1} {#3-#4-form} + { + \acro_property_if_set:nnF {#1} {#3-#4} + { + \__acro_property_set:nne {#1} {#3-#4} + { \acro_attribute_get:nn {#2:endings} {#4} } + } + } + } + +% #1: id +\cs_new_protected:Npn \acro_set_endings:n #1 + { + \__acro_set_endings:nn {#1} {short} + \__acro_set_endings:nn {#1} {long} + } + +% ---------------------------------------------------------------------------- +\AcroModuleEnd diff --git a/code/acro.start.code.tex b/code/acro.start.code.tex index 9b2e72d..68a28c7 100644 --- a/code/acro.start.code.tex +++ b/code/acro.start.code.tex @@ -35,10 +35,10 @@ % setup package: \tl_const:Nn \c_acro_package_name_tl {acro} -\tl_const:Nn \c_acro_date_tl {2020/04/20} +\tl_const:Nn \c_acro_date_tl {2020/04/29} \tl_const:Nn \c_acro_version_major_number_tl {3} \tl_const:Nn \c_acro_version_minor_number_tl {0} -\tl_const:Nn \c_acro_version_subrelease_tl {beta} +\tl_const:Nn \c_acro_version_subrelease_tl {} \tl_const:Nx \c_acro_version_number_tl { \c_acro_version_major_number_tl . diff --git a/code/acro.sty b/code/acro.sty index 120a9f5..d1761cf 100644 --- a/code/acro.sty +++ b/code/acro.sty @@ -35,10 +35,10 @@ % setup package: \tl_const:Nn \c_acro_package_name_tl {acro} -\tl_const:Nn \c_acro_date_tl {2020/04/20} +\tl_const:Nn \c_acro_date_tl {2020/04/29} \tl_const:Nn \c_acro_version_major_number_tl {3} \tl_const:Nn \c_acro_version_minor_number_tl {0} -\tl_const:Nn \c_acro_version_subrelease_tl {beta} +\tl_const:Nn \c_acro_version_subrelease_tl {} \tl_const:Nx \c_acro_version_number_tl { \c_acro_version_major_number_tl . @@ -734,6 +734,9 @@ \NewDocumentCommand \DeclareAcroTranslation {m+m} { \acro_declare_translations:nn {#1} {#2} } +\NewDocumentCommand \AddAcroTranslations {m+m} + { \acro_add_translations:nn {#1} {#2} } + \NewExpandableDocumentCommand \acrotranslate {m} { \acro_translate:n {#1} } @@ -748,6 +751,7 @@ \NewExpandableDocumentCommand \acdot {} { \acro_dot: } \NewExpandableDocumentCommand \acspace {} { \acro_space: } +\NewExpandableDocumentCommand \abbrdot {} { .\@ } \NewDocumentCommand \acroupper {} { \acro_upper: } \NewDocumentCommand \acrofull {} { \acro_first: } @@ -825,6 +829,9 @@ \NewDocumentCommand \acrodonotuse {} { \acro_use_false: } +\NewDocumentCommand \acroformat {mm} + { \acro_format:enn { \AcronymID } {#1} {#2} } + \NewDocumentCommand \acrogroupcite {} { \bool_if:NT \l__acro_cite_group_bool @@ -1719,100 +1726,6 @@ use-id-as-short .default:n = true } -% -------------------------------------------------------------------------- -% mechanism for endings: -\tl_new:N \l__acro_endings_tl - -\acro_attribute_new:n {short:endings} -\acro_attribute_new:n {long:endings} - -\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} - } - -% #1: ending -% #2: short default -% #3: long default -\cs_new_protected:Npn \acro_declare_ending:nnn #1#2#3 - { - \bool_new:c {l__acro_#1_bool} - \cs_new_protected:cpn {acro_#1:} { \bool_set_true:c {l__acro_#1_bool} } - \exp_args:Nc \NewDocumentCommand {acro#1} {} { \use:c {acro_#1:} } - \prg_new_conditional:cpnn {acro_if_#1:} {p,T,F,TF} - { - \bool_if:cTF {l__acro_#1_bool} - { \prg_return_true: } - { \prg_return_false: } - } - \tl_put_right:Nn \l__acro_endings_tl {{#1}} - \keys_define:nn {acro} - { - short-#1-ending .code:n = - \acro_attribute_set:nnn {short:endings} {#1} {##1} , - short-#1-ending .initial:n = #2 , - long-#1-ending .code:n = - \acro_attribute_set:nnn {long:endings} {#1} {##1} , - long-#1-ending .initial:n = #3 - } - \__acro_declare_ending_properties:n {#1}% plural + plural-form - \acro_list_map:nn {short} - { - % short-plural + short-plural-form - \__acro_declare_ending_properties:n {##1-#1} - % short-plural = plural - \acro_property_make_alias:nn {##1-#1} {#1} - } - \acro_list_map:nn {long} - { - % long-plural + long-plural-form - \__acro_declare_ending_properties:n {##1-#1} - % long-plural = plural - \acro_property_make_alias:nn {##1-#1} {#1} - % long-plural-form = plural-form - \acro_property_make_alias:nn {##1-#1-form} {#1-form} - } - } - -% #1: id -% #2: short|long -\cs_new_protected:Npn \__acro_set_endings:nn #1#2 - { - \acro_list_map:nn {#2} - { - \tl_map_inline:Nn \l__acro_endings_tl - { \__acro_set_ending:nnnn {#1} {#2} {##1} {####1} } - } - } - -% #1: id -% #2: short|long -% #3: property -% #4: ending -\cs_new_protected:Npn \__acro_set_ending:nnnn #1#2#3#4 - { - \acro_property_if_set:nnF {#1} {#3-#4-form} - { - \acro_property_if_set:nnF {#1} {#3-#4} - { - \__acro_property_set:nne {#1} {#3-#4} - { \acro_attribute_get:nn {#2:endings} {#4} } - } - } - } - -% #1: id -\cs_new_protected:Npn \acro_set_endings:n #1 - { - \__acro_set_endings:nn {#1} {short} - \__acro_set_endings:nn {#1} {long} - } - % -------------------------------------------------------------------------- % declaration of acronyms: \seq_new:N \g__acro_acronyms_seq @@ -1953,7 +1866,7 @@ % sets the format from the global option: % #1: property -\cs_new_protected:Npn \__acro_global_format:n #1 +\cs_new:Npn \__acro_global_format:n #1 { \acro_property_if_alias:nTF {#1} { @@ -1974,7 +1887,7 @@ % #1: id % #2: property % #3: insert if false -\cs_new_protected:Npn \__acro_property_format:nnF #1#2#3 +\cs_new:Npn \__acro_property_format:nnF #1#2#3 { \acro_property_if_set:nnTF {#1} {#2-format} { \acro_property_get:nn {#1} {#2-format} } @@ -2004,29 +1917,32 @@ % #1: id % #1: property -\cs_new_protected:Npn \__acro_property_format:nn #1#2 +\cs_new:Npn \__acro_property_format:nn #1#2 { \__acro_property_format:nnF {#1} {#2} {} } % sets the individual format: % #1: id % #2: property % #3: text -\cs_new_protected:Npn \__acro_format:nnn #1#2#3 +\cs_new:Npn \acro_format:nnn #1#2#3 { - \bool_if:NTF \l__acro_format_replace_bool - { - \__acro_property_format:nnF {#1} {#2} - { \__acro_global_format:n {#2} } - {#3} - } - { - \__acro_global_format:n {#2} - { - \__acro_property_format:nn {#1} {#2} - {#3} - } - } + { + \bool_if:NTF \l__acro_format_replace_bool + { + \__acro_property_format:nnF {#1} {#2} + { \__acro_global_format:n {#2} } + {#3} + } + { + \__acro_global_format:n {#2} + { + \__acro_property_format:nn {#1} {#2} + {#3} + } + } + } } +\cs_generate_variant:Nn \acro_format:nnn {e} % #1: property: \cs_new_protected:Npn \acro_new_format:n #1 @@ -2054,6 +1970,167 @@ format / replace .initial:n = false } +% ---------------------------------------------------------------------------- +\AcroModuleEnd +\AcroModule{ppfixes}{pre- and postfixes to acronyms} +% -------------------------------------------------------------------------- +% articles +\bool_new:N \l__acro_article_bool +\tl_new:N \g__acro_articles_tl + +% #1: name +% #2: default +\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_list_map:nn {short} + { + \DeclareAcroPropertyAlias {##1-#1} {#1} + \str_if_in:nnF {##1} {-acc} + { \DeclareAcroPropertyAlias {##1-acc-#1} {##1-#1} } + } + \acro_list_map:nn {long} + { + \DeclareAcroPropertyAlias {##1-#1} {#1} + \str_if_in:nnF {##1} {acc} + { \DeclareAcroPropertyAlias {##1-acc-#1} {##1-#1} } + } + \bool_new:c {l__acro_article_#1_bool} + \tl_new:c {l__acro_article_#1_tl} + \exp_args:Nc \NewDocumentCommand {acro#1} {} { \use:c {acro_#1:} } + \cs_new_protected:cpn {acro_#1:} + { + \bool_if:NF \l__acro_article_bool + { + \bool_set_true:c {l__acro_article_#1_bool} + \bool_set_true:N \l__acro_article_bool + } + } + \keys_define:nn {acro} + { + #1 .tl_set:c = {l__acro_article_#1_tl} , + #1 .initial:n = #2 + } + } + +% #1: id +\cs_new_protected:Npn \__acro_set_article_defaults:n #1 + { + \tl_map_tokens:Nn \g__acro_articles_tl + { \__acro_default_article:nn {#1} } + } + +% #1: id +% #2: article +\cs_new_protected:Npn \__acro_default_article:nn #1#2 + { \acro_property_set:nnv {#1} {#2} {l__acro_article_#2_tl} } + +% -------------------------------------------------------------------------- +% mechanism for endings: +\tl_new:N \l__acro_endings_tl + +\bool_new:N \l__acro_ending_bool + +\acro_attribute_new:n {short:endings} +\acro_attribute_new:n {long:endings} + +\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} + } + +% #1: ending +% #2: short default +% #3: long default +\cs_new_protected:Npn \acro_declare_ending:nnn #1#2#3 + { + \bool_new:c {l__acro_ending_#1_bool} + \exp_args:Nc \NewDocumentCommand {acro#1} {} { \use:c {acro_#1:} } + \cs_new_protected:cpn {acro_#1:} + { + \bool_if:NF \l__acro_ending_bool + { + \bool_set_true:c {l__acro_ending_#1_bool} + \bool_set_true:N \l__acro_ending_bool + } + } + \prg_new_conditional:cpnn {acro_if_#1:} {p,T,F,TF} + { + \bool_if:cTF {l__acro_ending_#1_bool} + { \prg_return_true: } + { \prg_return_false: } + } + \tl_put_right:Nn \l__acro_endings_tl {{#1}} + \keys_define:nn {acro} + { + short-#1-ending .code:n = + \acro_attribute_set:nnn {short:endings} {#1} {##1} , + short-#1-ending .initial:n = #2 , + long-#1-ending .code:n = + \acro_attribute_set:nnn {long:endings} {#1} {##1} , + long-#1-ending .initial:n = #3 + } + \__acro_declare_ending_properties:n {#1}% plural + plural-form + \acro_list_map:nn {short} + { + % short-plural + short-plural-form + \__acro_declare_ending_properties:n {##1-#1} + % short-plural = plural + \acro_property_make_alias:nn {##1-#1} {#1} + } + \acro_list_map:nn {long} + { + % long-plural + long-plural-form + \__acro_declare_ending_properties:n {##1-#1} + % long-plural = plural + \acro_property_make_alias:nn {##1-#1} {#1} + % long-plural-form = plural-form + \acro_property_make_alias:nn {##1-#1-form} {#1-form} + } + } + +% #1: id +% #2: short|long +\cs_new_protected:Npn \__acro_set_endings:nn #1#2 + { + \acro_list_map:nn {#2} + { + \tl_map_inline:Nn \l__acro_endings_tl + { \__acro_set_ending:nnnn {#1} {#2} {##1} {####1} } + } + } + +% #1: id +% #2: short|long +% #3: property +% #4: ending +\cs_new_protected:Npn \__acro_set_ending:nnnn #1#2#3#4 + { + \acro_property_if_set:nnF {#1} {#3-#4-form} + { + \acro_property_if_set:nnF {#1} {#3-#4} + { + \__acro_property_set:nne {#1} {#3-#4} + { \acro_attribute_get:nn {#2:endings} {#4} } + } + } + } + +% #1: id +\cs_new_protected:Npn \acro_set_endings:n #1 + { + \__acro_set_endings:nn {#1} {short} + \__acro_set_endings:nn {#1} {long} + } + % ---------------------------------------------------------------------------- \AcroModuleEnd \AcroModule{tools}{tools for treating different aspects} @@ -2198,62 +2275,6 @@ \keys_set:nn {acro} { list/uppercase/first , uppercase/first } -% -------------------------------------------------------------------------- -% articles -\bool_new:N \l__acro_article_bool -\tl_new:N \g__acro_articles_tl - -% #1: name -% #2: default -\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_list_map:nn {short} - { - \DeclareAcroPropertyAlias {##1-#1} {#1} - \str_if_in:nnF {##1} {-acc} - { \DeclareAcroPropertyAlias {##1-acc-#1} {##1-#1} } - } - \acro_list_map:nn {long} - { - \DeclareAcroPropertyAlias {##1-#1} {#1} - \str_if_in:nnF {##1} {acc} - { \DeclareAcroPropertyAlias {##1-acc-#1} {##1-#1} } - } - \bool_new:c {l__acro_article_#1_bool} - \tl_new:c {l__acro_article_#1_tl} - \exp_args:Nc \NewDocumentCommand {acro#1} {} - { \use:c {acro_#1:} } - \cs_new_protected:cpn {acro_#1:} - { - \bool_if:NF \l__acro_article_bool - { - \bool_set_true:c {l__acro_article_#1_bool} - \bool_set_true:N \l__acro_article_bool - } - } - \keys_define:nn {acro} - { - #1 .tl_set:c = {l__acro_article_#1_tl} , - #1 .initial:n = #2 - } - } - -% #1: id -\cs_new_protected:Npn \__acro_set_article_defaults:n #1 - { - \tl_map_tokens:Nn \g__acro_articles_tl - { \__acro_default_article:nn {#1} } - } - -% #1: id -% #2: article -\cs_new_protected:Npn \__acro_default_article:nn #1#2 - { \acro_property_set:nnv {#1} {#2} {l__acro_article_#2_tl} } - % -------------------------------------------------------------------------- % citing: \bool_new:N \l__acro_cite_bool @@ -2389,10 +2410,10 @@ \__acro_index:e { \acro_property_get:nn {#1} {index-sort} @ - { % <<< don't let formatting bleed - \acro_property_get:nn {#1} {short-format} - { \acro_property_get:nn {#1} {short} } - } + \acro_format:nnn + {#1} + {short} + { \acro_property_get:nn {#1} {short} } } } \group_end: @@ -2871,8 +2892,8 @@ \bool_lazy_and:nnTF { \acro_property_if_eq_p:nn {#2} {long} } { \acro_if_first_p:n {#1} } - { \__acro_format:nnn {#1} {first-#2} } - { \__acro_format:nnn {#1} {#2} } + { \acro_format:nnn {#1} {first-#2} } + { \acro_format:nnn {#1} {#2} } { \__acro_upper:n { @@ -3512,6 +3533,9 @@ \msg_new:nnn {acro} {label} { The~ list~ template~ `#1'~ needs~ the~ option~ `labels'~ activated. } +\msg_new:nnn {acro} {threshold} + { The~ sequentes~ threshold~ needs~ to~ be~ at~ least~ 3. } + \group_begin: \char_set_catcode_other:N \@ @@ -3664,7 +3688,7 @@ } } } - \seq_use:Nn \l__acro_tmpb_seq {,~} + \seq_use:Nn \l__acro_tmpb_seq { \l__acro_pages_sep_tl } } % #1: sequence @@ -3673,13 +3697,16 @@ \cs_new_protected:Npn \__acro_finish_range:Nnn #1#2#3 { \seq_pop_right:NN #1 \l__acro_tmpa_tl - \int_compare:nNnTF #2 > 1 + \int_compare:nNnTF {#2} > 1 { - \bool_if:NTF \l__acro_sequentes_bool + \bool_lazy_and:nnTF + { \l__acro_seq_use_bool } + { \int_compare_p:nNn {#2} < \l__acro_pages_seq_threshold_int } { \seq_put_right:Ne \l__acro_tmpb_seq { \exp_not:V \l__acro_tmpa_tl + \exp_not:V \l__acro_pages_seq_pre_tl \acro_translate:n {sequentes} } } @@ -3693,11 +3720,12 @@ } } { - \bool_if:NTF \l__acro_sequentes_bool + \bool_if:NTF \l__acro_seq_use_bool { \seq_put_right:Ne \l__acro_tmpb_seq { \exp_not:V \l__acro_tmpa_tl + \exp_not:V \l__acro_pages_seq_pre_tl \acro_translate:n {sequens} } } @@ -3712,7 +3740,7 @@ \bool_new:N \l__acro_pages_all_bool \bool_new:N \l__acro_pages_display_bool -\bool_new:N \l__acro_sequentes_bool +\bool_new:N \l__acro_seq_use_bool % #1: id \prg_new_conditional:Npnn \acro_if_pages:n #1 {p,T,F,TF} @@ -3747,6 +3775,10 @@ \cs_generate_variant:Nn \acro_no_page_ranges:n {e} \tl_new:N \l__acro_pages_fill_tl +\tl_new:N \l__acro_pages_sep_tl +\tl_new:N \l__acro_pages_seq_pre_tl + +\int_new:N \l__acro_pages_seq_threshold_int \keys_define:nn {acro/pages} { @@ -3757,14 +3789,23 @@ display / first .code:n = \bool_set_true:N \l__acro_pages_display_bool \bool_set_false:N \l__acro_pages_all_bool , - display / none .code:n = + display / none .code:n = \bool_set_false:N \l__acro_pages_display_bool , - seq .bool_set:N = \l__acro_sequentes_bool , - seq .initial:n = true , - fill .tl_set:N = \l__acro_pages_fill_tl , - fill .initial:n = \dotfill , - name .bool_set:N = \l__acro_pages_name_display_bool , - name .initial:n = false + seq / use .bool_set:N = \l__acro_seq_use_bool , + seq / use .initial:n = true , + seq / pre .tl_set:N = \l__acro_pages_seq_pre_tl , + seq / pre .initial:n = \, , + seq / threshold .code:n = + \int_compare:nNnTF {#1} < 3 + { \msg_error:nn {acro} {threshold} } + { \int_set:Nn \l__acro_pages_seq_threshold_int {#1} } , + seq / threshold .initial:n = 3 , + fill .tl_set:N = \l__acro_pages_fill_tl , + fill .initial:n = \dotfill , + sep .tl_set:N = \l__acro_pages_sep_tl , + sep .initial:n = {,~} , + name .bool_set:N = \l__acro_pages_name_display_bool , + name .initial:n = false } % ---------------------------------------------------------------------------- @@ -3781,6 +3822,9 @@ Otherwise~ contact~ the~ author~ and~ he'll~ probably~ add~ your~ language. } +\msg_new:nnn {acro} {translation-value} + { You~ need~ to~ give~ a~ value~ to~ `#1'~ \msg_line_context: } + % -------------------------------------------------------------------------- \bool_new:N \l__acro_show_locale_bool \bool_new:N \l__acro_list_show_locale_bool @@ -3921,21 +3965,28 @@ % #2: csv list: { = , = } \cs_new_protected:Npn \acro_declare_translations:nn #1#2 { - \clist_map_inline:nn {#2} - { \__acro_declare_translation:nw {#1} ##1 \q_stop } + \cs_set:Npn \__acro_declare_translation_aux:n ##1 + { \msg_error:nnn {acro} {translation-value} {##1} } + \cs_set:Npn \__acro_declare_translation_aux:nn ##1##2 + { \acro_declare_translation:nnn {##1} {#1} {##2} } + \keyval_parse:NNn + \__acro_declare_translation_aux:n + \__acro_declare_translation_aux:nn + {#2} } -% #1: keyword -% #2: language -% #3: translation -\cs_new_protected:Npn \__acro_declare_translation:nw #1#2=#3\q_stop +% #1: language +% #2: csv list: { = , = } +\cs_new_protected:Npn \acro_add_translations:nn #1#2 { - \tl_set:Nx \l__acro_tmpa_tl { \tl_trim_spaces:n {#2} } - \tl_set:Nx \l__acro_tmpb_tl { \tl_trim_spaces:n {#3} } - \acro_declare_translation:VnV - \l__acro_tmpa_tl - {#1} - \l__acro_tmpb_tl + \cs_set:Npn \__acro_declare_translation_aux:n ##1 + { \msg_error:nnn {acro} {translation-value} {##1} } + \cs_set:Npn \__acro_declare_translation_aux:nn ##1##2 + { \acro_declare_translation:nnn {#1} {##1} {##2} } + \keyval_parse:NNn + \__acro_declare_translation_aux:n + \__acro_declare_translation_aux:nn + {#2} } % within the loop: @@ -4584,7 +4635,7 @@ \acro_set_pdf_cs:Nn \Aclp {Long-plural} \acro_set_pdf_cs:Nn \acap {alt-plural} \acro_set_pdf_cs:Nn \Acap {Alt-plural} - \cs_set_eq:NN \__acro_format:nnn \use_iii:nnn + \cs_set_eq:NN \acro_format:nnn \use_iii:nnn \cs_set:Npn \@ {} } \cs_set_protected:Npn \acro_hyper_page:n #1 { \hyperpage {#1} } @@ -4977,48 +5028,59 @@ Italian = Acronimi , Portuguese = Acr\'onimos , Spanish = Siglas , - Catalan = Sigles , - Turkish = K\i saltmalar + Catalan = Sigles } % page name \DeclareAcroTranslation {page} { - Fallback = p. , - English = p. , - French = p. , - German = S. , - Portuguese = p. + Fallback = p\abbrdot , + English = p\abbrdot , + French = p\abbrdot , + German = S\abbrdot , + Italian = p\abbrdot , + Portuguese = p\abbrdot , + Spanish = p\'ag\abbrdot , + Catalan = p\`ag\abbrdot } % pages name \DeclareAcroTranslation {pages} { - Fallback = pp. , - English = pp. , - French = pp. , - German = S. , - Portuguese = pp. + Fallback = pp\abbrdot , + English = pp\abbrdot , + French = pp\abbrdot , + German = S\abbrdot , + Italian = pp\abbrdot , + Portuguese = pp\abbrdot , + Spanish = p\'ags\abbrdot , + Catalan = p\`ag\abbrdot } % following page \DeclareAcroTranslation {sequens} { - Fallback = f. , - English = f. , - French = sq. , - German = f. , - Portuguese = s. + Fallback = f\abbrdot , + English = f\abbrdot , + French = sq\abbrdot , + German = f\abbrdot , + Italian = s\abbrdot , + Portuguese = s\abbrdot , + Spanish = s\abbrdot , + Catalan = seq\abbrdot } % following pages \DeclareAcroTranslation {sequentes} { - Fallback = ff. , - English = ff. , - French = sqq. , - German = ff. , - Portuguese = ss. + Fallback = ff\abbrdot , + English = ff\abbrdot , + French = sqq\abbrdot , + German = ff\abbrdot , + Italian = ss\abbrdot , + Portuguese = ss\abbrdot , + Spanish = ss\abbrdot , + Catalan = et seq\abbrdot } % also @@ -5031,8 +5093,7 @@ Italian = anche , Portuguese = tamb\'{e}m , Spanish = tambien , - Catalan = tamb\'{e} , - Turkish = ayr\i ca + Catalan = tamb\'{e} } % or @@ -5045,8 +5106,7 @@ Italian = o , Portuguese = ou , Spanish = o , - Catalan = o , - Turkish = veya + Catalan = o } % and @@ -5059,8 +5119,7 @@ Italian = e , Portuguese = e , Spanish = y , - Catalan = i , - Turkish = ve + Catalan = i } % -------------------------------------------------------------------------- @@ -5326,8 +5385,13 @@ single-format .code:n = \acro_remove_option: , single-form .code:n = \acro_deprecate_option:nn {single-style} {#1} , - first-long-format .code:n = \acro_remove_option: , + first-long-format .code:n = + \acro_deprecate_option:nn {format/first-long} {#1} , + list-short-format .code:n = \acro_remove_option: , + list-long-format .code:n = + \acro_deprecate_option:nn {format/list} {#1} , list-foreign-format .code:n = \acro_remove_option: , + override-list-format .code:n = \acro_remove_option: , format-include-endings .code:n = \acro_deprecate_option:nn {include-endings} {true} , extra-style .code:n = \acro_remove_option: , diff --git a/code/acro.tools.code.tex b/code/acro.tools.code.tex index dfb4413..862ab37 100644 --- a/code/acro.tools.code.tex +++ b/code/acro.tools.code.tex @@ -140,62 +140,6 @@ \keys_set:nn {acro} { list/uppercase/first , uppercase/first } -% -------------------------------------------------------------------------- -% articles -\bool_new:N \l__acro_article_bool -\tl_new:N \g__acro_articles_tl - -% #1: name -% #2: default -\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_list_map:nn {short} - { - \DeclareAcroPropertyAlias {##1-#1} {#1} - \str_if_in:nnF {##1} {-acc} - { \DeclareAcroPropertyAlias {##1-acc-#1} {##1-#1} } - } - \acro_list_map:nn {long} - { - \DeclareAcroPropertyAlias {##1-#1} {#1} - \str_if_in:nnF {##1} {acc} - { \DeclareAcroPropertyAlias {##1-acc-#1} {##1-#1} } - } - \bool_new:c {l__acro_article_#1_bool} - \tl_new:c {l__acro_article_#1_tl} - \exp_args:Nc \NewDocumentCommand {acro#1} {} - { \use:c {acro_#1:} } - \cs_new_protected:cpn {acro_#1:} - { - \bool_if:NF \l__acro_article_bool - { - \bool_set_true:c {l__acro_article_#1_bool} - \bool_set_true:N \l__acro_article_bool - } - } - \keys_define:nn {acro} - { - #1 .tl_set:c = {l__acro_article_#1_tl} , - #1 .initial:n = #2 - } - } - -% #1: id -\cs_new_protected:Npn \__acro_set_article_defaults:n #1 - { - \tl_map_tokens:Nn \g__acro_articles_tl - { \__acro_default_article:nn {#1} } - } - -% #1: id -% #2: article -\cs_new_protected:Npn \__acro_default_article:nn #1#2 - { \acro_property_set:nnv {#1} {#2} {l__acro_article_#2_tl} } - % -------------------------------------------------------------------------- % citing: \bool_new:N \l__acro_cite_bool @@ -331,10 +275,10 @@ \__acro_index:e { \acro_property_get:nn {#1} {index-sort} @ - { % <<< don't let formatting bleed - \acro_property_get:nn {#1} {short-format} - { \acro_property_get:nn {#1} {short} } - } + \acro_format:nnn + {#1} + {short} + { \acro_property_get:nn {#1} {short} } } } \group_end: diff --git a/code/acro.upgrade.code.tex b/code/acro.upgrade.code.tex index 8621ba2..ab4ff9c 100644 --- a/code/acro.upgrade.code.tex +++ b/code/acro.upgrade.code.tex @@ -259,8 +259,13 @@ single-format .code:n = \acro_remove_option: , single-form .code:n = \acro_deprecate_option:nn {single-style} {#1} , - first-long-format .code:n = \acro_remove_option: , + first-long-format .code:n = + \acro_deprecate_option:nn {format/first-long} {#1} , + list-short-format .code:n = \acro_remove_option: , + list-long-format .code:n = + \acro_deprecate_option:nn {format/list} {#1} , list-foreign-format .code:n = \acro_remove_option: , + override-list-format .code:n = \acro_remove_option: , format-include-endings .code:n = \acro_deprecate_option:nn {include-endings} {true} , extra-style .code:n = \acro_remove_option: , diff --git a/doc/acro-manual.cls b/doc/acro-manual.cls index 54842f2..d01b202 100644 --- a/doc/acro-manual.cls +++ b/doc/acro-manual.cls @@ -63,14 +63,15 @@ add-cmds = { % basic commands: ac, Ac, aca, Aca, acf, Acf, acl, Acl, acs, Acs, - iac, Iac, iaca, Iaca, iacf, Iacf, iacl, Iacl, iacs, Iacs , + iac, Iac, iaca, Iaca, iacf, Iacf, iacl, Iacl, iacs, Iacs, acp, Acp, acap, Acap, acfp, Acfp, aclp, Aclp, acsp, Acsp, + acflike, % general commands: - acdot, aciftrailing, acreset, acresetall, acspace, acsetup, acuse, - acuseall, printacronyms, + abbrdot, acdot, aciftrailing, acreset, acresetall, acspace, acsetup, + acuse, acuseall, printacronyms, % used in templates and command definitions: - acroindefinite, acrofull, acrogroupcite, acroheading, acronymsmap, - acronymsmapF, acronymsmapT, acroupper, + acroindefinite, acroformat, acrofull, acrogroupcite, acroheading, + acronymsmap, acronymsmapF, acronymsmapT, acroupper, acronopagerange, acroifF, acroifT, acroifTF, acroifallF, acroifallT, acroifallTF, acroifanyF, acroifanyT, acroifanyTF, acroifchapterF, acroifchapterT, @@ -82,8 +83,8 @@ % declaring stuff: DeclareAcronym, DeclareAcroArticle, DeclareAcroEnding, DeclareAcroProperty, - DeclareAcroTranslation, NewAcroCommand, RenewAcroCommand, - DeclareAcroCommand, ProvideAcroCommand, + AddAcroTranslations, DeclareAcroTranslation, + NewAcroCommand, RenewAcroCommand, DeclareAcroCommand, ProvideAcroCommand, % demonstration of the possessive ending: acg, acfg, aclg, acsg, iacsg, acropossessive, % demonstration if definite article: @@ -104,10 +105,14 @@ module-sep = {\texttt{/}}% } +\DeclareTranslation{English}{cnltx-toc}{Table of contents} + \newcommand*\barg{\textcolor{argument}{\code{!}}} \newcommand*\qarg{\textcolor{argument}{\code{?}}} \newcommand*\uarg{\textcolor{argument}{\code{|}}} +\newidxcmd\sym{\code{#1}}[ (symbol)] + \renewcommand*\cnltx@module@text[2]{% \begingroup \reversemarginpar @@ -516,7 +521,7 @@ \def\acro@example@pdffile@path{./examples/acro.example}% \def\acro@example@desc##1{\csuse{acro@example@texfile@desc@##1}}% \def\acro@example@title##1{% - Example~\theexamplefile: \acro@example@desc{##1} + Example~\theexamplefile: \acro@example@desc{##1}% \\Links: \acro@example@links{##1}\hfill File: \code{acro.example.##1.tex}% }% \def\acro@example@bookmark##1{Example~\theexamplefile\ (\acro@example@desc{##1})}% @@ -552,7 +557,10 @@ \dolistloop\acro@examplefiles } +\newidxcmd\cmd{\code{\textbackslash\textcolor{white}{#1}}} + \acro@add@example{basic}{Basic usage} +\acro@add@example{acflike}{Re-implement \cmd*{acflike}} \acro@add@example{issue-109}{Invisible command for backref} \acro@add@example{issue-111}{Defining a definite article} \acro@add@example{issue-119}{Write the list of acronyms to an external file} @@ -563,7 +571,7 @@ % ---------------------------------------------------------------------------- - +% 2012: v0 \acro@add@version{2012-06-22}{0.1} \acro@add@version{2012-06-23}{0.1a} \acro@add@version{2012-06-24}{0.1b} @@ -581,6 +589,7 @@ \acro@add@version{2012-11-30}{0.5} \acro@add@version{2012-12-14}{0.6} \acro@add@version{2013-01-02}{0.6a} +% 2013: v1 \acro@add@version{2013-01-16}{1.0} \acro@add@version{2013-01-26}{1.1} \acro@add@version{2013-01-29}{1.1a} @@ -601,6 +610,7 @@ \acro@add@version{2015-02-26}{1.6} \acro@add@version{2015-04-08}{1.6a} \acro@add@version{2015-05-10}{1.6b} +% 2015: v2 \acro@add@version{2015-08-16}{2.0} \acro@add@version{2015-08-25}{2.0a} \acro@add@version{2015-08-29}{2.0b} @@ -637,7 +647,7 @@ \acro@add@version{2020-01-16}{2.11a} \acro@add@version{2020-01-24}{2.11b} \acro@add@version{2020-02-03}{2.11c} -\acro@add@version{2020-04-06}{v3.0alpha} -\acro@add@version{2020-04-20}{v3.0beta} +% 2020: v3 +\acro@add@version{2020-04-25}{v3.0} \endinput diff --git a/doc/acro-manual.pdf b/doc/acro-manual.pdf index f2a8649..adcbb7f 100644 Binary files a/doc/acro-manual.pdf and b/doc/acro-manual.pdf differ diff --git a/doc/acro-manual.tex b/doc/acro-manual.tex index 452f9c2..6470c95 100644 --- a/doc/acro-manual.tex +++ b/doc/acro-manual.tex @@ -185,7 +185,7 @@ % declare glossary terms: \DeclareAcronym{property}{ long = A \property*{property} is an option to the second argument of the - \cs*{DeclareAcroym} command. This are options of an individual acronym if + \cs*{DeclareAcroym} command. They are options of an individual acronym if you will. , tag = glossary , no-index } @@ -207,27 +207,24 @@ } \DeclareAcronym{articles}{ long = {Articles are prefixes to acronyms, usually separated with a blank. - \emph{They are mutually exclusive.}} , + \emph{Different types of articles are mutually exclusive.}} , tag = glossary , no-index } \DeclareAcronym{endings}{ - long = {Endings are postfixes to acronyms, usually no separated from the - acronym.} , + long = {Endings are postfixes to acronyms, usually not separated from the + acronym. \emph{Different types of endings are mutually exclusive.}} , tag = glossary , no-index } \DeclareAcronym{translations}{ - long = Localisation strings which can be modified and extended. , + long = Localisation strings which can be modified. , tag = glossary , no-index } \newcommand*\issues{\url{https://github.com/cgnieder/acro/issues}} -\begin{document} +\newcommand*\latin[1]{\textit{#1}} -\begin{bewareofthedog} - Hi and thanks that you are testing v3.0 of \acro\ before it is released to - \ac{ctan}. -\end{bewareofthedog} +\begin{document} \clearpage \part{Get started with \acro}\label{part:get-started-with} @@ -244,7 +241,8 @@ \section{\acro\ for the impatient}\label{sec:acro-impatient} \begin{commands} \command{DeclareAcronym}[\marg{id}\marg{properties}] where \meta{id} is a unique string to identify the acronym and - \meta{properties} is a key\slash value list of properties. These include: + \meta{properties} is a key\slash value list of acronym properties. These + include: \end{commands} \begin{properties} %% short @@ -303,14 +301,15 @@ \subsection{Load-time options}\label{sec:load-time-options} argument to \cs*{usepackage}: \begin{options} \keychoice{version}{2,3}\Default{3} - This option allows you to use the last version prior to the update to - version~3. This may help if you don't have the time to fix issues with - the new version. + The option allows you to use the last version prior to the update to + version~3. This may help if you don't have the time to fix issues after + upgrading to the new version. \keybool{upgrade}\Default{true} When this option is used \acro\ tries to give as much helpful and meaningful warning or error messages when a deprecated or removed command, property, or option is used. This is especially useful if you are - upgrading from version~2. + upgrading from version~2. The option will initially be true for a few + months after the upgrade to version~3. \end{options} \subsection{Setup command}\label{sec:setup-command} @@ -320,8 +319,8 @@ \subsection{Setup command}\label{sec:setup-command} \command{acsetup}[\marg{options}] or as option to other commands. If the latter is possible then it is described when the corresponding commands are explained. Options usually - follow a key\slash value syntax like and are always described in the - following way: + follow a key\slash value syntax and are always described in the following + way: \end{commands} \begin{options} \opt*{option} @@ -353,17 +352,16 @@ \section{Declaring acronyms and other abbreviations}\label{sec:decl-acronyms-oth All acronyms have to be declared in the preamble with the following command in order to be used in the document. Any usage of an acronym which has not been -declared leeds to an error message. +declared leads to an error message. \begin{commands} \command{DeclareAcronym}[\marg{id}\marg{list of properties}] The basic command for declaring an acronym where \meta{id} is a unique - string identifying the acronym. Per default behavior this is case - sensitive which means \code{id} is different from \code{ID}, for example. - There is an option \option{case-sensitive} to change this. + string identifying the acronym. Per default this is case sensitive which + means \code{id} is different from \code{ID}, for example. \end{commands} -This command understands a number of properties which are listed in the +The command understands a number of properties which are listed in the following sections. This is a comprehensive overview over the existing -properties. Most of these properties are explained in more detail in later +properties. Many properties are also explained in more detail in later sections of this manual. \begin{options} \keybool{case-sensitive}\Default{false} @@ -863,11 +861,17 @@ \subsection{Add page numbers to the list}\label{sec:page-numbers} Decide wether to include page numbers in the list of acroynms and wether to add the first page or every page. When you choose \code{first} and have \pkg{hyperref} loaded you will also get a backlink to that page. - \keybool{seq}\Module{pages}\Default{true} - When you chose \module{pages}\code{/}\keyis{display}{all} then you can - decide wether you want a page list like 2,3,5,6,7 be displayed as 2f.\ - 5ff. (when this option is true) or as 2,3,5--6 (when this option is - false). + \keybool{use}\Module{pages,seq}\Default{true} + Turns a two-page range into \meta{num}\,f.\ (\latin{sequens}) and a + three-page range into \meta{num}\,ff.\ (\latin{sequentes}) when set to + \code{true}. + \keyval{pre}{code}\Module{pages,seq}\Default{\cs*{,}} + \meta{code} is inserted between the page number and the sequens or + sequentes symbol. + \keyval{threshold}{num}\Module{pages,seq}\Default{3} + The threshold for a page range to be turned into \latin{sequentes}. A + page range above the threshold is still typeset as a range: + \meta{num1}--\meta{num2}. \keyval{fill}{code}\Module{pages}\Default{\cs*{dotfill}} This is the code that is placed between acronym description and actual page numbers. @@ -1410,8 +1414,8 @@ \section{Trailing tokens}\label{sec:trailing-tokens} \subsection{What is it about?} \acro\ has the possibility to look ahead for certain tokens and switch a boolean variable if it finds them. Per default \acro\ knows about three -tokens: the \enquote{\code{dot}} (\code{.}), the \enquote{\code{dash}} -(\code{-}) and the \enquote{\code{babel-hyphen}} (\cs*{babelhyphen}). +tokens: the \enquote{\code{dot}} (\sym{.}), the \enquote{\code{dash}} +(\sym{-}) and the \enquote{\code{babel-hyphen}} (\cs*{babelhyphen}). Yeu have seen an example for this already: \begin{sourcecode} @@ -1478,9 +1482,10 @@ \subsection{How does it work?} \begin{sourcecode} \acsetup{ trailing/define = . {dot} , + trailing/define = {, {comma}} , trailing/define = - {dash} trailing/define = \babelhyphen {babel-hyphen} , - trailing/activate = dot + trailing/activate = {dot,comma} } \end{sourcecode} @@ -1494,14 +1499,15 @@ \subsection{How does it work?} \end{commands} This command is used to define the two commands you already know: \begin{commands} - \expandable\command{acdot} Inserts \code{.}\cs*{@} if no \code{dot} follows. + \expandable\command{acdot} Inserts \cs{abbrdot} if no \code{dot} follows. \expandable\command{acspace} Inserts a \cs*{space} if no \code{dash} or \code{babel-hyphen} follows. + \expandable\command{abbrdot} Inserts \sym{.}\cs*{@} \end{commands} The definitions are equivalent\footnote{Not \emph{quite}: \acro's definitions are engine protected.} to the following code: \begin{sourcecode} - \newcommand*\acdot{\aciftrailing{dot}{}{.\@}} + \newcommand*\acdot{\aciftrailing{dot}{}{\abbrdot}} \newcommand*\acspace{\aciftrailing{dash,babel-hyphen}{}{\space}} \end{sourcecode} You are of course free to redefine them according to your needs. @@ -1693,8 +1699,8 @@ \section{Localisation}\label{sec:localisation} language. It is meant for usage in template definitions. \end{commands} -Available keywords and their English and German translations are shown in -table~\vref{tab:translations}. +Available keywords and their English, French, and German translations are +shown in table~\vref{tab:translations}. \begin{table} \centering @@ -1864,6 +1870,11 @@ \subsubsection{Commands for common uses} ending either in uppercase or lowercase form. Default is the lowercase form without ending or article. The actual outcome is determined by switches which are explained in section~\vref{sec:own-acronym-commands}. + \command{acroformat}[\marg{type}\marg{text}] + This formats \meta{text} according to \meta{type} where \meta{type} has + either been set as property or as option from the \module{format} module. + Valid values are \code{short}, \code{long}, \code{alt}, \code{extra}, + \code{foreign}, \code{list}, and \code{first-long}. \command{acroshow}[\marg{property}] For debugging puposes: writes the property \meta{property} of the current acronym to the log file. @@ -2156,18 +2167,34 @@ \section{Translations}\label{sec:translations} keywords, or for changing existing translations \acro\ uses this command: \begin{commands} \command{DeclareAcroTranslation}[\marg{key}\marg{language=translation list}] - With this command new translations can be added or existing translations - can be changed. + With this command new translations keywords can be added and translations + for existing keywords can be changed. + \command{AddAcroTranslations}[\marg{key}\marg{language=translation list}] + Basically the same but this time per language rather than per keyword. \end{commands} As an example this is how \acro\ declares translations for the \code{pages} keyword: \begin{sourcecode} \DeclareAcroTranslation{pages}{ - Fallback = pp. , - English = pp. , - French = pp. , - German = S. , - Portuguese = pp. + Fallback = pp\abbrdot , + English = pp\abbrdot , + French = pp\abbrdot , + German = S\abbrdot , + Portuguese = pp\abbrdot + } +\end{sourcecode} +Translations for a language could be added this way\footnote{\acro\ already + has the translations for Italian.}: +\begin{sourcecode} + \AddAcroTranslations{Italian}{ + list-name = Acronimi , + page = p\abbrdot , + pages = pp\abbrdot , + sequens = s\abbrdot , + sequentes = ss\abbrdot , + also = anche , + and = e , + or = o } \end{sourcecode} The existing keywords had been shown in table~\vref{tab:translations}. @@ -2181,15 +2208,15 @@ \section{Properties}\label{sec:new-properties} \command{DeclareAcroProperty}[\sarg\qarg\barg\uarg\marg{name}] This defines the new property \meta{name}. The command has four optional arguments most of which you probably never need. \par - The optional star \code{*} ensures that each acronym gets a \emph{unique} + The optional star \sym{*} ensures that each acronym gets a \emph{unique} value for the property. \par - The optional question mark \code{?} creates a \emph{boolean} property. + The optional question mark \sym{?} creates a \emph{boolean} property. That is a property that only can get the values \code{true} or \code{false} and when it is used without value (not an empty value!) then \code{true} is assumed. \par - The optional bang \code{!} creates a \emph{mandatory} property. An error - if raised if an acronym does not set it. \par - The optional pipe \code{|} creates a \emph{static} property which means + The optional exclamation mark \sym{!} creates a \emph{mandatory} + property. An error if raised if an acronym does not set it. \par + The optional pipe \sym{|} creates a \emph{static} property which means its value is written to an auxiliary file and read in again at begin document. Once set the value is the same throughout the document \command{DeclareAcroPropertyAlias}[\sarg\qarg\barg\uarg\marg{name1}\marg{name2}] @@ -2225,10 +2252,12 @@ \subsection{Background} count usage, index, and add a citation if necessary. \command{RenewAcroCommand}[\marg{command}\marg{arg. spec.}\marg{code}] Like \cs{NewAcroCommand} but redefines an existing command. - \command{UseAcrotemplate}[\oarg{type}\marg{name}\oarg{argument number}] - The argument \meta{type} defaults to \code{acronym} and meta{argument - number} defaults to \code{1}. All predefined acronym templates use - the first argument as \ac{id} so they must at least use one argument. + \command{UseAcroTemplate}[\oarg{type}\marg{name}\oarg{argument number}\meta{arguments}] + The argument \meta{type} defaults to \code{acronym} and \meta{argument + number} defaults to \code{1}. The command must be followed by as many + mandatory arguments as you specify with \meta{argument number}. All + predefined acronym templates use the first argument as \ac{id} so they + must use one argument. \end{commands} Let's see an example. This is the definition of \cs{ac}: \begin{sourcecode} @@ -2304,7 +2333,7 @@ \subsection{Create commands for possessive endings} This is the \acg{MP} first day at work after \dots \end{example} -\section{Own \acro style files} +\section{Own \acro\ style files} When you want to use your definitions regarding \acro\ repeatedly then it makes sense to put them in a file which you put somewhere in your local \LaTeX\ tree. There are three options: