diff options
author | Karl Berry <karl@freefriends.org> | 2016-04-14 21:45:42 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-04-14 21:45:42 +0000 |
commit | 75abca078467cf614b05107058c1255f20163316 (patch) | |
tree | d74414841883c49b363fecca5e43e70de1408195 /Master/texmf-dist/tex/latex/acro/acro.sty | |
parent | a4e3ac91784ab034090726ebb9a8718be0bdc7b6 (diff) |
acro (14apr16)
git-svn-id: svn://tug.org/texlive/trunk@40521 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/acro/acro.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/acro/acro.sty | 275 |
1 files changed, 180 insertions, 95 deletions
diff --git a/Master/texmf-dist/tex/latex/acro/acro.sty b/Master/texmf-dist/tex/latex/acro/acro.sty index d646a937712..93db29db068 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,etoolbox} \ProvidesExplPackage {acro} - {2016/03/25} - {2.4} + {2016/04/14} + {2.4a} {Typeset Acronyms} % -------------------------------------------------------------------------- @@ -213,6 +213,7 @@ \bool_new:N \l__acro_new_page_numbering_bool \bool_new:N \l__acro_first_use_brackets_bool \bool_new:N \l__acro_first_only_short_bool +\bool_new:N \l__acro_first_only_long_bool \bool_new:N \l__acro_first_reversed_bool \bool_new:N \l__acro_use_note_bool \bool_new:N \l__acro_extra_punct_bool @@ -500,7 +501,10 @@ % objects with three arguments: \cs_new_protected:Npn \acro_first_instance:nnnn #1#2#3#4 - { \UseInstance {acro-first} {#1} {#2} {#3} {#4} } + { + \acro_if_defined:nT {#2} + { \UseInstance {acro-first} {#1} {#2} {#3} {#4} } + } \cs_generate_variant:Nn \acro_first_instance:nnnn {VnV,VnVV} % -------------------------------------------------------------------------- @@ -576,6 +580,7 @@ brackets : boolean = true , brackets-type : tokenlist = () , only-short : boolean = false , + only-long : boolean = false , reversed : boolean = false , between : tokenlist , foreign-sep : tokenlist = { , ~ } @@ -585,76 +590,128 @@ brackets = \l__acro_first_use_brackets_bool , brackets-type = \l__acro_first_brackets_tl , only-short = \l__acro_first_only_short_bool , + only-long = \l__acro_first_only_long_bool , reversed = \l__acro_first_reversed_bool , between = \l__acro_first_between_tl , foreign-sep = \l__acro_foreign_sep_tl } { \AssignTemplateKeys - \bool_if:nT { !\l__acro_first_only_short_bool && !\l__acro_first_reversed_bool } - { - \acro_write_indefinite:nn {#1} {long} - \acro_write_expanded:nnn {#1} {first-long} {#3} - \acro_space: - \tl_if_blank:VF \l__acro_first_between_tl + \bool_if:NTF \l__acro_first_reversed_bool + { % zuerst kurze Form, dann lange Form: + \bool_if:NF \l__acro_first_only_long_bool { - \tl_use:N \l__acro_first_between_tl - \acro_space: + \acro_write_indefinite:nn {#1} {short} + \group_begin: + \acro_for_all_trailing_tokens_do:n + { \acro_deactivate_trailing_action:n {##1} } + \acro_write_compact:nn {#1} {short} + \group_end: + \bool_if:NF \l__acro_first_only_short_bool + { + \acro_space: + \tl_if_blank:VF \l__acro_first_between_tl + { + \tl_use:N \l__acro_first_between_tl + \acro_space: + } + } } + % öffnende Klammer: + \bool_if:nT + { + \l__acro_first_use_brackets_bool && + !\l__acro_first_only_short_bool && + !\l__acro_first_only_long_bool + } + { \tl_head:N \l__acro_first_brackets_tl } + % fremdsprachige Form: + \bool_if:nT + { + \l__acro_foreign_bool && + !\l__acro_first_only_short_bool && + !\l__acro_first_only_long_bool + } + { + \acro_write_foreign:n {#1} + \acro_if_foreign:nT {#1} { \tl_use:N \l__acro_foreign_sep_tl } + } + % Artikel der Langform und Langform: + \bool_if:NF \l__acro_first_only_short_bool + { + \acro_write_indefinite:nn {#1} {long} + \acro_write_expanded:nnn {#1} {first-long} {#3} + } + % Zitat: + \bool_if:NT \l__acro_group_citation_bool + { \acro_group_cite:n {#1} } + % schließende Klammer: + \bool_if:nT + { + \l__acro_first_use_brackets_bool && + !\l__acro_first_only_short_bool && + !\l__acro_first_only_long_bool + } + { \tl_tail:N \l__acro_first_brackets_tl } } - \bool_if:nT - { \l__acro_first_use_brackets_bool && !\l__acro_first_reversed_bool } - { \tl_head:N \l__acro_first_brackets_tl } - \bool_if:nT - { - \l__acro_foreign_bool && - !\l__acro_first_reversed_bool && - !\l__acro_first_only_short_bool - } - { - \acro_write_foreign:n {#1} - \acro_if_foreign:nT {#1} { \tl_use:N \l__acro_foreign_sep_tl } - } - \bool_if:nT - { \l__acro_first_reversed_bool || \l__acro_first_only_short_bool } - { \acro_write_indefinite:nn {#1} {short} } - \group_begin: - \bool_if:nT - { !\l__acro_first_reversed_bool && !\l__acro_first_only_short_bool } - { - \prop_map_inline:Nn \l__acro_trailing_tokens_prop - { \acro_deactivate_trailing_action:n {##1} } - } - \acro_write_compact:nn {#1} {short} - \group_end: - \bool_if:nT - { \l__acro_group_citation_bool && !\l__acro_first_reversed_bool } - { \acro_group_cite:n {#1} } - \bool_if:nT - { \l__acro_first_use_brackets_bool && !\l__acro_first_reversed_bool } - { \tl_tail:N \l__acro_first_brackets_tl } - \bool_if:NT \l__acro_first_reversed_bool - { + { % zuerst lange Form, dann kurze Form: + % Artikel + lange Form: \bool_if:NF \l__acro_first_only_short_bool { - \tl_if_blank:VF \l__acro_first_between_tl + \acro_write_indefinite:nn {#1} {long} + \acro_write_expanded:nnn {#1} {first-long} {#3} + \bool_if:NF \l__acro_first_only_long_bool { - \tl_use:N \c_space_tl - \tl_use:N \l__acro_first_between_tl + \acro_space: + \tl_if_blank:VF \l__acro_first_between_tl + { + \tl_use:N \l__acro_first_between_tl + \acro_space: + } } - \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:Vo \l__acro_first_long_format_tl {#3} - \acro_if_foreign:nT {#1} - { \acroenparen { \acro_write_foreign:n {#1} } } } + % öffnende Klammer: + \bool_if:nT + { + \l__acro_first_use_brackets_bool && + !\l__acro_first_only_short_bool && + !\l__acro_first_only_long_bool + } + { \tl_head:N \l__acro_first_brackets_tl } + % fremdsprachige Form: + \bool_if:nT + { + \l__acro_foreign_bool && + !\l__acro_first_only_short_bool && + !\l__acro_first_only_long_bool + } + { + \acro_write_foreign:n {#1} + \acro_if_foreign:nT {#1} { \tl_use:N \l__acro_foreign_sep_tl } + } + % Artikel der Kurzform und Kurzform: + \bool_if:NF \l__acro_first_only_long_bool + { + \acro_write_indefinite:nn {#1} {short} + \group_begin: + \acro_for_all_trailing_tokens_do:n + { \acro_deactivate_trailing_action:n {##1} } + \acro_write_compact:nn {#1} {short} + \group_end: + } + % Zitat: \bool_if:NT \l__acro_group_citation_bool { \acro_group_cite:n {#1} } + % schließende Klammer: \bool_if:nT - { \l__acro_first_use_brackets_bool && !\l__acro_first_only_short_bool } + { + \l__acro_first_use_brackets_bool && + !\l__acro_first_only_short_bool && + !\l__acro_first_only_long_bool + } { \tl_tail:N \l__acro_first_brackets_tl } } + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \bool_if:NF \l__acro_group_citation_bool { \acro_cite_if:Nn \l__acro_citation_first_bool {#1} } \acro_index_if:Nn \l__acro_addto_index_bool {#1} @@ -738,6 +795,13 @@ brackets = false } \DeclareInstance {acro-first} + { long } + { inline } + { + only-long = true , + brackets = false + } +\DeclareInstance {acro-first} { reversed } { inline } { reversed = true } @@ -1608,9 +1672,18 @@ % -------------------------------------------------------------------------- % some helpers we'll need more often: +\seq_new:N \g__acro_declared_acronyms_seq + +\prg_new_conditional:Npnn \acro_if_defined:n #1 {p,T,F,TF} + { + \seq_if_in:NnTF \g__acro_declared_acronyms_seq {#1} + { \prg_return_true: } + { \prg_return_false: } + } + \cs_new_protected:Npn \acro_defined:n #1 { - \prop_if_in:NnF \l__acro_short_prop {#1} + \acro_if_defined:nF {#1} { \acro_serious_message:nn {undefined} {#1} } } @@ -2578,10 +2651,13 @@ { \acro_activate_trailing_action:n {#2} } \acro_new_trailing_token:n {#2} } - + \NewDocumentCommand \AcroRegisterTrailing {mm} { \acro_register_trailing_token:Nn #1 {#2} } +\cs_new_protected:Npn \acro_for_all_trailing_tokens_do:n #1 + { \prop_map_inline:Nn \l__acro_trailing_tokens_prop {#1} } + % activate a token: \cs_new_protected:Npn \acro_activate_trailing_token:n #1 { @@ -3528,6 +3604,7 @@ % internal acronym declaring function: \cs_new_protected:Npn \acro_declare_acronym:nn #1#2 { + \seq_gput_right:Nn \g__acro_declared_acronyms_seq {#1} \bool_gset_true:N \g__acro_first_acronym_declared_bool \tl_set:Nn \l__acro_current_key_tl {#1} \keys_set:nn { acro / declare-acronym } {#2} @@ -3605,44 +3682,50 @@ % -------------------------------------------------------------------------- % language support -\RequirePackage { translations } -% Listenname -\DeclareTranslationFallback { acronym-list-name } { Acronyms } -\DeclareTranslation { English } { acronym-list-name } { Acronyms } -\DeclareTranslation { American } { acronym-list-name } { Acronyms } -\DeclareTranslation { British } { acronym-list-name } { Acronyms } -\DeclareTranslation { French } { acronym-list-name } { Acronymes } -\DeclareTranslation { German } { acronym-list-name } { Abk\"urzungen } -\DeclareTranslation { Italian } { acronym-list-name } { Acronimi } -\DeclareTranslation { Portuguese } { acronym-list-name } { Acr\'onimos } -\DeclareTranslation { Spanish } { acronym-list-name } { Siglas } -\DeclareTranslation { Catalan } { acronym-list-name } { Sigles } -\DeclareTranslation { Turkish } { acronym-list-name } { K\i saltmalar } -\tl_set:Nn \l__acro_list_name_tl { \GetTranslation { acronym-list-name } } -% Seitenname -\DeclareTranslationFallback { acronym-page-name } { p. } -\DeclareTranslation { English } { acronym-page-name } { p. } -\DeclareTranslation { German } { acronym-page-name } { S. } -\DeclareTranslation { Portuguese } { acronym-page-name } { p. } -\tl_set:Nn \l__acro_page_name_tl { \GetTranslation { acronym-page-name }\@\, } -% Seitenname - Plural -\DeclareTranslationFallback { acronym-pages-name } { pp. } -\DeclareTranslation { English } { acronym-pages-name } { pp. } -\DeclareTranslation { German } { acronym-pages-name } { S. } -\DeclareTranslation { Portuguese } { acronym-pages-name } { pp. } -\tl_set:Nn \l__acro_pages_name_tl { \GetTranslation { acronym-pages-name }\@\, } -% einzelne folgende Seite -\DeclareTranslationFallback { acronym-next-page } { f. } -\DeclareTranslation { English } { acronym-next-page } { f. } -\DeclareTranslation { German } { acronym-next-page } { f. } -\DeclareTranslation { Portuguese } { acronym-next-page } { s. } -\tl_set:Nn \l__acro_next_page_tl { \,\GetTranslation {acronym-next-page }\@ } -% mehrere folgende Seiten -\DeclareTranslationFallback { acronym-next-pages } { ff. } -\DeclareTranslation { English } { acronym-next-pages } { ff. } -\DeclareTranslation { German } { acronym-next-pages } { ff. } -\DeclareTranslation { Portuguese } { acronym-next-pages } { ss. } -\tl_set:Nn \l__acro_next_pages_tl { \,\GetTranslation {acronym-next-pages }\@ } +\RequirePackage {translations} +% list name +\DeclareTranslationFallback {acronym-list-name} {Acronyms} +\DeclareTranslation {English} {acronym-list-name} {Acronyms} +\DeclareTranslation {American} {acronym-list-name} {Acronyms} +\DeclareTranslation {British} {acronym-list-name} {Acronyms} +\DeclareTranslation {French} {acronym-list-name} {Acronymes} +\DeclareTranslation {German} {acronym-list-name} {Abk\"urzungen} +\DeclareTranslation {Italian} {acronym-list-name} {Acronimi} +\DeclareTranslation {Portuguese} {acronym-list-name} {Acr\'onimos} +\DeclareTranslation {Spanish} {acronym-list-name} {Siglas} +\DeclareTranslation {Catalan} {acronym-list-name} {Sigles} +\DeclareTranslation {Turkish} {acronym-list-name} {K\i saltmalar} + +% page name +\DeclareTranslationFallback {acronym-page-name} {p.} +\DeclareTranslation {English} {acronym-page-name} {p.} +\DeclareTranslation {German} {acronym-page-name} {S.} +\DeclareTranslation {Portuguese} {acronym-page-name} {p.} + +% pages name +\DeclareTranslationFallback {acronym-pages-name} {pp.} +\DeclareTranslation {English} {acronym-pages-name} {pp.} +\DeclareTranslation {German} {acronym-pages-name} {S.} +\DeclareTranslation {Portuguese} {acronym-pages-name} {pp.} + +% following page +\DeclareTranslationFallback {acronym-next-page} {f.} +\DeclareTranslation {English} {acronym-next-page} {f.} +\DeclareTranslation {German} {acronym-next-page} {f.} +\DeclareTranslation {Portuguese} {acronym-next-page} {s.} + +% following pages +\DeclareTranslationFallback {acronym-next-pages} {ff.} +\DeclareTranslation {English} {acronym-next-pages} {ff.} +\DeclareTranslation {German} {acronym-next-pages} {ff.} +\DeclareTranslation {Portuguese} {acronym-next-pages} {ss.} + +% tokenlists using the translations: +\tl_set:Nn \l__acro_list_name_tl { \GetTranslation {acronym-list-name} } +\tl_set:Nn \l__acro_page_name_tl { \GetTranslation {acronym-page-name}\@\, } +\tl_set:Nn \l__acro_pages_name_tl { \GetTranslation {acronym-pages-name}\@\, } +\tl_set:Nn \l__acro_next_page_tl { \,\GetTranslation {acronym-next-page}\@ } +\tl_set:Nn \l__acro_next_pages_tl { \,\GetTranslation {acronym-next-pages}\@ } % -------------------------------------------------------------------------- % allow for a configuration file: @@ -3819,11 +3902,13 @@ endings - property `foreign-lang' - fix issue #65 -2016/03/?? v2.4 - extend class mechanism: classes can be used like tags +2016/03/25 v2.4 - extend class mechanism: classes can be used like tags - add idea of `barriers' and list local to those barriers => new option `reset-at-barriers' => new option `local-to-barriers' for \printacronyms => new command \acbarrier +2016/04/14 v2.4a - if undefined acronym is used and `messages = silent' is + active don't through error % -------------------------------------------------------------------------- % TODO: |