diff options
author | Karl Berry <karl@freefriends.org> | 2013-01-18 23:26:48 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-01-18 23:26:48 +0000 |
commit | fb0e09783157c2c9f8e6899a25abc2442b8a77f6 (patch) | |
tree | 3ac58c5ecaa0f0e9130476ed1507cd8fdac116fc /Master/texmf-dist/tex/latex/acro | |
parent | 9a3b24b6c40172a8e489ab6d7409303db574c826 (diff) |
acro (17jan13)
git-svn-id: svn://tug.org/texlive/trunk@28867 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 | 649 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/acro/acro0.def | 168 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/acro/acro1.def | 337 |
3 files changed, 954 insertions, 200 deletions
diff --git a/Master/texmf-dist/tex/latex/acro/acro.sty b/Master/texmf-dist/tex/latex/acro/acro.sty index f867b88fe19..fb8b8c09105 100644 --- a/Master/texmf-dist/tex/latex/acro/acro.sty +++ b/Master/texmf-dist/tex/latex/acro/acro.sty @@ -23,7 +23,7 @@ % The Current Maintainer of this work is Clemens Niederberger. % -------------------------------------------------------------------------- % The acro package consists of the files -% - acro.sty, acro_en.tex, acro_en.pdf, README +% - acro.sty, acro0.def, acro1.def, acro_en.tex, acro_en.pdf, README % -------------------------------------------------------------------------- % If you have any ideas, questions, suggestions or bugs to report, please % feel free to contact me. @@ -31,11 +31,11 @@ \RequirePackage{expl3,xparse,l3keys2e,xtemplate} \ProvidesExplPackage {acro} - {2013/01/02} - {0.6a} + {2013/01/16} + {1.0} {Typeset Acronyms} -% error messages: +% warning and error messages: \msg_new:nnnn { acro } { undefined } { You've~requested~acronym~`#1'~but~it~seems~that~it~was~never~defined! } { @@ -43,12 +43,23 @@ apperantly~haven't~defined~it,~yet!~Maybe~you've~mispelled~it? } +\msg_new:nnnn { acro } { version } + { You've~selected~the~version~option~`#1'~which~doesn't~exist. } + { + You've~selected~the~version~option~`#1'~which~doesn't~exist.~ + I'm~using~option~`#2'~instead. + } + % temporary variables \tl_new:N \l__acro_tmpa_tl \tl_new:N \l__acro_tmpb_tl \tl_new:N \l__acro_tmpc_tl \prop_new:N \l__acro_tmpa_prop +\prop_new:N \l__acro_tmpb_prop \seq_new:N \l__acro_tmpa_seq +\seq_new:N \l__acro_tmpb_seq + +\tl_new:N \l__acro_ignore_tl % boolean variables: \bool_new:N \l__acro_mark_as_used_bool @@ -64,10 +75,16 @@ \bool_new:N \l__acro_xspace_bool \bool_new:N \l__acro_first_upper_bool \bool_new:N \l__acro_sort_bool +\bool_set_true:N \l__acro_sort_bool \bool_new:N \l__acro_capitalize_list_bool \bool_new:N \l__acro_citation_all_bool \bool_new:N \l__acro_citation_first_bool \bool_set_true:N \l__acro_citation_first_bool +\bool_new:N \l__acro_acc_supp_bool +\bool_new:N \l__acro_page_ranges_bool +\bool_set_true:N \l__acro_page_ranges_bool +\bool_new:N \l__acro_record_pages_bool +\bool_set_true:N \l__acro_record_pages_bool % tokenlist variables: \tl_new:N \l__acro_short_format_tl @@ -81,7 +98,13 @@ \tl_new:N \l__acro_page_instance_tl \tl_set:Nn \l__acro_page_instance_tl { none } \tl_new:N \l__acro_page_name_tl -\tl_set:Nn \l__acro_page_name_tl { p. } +\tl_set:Nn \l__acro_page_name_tl { p.\@\, } +\tl_new:N \l__acro_pages_name_tl +\tl_set:Nn \l__acro_pages_name_tl { pp.\@\, } +\tl_new:N \l__acro_next_page_tl +\tl_set:Nn \l__acro_next_page_tl { \,f.\@ } +\tl_new:N \l__acro_next_pages_tl +\tl_set:Nn \l__acro_next_pages_tl { \,ff.\@ } \tl_new:N \l__acro_list_instance_tl \tl_set:Nn \l__acro_list_instance_tl { list } \tl_new:N \l__acro_list_type_tl @@ -104,6 +127,7 @@ % property list variables: \prop_new:N \l__acro_short_prop \prop_new:N \l__acro_alt_prop +\prop_new:N \l__acro_sort_prop \prop_new:N \l__acro_long_prop \prop_new:N \l__acro_class_prop \prop_new:N \l__acro_replace_plural_prop @@ -116,6 +140,7 @@ \prop_new:N \l__acro_citation_post_prop \prop_new:N \l__acro_pdfstring_prop \prop_new:N \l__acro_pdfstring_plural_prop +\prop_new:N \l__acro_acc_supp_prop % length variables: \dim_new:N \l__acro_table_width_dim @@ -129,9 +154,39 @@ \cs_new_eq:NN \acro_first_upper_case:n \__acro_first_upper_case:n +% -------------------------------------------------------------------------- +% versioning: +\tl_new:N \l__acro_active_version_tl +\tl_new:N \l__acro_version_zero_tl +\tl_set:Nn \l__acro_version_zero_tl { 0 } + +\clist_new:N \l__acro_versions_clist +\clist_put_right:Nn \l__acro_versions_clist { 0 } +\clist_put_right:Nn \l__acro_versions_clist { 1 } + +\bool_new:N \l__acro_version_selected_bool + +\cs_new:Npn \__acro_select_version:n #1 + { + \clist_if_in:NnTF \l__acro_versions_clist { #1 } + { + \file_input:n { acro#1.def } + \tl_set:Nn \l__acro_active_version_tl { #1 } + } + { + \msg_warning:nnxx { acro } { version } { #1 } { 1 } + \file_input:n { acro1.def } + \tl_set:Nn \l__acro_active_version_tl { 1 } + } + \bool_set_true:N \l__acro_version_selected_bool + } + + % options: \keys_define:nn { acro } { + version .code:n = \__acro_select_version:n { #1 } , + accsupp .bool_set:N = \l__acro_acc_supp_bool , macros .bool_set:N = \l__acro_create_macros_bool , xspace .bool_set:N = \l__acro_xspace_bool , strict .bool_set:N = \l__acro_strict_bool , @@ -147,6 +202,11 @@ extra-style .tl_set:N = \l__acro_extra_instance_tl , page-ref .tl_set:N = \l__acro_page_instance_tl , page-name .tl_set:N = \l__acro_page_name_tl , + pages-name .tl_set:N = \l__acro_pages_name_tl , + page-ranges .bool_set:N = \l__acro_page_ranges_bool , + record-pages .bool_set:N = \l__acro_record_pages_bool , + next-page .tl_set:N = \l__acro_next_page_tl , + next-pages .tl_set:N = \l__acro_next_pages_tl , list-style .tl_set:N = \l__acro_list_instance_tl , list-type .tl_set:N = \l__acro_list_type_tl , list-header .tl_set:N = \l__acro_list_title_tl , @@ -184,65 +244,14 @@ \cs_new_eq:NN \acro_xspace: \xspace } { \cs_new:Npn \acro_xspace: {} } + \bool_if:NF \l__acro_record_pages_bool + { \cs_set_eq:NN \__acro_record_page_number:n \use_none:n } } % setup command: \NewDocumentCommand \acsetup { m } { \keys_set:nn { acro } { #1 } \ignorespaces } -% -------------------------------------------------------------------------- -% adding an acronym, internal command: -% #1: use/replace plural (boolean) -% #2: id -% #3: short -% #4: short plural -% #5: alt -% #6: long -% #7: long plural -% #8: class -% #9: extra -\cs_new:Npn \acro_new:nnnnnnnnn #1#2#3#4#5#6#7#8#9 - { - \IfBooleanTF { #1 } - { \prop_put:Nnn \l__acro_replace_plural_prop { #2 } { \c_true_bool } } - { \prop_put:Nnn \l__acro_replace_plural_prop { #2 } { \c_false_bool } } - \prop_put:Nnn \l__acro_short_prop { #2 } { #3 } - \prop_put:Nnn \l__acro_pdfstring_prop { #2 } { #3 } - \IfNoValueTF { #4 } - { - \prop_put:Nnn \l__acro_short_plural_prop - { #2 } { \l__acro_default_plural_tl } - \prop_put:Nnx \l__acro_pdfstring_plural_prop - { #2 } { \exp_not:n { #3 } \exp_not:V \l__acro_default_plural_tl } - } - { - \prop_put:Nnn \l__acro_short_plural_prop { #2 } { #4 } - \prop_put:Nnx \l__acro_pdfstring_plural_prop { #2 } { \exp_not:n { #3 #4 } } - } - \IfNoValueTF { #5 } - { \prop_put:Nnn \l__acro_alt_prop { #2 } { #2 } } - { \prop_put:Nnn \l__acro_alt_prop { #2 } { #5 } } - \prop_put:Nnn \l__acro_long_prop { #2 } { #6 } - \IfNoValueTF { #7 } - { \prop_put:Nnn \l__acro_long_plural_prop { #2 } { \l__acro_default_plural_tl } } - { \prop_put:Nnn \l__acro_long_plural_prop { #2 } { #7 } } - \IfNoValueF { #8 } - { \prop_put:Nnn \l__acro_class_prop { #2 } { #8} } - \IfNoValueF { #9 } - { \prop_put:Nnn \l__acro_extra_prop { #2 } { #9 } } - \bool_new:c { g__acro_#2_used_bool } - \bool_new:c { g__acro_#2_label_bool } - \bool_if:NT \l__acro_create_macros_bool - { - \cs_if_exist:cTF { #2 } - { - \bool_if:NT \l__acro_strict_bool - { \cs_set:cpn { #2 } { \ac { #2 } \acro_xspace: } } - } - { \cs_new:cpn { #2 } { \ac { #2 } \acro_xspace: } } - } - } - % typeset the short form: \cs_new:Npn \__acro_write_short:n #1 { @@ -312,7 +321,7 @@ \ifHy@ocgcolorlinks \exp_after:wN \use_i:nn \else - \exp_after:wN \use_ii:nn + \exp_after:wN \exp_after:wN \exp_after:wN \use_ii:nn \fi \fi { \textcolor { \@linkcolor } { #1 } } @@ -368,7 +377,7 @@ } \bool_if:nT { \l__acro_first_use_brackets_bool && !\l__acro_first_reversed_bool } { \tl_head:N \l__acro_first_brackets_tl } - \__acro_write_short:n { #2 } + \__acro_acc_supp:nn { #1 } { \__acro_write_short:n { #2 } } \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_only_short_bool && \l__acro_first_reversed_bool } @@ -392,7 +401,7 @@ \DeclareTemplateCode { acro-first } { footnote } { 3 } { } { \AssignTemplateKeys - \__acro_write_short:n { #2 } + \__acro_acc_supp:nn { #1 } { \__acro_write_short:n { #2 } } \footnote { \__acro_write_long:No \l__acro_long_format_tl { #3 } @@ -460,12 +469,234 @@ { punct = true, brackets = false } % -------------------------------------------------------------------------- -% outputting the page number: +% outputting the page numbers: \bool_new:N \l__acro_page_punct_bool +\bool_new:N \l__acro_page_brackets_bool \bool_new:N \l__acro_page_display_bool \tl_new:N \l__acro_page_punct_tl +\tl_new:N \l__acro_page_brackets_tl \dim_new:N \l__acro_page_space_dim +\cs_new:Npn \acro_create_page_records:n #1 + { + \seq_new:c { g__acro_#1_tmp_seq } + \seq_new:c { g__acro_#1_pages_seq } + } + +\cs_new:Npn \acro@hyper@page #1 + { + \tl_if_in:nnTF { #1 } { \acro@no@hyperpage } + { #1 } + { \acro_hyper_page:n { #1 } } + } + +\cs_new_protected:Npn \acro@no@hyperpage {} + +\cs_new:Npn \__acro_safe_pages_aux:n #1 + { \noexpand \acro@hyper@page {#1}| } + +\cs_new_eq:NN \acro_hyper_page:n \use:n + +\cs_new:Npn \acro_safe_pages:n #1 + { + \iow_now:Nx \@auxout + { + \exp_not:n { \global \@namedef } { acro@#1@pages } + { \seq_map_function:cN { g__acro_#1_pages_seq } \__acro_safe_pages_aux:n } + } + } + +\AtEndDocument + { + \prop_map_inline:Nn \l__acro_short_prop + { + \acro_finalize_page_numbers:n { #1 } + \acro_safe_pages:n { #1 } + } + } + +\tl_new:N \l__acro_tmp_page_tl +\tl_new:N \l__acro_last_page_tl + +%TODO: this should be translated into expl3 syntax +\cs_new:Npn \__acro_if_is_number:nTF #1 + { + \if!\ifnum9<1#1!\expandafter\expandafter\expandafter\@firstoftwo\fi + \else + \expandafter\@secondoftwo + \fi + } + +\cs_new:Npn \__acro_convert_to_arabic:n #1 + { + \__acro_if_is_number:nTF { #1 } + { #1 } + { \exp_args:Nf \int_from_roman:n { \tl_expandable_lowercase:n { #1 } } } + } +\cs_generate_variant:Nn \__acro_convert_to_arabic:n { V } + +\cs_new:Npn \__acro_record_page_number:n #1 + { + \seq_if_empty:cTF { g__acro_#1_pages_seq } + {% no pages recorded, yet + \seq_gput_right:cx { g__acro_#1_pages_seq } { \thepage } + \seq_gput_right:cx { g__acro_#1_tmp_seq } { \thepage } + } + { + \seq_get_right:cN { g__acro_#1_tmp_seq } \l__acro_tmp_page_tl + \seq_get_right:cN { g__acro_#1_pages_seq } \l__acro_last_page_tl + \tl_if_eq:NNTF \l__acro_tmp_page_tl \l__acro_last_page_tl + {% range may have started + \int_compare:nNnF + { \value{page} } + = + { \__acro_convert_to_arabic:V \l__acro_tmp_page_tl } + { + \int_compare:nNnTF + { \value{page} } + = + { \__acro_convert_to_arabic:V \l__acro_tmp_page_tl + 1 } + {% range continues + \seq_gput_right:cx { g__acro_#1_tmp_seq } { \thepage } + } + {% no range (any more) + \seq_gput_right:cx { g__acro_#1_pages_seq } { \acro@no@hyperpage,~ } + \seq_gclear:c { g__acro_#1_tmp_seq } + \seq_gput_right:cx { g__acro_#1_tmp_seq } { \thepage } + \seq_gput_right:cx { g__acro_#1_pages_seq } { \thepage } + } + } + } + {% we're in a range + \int_compare:nNnF + { \value{page} } + = + { \__acro_convert_to_arabic:V \l__acro_tmp_page_tl } + { + \int_compare:nNnTF + { \value{page} } + = + { \__acro_convert_to_arabic:V \l__acro_tmp_page_tl + 1 } + {% range continues + \seq_gput_right:cx { g__acro_#1_tmp_seq } { \thepage } + } + {% no range (any more) + \int_compare:nNnTF + { \__acro_convert_to_arabic:V \l__acro_tmp_page_tl } + = + { \__acro_convert_to_arabic:V \l__acro_last_page_tl +1 } + { + \bool_if:NTF \l__acro_page_ranges_bool + { + \seq_gput_right:cn { g__acro_#1_pages_seq } + { \acro@no@hyperpage,~ } + \seq_gput_right:cx { g__acro_#1_pages_seq } + { \l__acro_tmp_page_tl } + } + { + \seq_gput_right:cn { g__acro_#1_pages_seq } + { \acro@no@hyperpage\l__acro_next_page_tl } + } + } + { + \bool_if:NTF \l__acro_page_ranges_bool + { + \seq_gput_right:cn { g__acro_#1_pages_seq } + { \acro@no@hyperpage-- } + \seq_gput_right:cx { g__acro_#1_pages_seq } + { \l__acro_tmp_page_tl } + } + { + \seq_gput_right:cn { g__acro_#1_pages_seq } + { \acro@no@hyperpage\l__acro_next_pages_tl } + } + } + \seq_gclear:c { g__acro_#1_tmp_seq } + \seq_gput_right:cx { g__acro_#1_tmp_seq } { \thepage } + \seq_gput_right:cn { g__acro_#1_pages_seq } { \acro@no@hyperpage,~ } + \seq_gput_right:cx { g__acro_#1_pages_seq } { \thepage } + } + } + } + } + } + +\cs_new:Npn \acro_finalize_page_numbers:n #1 + { + \seq_get_right:cN { g__acro_#1_tmp_seq } \l__acro_tmp_page_tl + \seq_get_right:cN { g__acro_#1_pages_seq } \l__acro_last_page_tl + \tl_if_eq:NNF \l__acro_tmp_page_tl \l__acro_last_page_tl + { + \int_compare:nNnTF + { \__acro_convert_to_arabic:V \l__acro_tmp_page_tl } + = + { \__acro_convert_to_arabic:V \l__acro_last_page_tl +1 } + { + \bool_if:NTF \l__acro_page_ranges_bool + { + \seq_gput_right:cn { g__acro_#1_pages_seq } + { \acro@no@hyperpage,~ } + \seq_gput_right:cx { g__acro_#1_pages_seq } + { \l__acro_tmp_page_tl } + } + { + \seq_gput_right:cn { g__acro_#1_pages_seq } + { \acro@no@hyperpage\l__acro_next_page_tl } + } + } + { + \bool_if:NTF \l__acro_page_ranges_bool + { + \seq_gput_right:cn { g__acro_#1_pages_seq } + { \acro@no@hyperpage-- } + \seq_gput_right:cx { g__acro_#1_pages_seq } + { \l__acro_tmp_page_tl } + } + { + \seq_gput_right:cn { g__acro_#1_pages_seq } + { \acro@no@hyperpage\l__acro_next_pages_tl } + } + } + } + } + +\cs_new:Npn \acro_print_page_numbers:n #1 + { + \cs_if_exist:cTF { acro@#1@pages } + { + \tl_set_eq:Nc \l__acro_tmpa_tl { acro@#1@pages } + \__acro_print_page_numbers:n { #1 } + } + { ?? } + } + +\cs_new:Npn \__acro_print_page_numbers:n #1 + { + \seq_set_split:NnV \l__acro_tmpb_seq { | } \l__acro_tmpa_tl + \seq_pop_right:NN \l__acro_tmpb_seq \l__acro_ignore_tl + \int_compare:nNnTF { \seq_count:N \l__acro_tmpb_seq } = { 1 } + { \l__acro_page_name_tl } { \l__acro_pages_name_tl } + \acro_no_break: + \skip_horizontal:N \l__acro_page_space_dim + \acro_no_break: + \seq_map_inline:Nn \l__acro_tmpb_seq { ##1 } + } + +\AtBeginDocument + { + \tl_if_eq:NNT \l__acro_active_version_tl \l__acro_version_zero_tl + { + \cs_set:Npn \__acro_print_page_numbers:n #1 + { + \acro_no_break: + \skip_horizontal:N \l__acro_page_space_dim + \acro_no_break: + \tl_use:N \l__acro_page_name_tl + \pageref{ac:#1} + } + } + } + \cs_new:Npn \acro_no_break: { \tex_penalty:D \c_ten_thousand } \DeclareObjectType { acro-page-number } { 1 } @@ -477,8 +708,7 @@ punct-symbol : tokenlist = {,} , brackets : boolean = false , brackets-type : tokenlist = () , - space : length = .3ex , - name : tokenlist , + space : length = .3ex } \DeclareTemplateCode { acro-page-number } { default } { 1 } @@ -488,8 +718,7 @@ punct-symbol = \l__acro_page_punct_tl , brackets = \l__acro_page_brackets_bool , brackets-type = \l__acro_page_brackets_tl , - space = \l__acro_page_space_dim , - name = \l__acro_page_name_tl , + space = \l__acro_page_space_dim } { \AssignTemplateKeys @@ -500,11 +729,7 @@ \tl_use:N \c_space_tl \bool_if:NT \l__acro_page_brackets_bool { \tl_head:N \l__acro_page_brackets_tl } - \tl_use:N \l__acro_page_name_tl - \acro_no_break: - \skip_horizontal:N \l__acro_page_space_dim - \acro_no_break: - \pageref { ac:#1 } + \acro_print_page_numbers:n { #1 } \bool_if:NT \l__acro_page_brackets_bool { \tl_tail:N \l__acro_page_brackets_tl } } @@ -568,7 +793,7 @@ \cs_new:Npn \acro_is_excluded:nnF #1#2#3 { \bool_set_false:N \l__acro_is_excluded_bool - \IfNoValueTF { #2 } + \tl_if_empty:nTF { #2 } { #3 } { \clist_map_inline:nn { #2 } @@ -649,7 +874,14 @@ \AssignTemplateKeys \__acro_activate_hyperref_support: \cs_set:Npn \acro_print_list_short:nn ##1##2 - { \item [ \acro_hyper_target:nn { ##1 } { \__acro_write_short:n { ##2 } } ] } + { + \item + [ + \acro_hyper_target:nn + { ##1 } + { \__acro_acc_supp:nn { ##1 } { \__acro_write_short:n { ##2 } } } + ] + } \cs_set:Npn \acro_print_list_long:n ##1 { \__acro_write_long:Nf \l__acro_list_long_format_tl @@ -693,7 +925,12 @@ \AssignTemplateKeys \__acro_activate_hyperref_support: \cs_set:Npn \acro_print_list_short:nn ##1##2 - { \acro_hyper_target:nn { ##1 } { \__acro_write_short:n { ##2 } } & } + { + \acro_hyper_target:nn + { ##1 } + { \__acro_acc_supp:nn { ##1 } { \__acro_write_short:n { ##2 } } } + & + } \cs_set:Npn \acro_print_list_long:n ##1 { \__acro_write_long:Nf \l__acro_list_long_format_tl @@ -735,7 +972,12 @@ \AssignTemplateKeys \__acro_activate_hyperref_support: \cs_set:Npn \acro_print_list_short:nn ##1##2 - { \acro_hyper_target:nn { ##1 } { \__acro_write_short:n { ##2 } } & } + { + \acro_hyper_target:nn + { ##1 } + { \__acro_acc_supp:nn { ##1 } { \__acro_write_short:n { ##2 } } } + & + } \cs_set:Npn \acro_print_list_long:n ##1 { \__acro_write_long:Nf \l__acro_list_long_format_tl @@ -779,7 +1021,12 @@ \AssignTemplateKeys \__acro_activate_hyperref_support: \cs_set:Npn \acro_print_list_short:nn ##1##2 - { \acro_hyper_target:nn { ##1 } { \__acro_write_short:n { ##2 } } & } + { + \acro_hyper_target:nn + { ##1 } + { \__acro_acc_supp:nn { ##1 } { \__acro_write_short:n { ##2 } } } + & + } \cs_set:Npn \acro_print_list_extra:n ##1 { \bool_if:NT \l__acro_capitalize_list_bool @@ -835,7 +1082,9 @@ \acro_is_used:nTF { #1 } { % this is not the first time - \__acro_write_short:V \l__acro_short_tl + \__acro_acc_supp:nn + { #1 } + { \__acro_write_short:V \l__acro_short_tl } \__acro_cite_if:Nn \l__acro_citation_all_bool { #1 } } { @@ -914,7 +1163,11 @@ \iow_now:Nx \@auxout { \string \acro@used@once { #1 } } \bool_if:NT \l__acro_mark_as_used_bool { - \bool_if:cF { g__acro_#1_label_bool } + \bool_if:nT + { + !\bool_if_p:c { g__acro_#1_label_bool } && + \tl_if_eq_p:NN \l__acro_active_version_tl \l__acro_version_zero_tl + } { \bool_gset_true:c { g__acro_#1_label_bool } \label{ac:#1} @@ -952,7 +1205,9 @@ \acro_is_used:n { #1 } \__acro_is_single:nT { #1 } { \cs_set_eq:NN \acro_hyper_link:nn \use_ii:nn } - \__acro_write_short:V \l__acro_short_tl + \__acro_acc_supp:nn + { #1 } + { \__acro_write_short:V \l__acro_short_tl } \__acro_cite_if:Nn \l__acro_citation_all_bool { #1 } } @@ -964,7 +1219,9 @@ \acro_is_used:n { #1 } \__acro_is_single:nT { #1 } { \cs_set_eq:NN \acro_hyper_link:nn \use_ii:nn } - \__acro_write_short:V \l__acro_alt_tl + \__acro_acc_supp:nn + { #1 } + { \__acro_write_short:V \l__acro_alt_tl } \__acro_cite_if:Nn \l__acro_citation_all_bool { #1 } } @@ -994,20 +1251,6 @@ { \l__acro_long_tl } } -% set custom format: -\cs_new:Npn \acro_format:nn #1#2 - { \prop_put:Nnn \l__acro_format_prop { #1 } { #2 } } - -% add citation: -\cs_new:Npn \acro_citation:nnnn #1#2#3#4 - { - \prop_put:Nnn \l__acro_citation_prop { #1 } { #4 } - \IfNoValueF { #2 } - { \prop_put:Nnn \l__acro_citation_pre_prop { #1 } { #2 } } - \IfNoValueF { #3 } - { \prop_put:Nnn \l__acro_citation_post_prop { #1 } { #3 } } - } - % #1 pre % #2 post % #3 key @@ -1041,6 +1284,34 @@ } } +% accessability support +\tl_new:N \l__acro_acc_supp_tl +\cs_new_eq:NN \__acro_acc_supp:nn \use_ii:nn + +\cs_new:Npn \__acro_acc_supp_aux:nn #1#2 + { + \BeginAccSupp { ActualText = #1 } + #2 + \EndAccSupp { } + } +\cs_generate_variant:Nn \__acro_acc_supp_aux:nn { V } + +\AtBeginDocument + { + \bool_if:NT \l__acro_acc_supp_bool + { + \RequirePackage { accsupp } + \cs_set:Npn \__acro_acc_supp:nn #1#2 + { + \prop_get:NnNF \l__acro_acc_supp_prop { #1 } \l__acro_acc_supp_tl + { \prop_get:NnN \l__acro_short_prop { #1 } \l__acro_acc_supp_tl } + \bool_if:NT \l__acro_use_plural_bool + { \tl_put_right:NV \l__acro_acc_supp_tl \l__acro_short_plural_tl } + \__acro_acc_supp_aux:Vn \l__acro_acc_supp_tl { #2 } + } + } + } + % -------------------------------------------------------------------------- % experimental sorting feature: \AtBeginDocument @@ -1050,9 +1321,14 @@ \RequirePackage { l3sort } \cs_new:Npn \acro_sort_prop:N #1 { - \seq_clear:N \l__acro_tmpa_seq - \prop_map_inline:Nn #1 - { \seq_put_right:Nn \l__acro_tmpa_seq { ##1 } } + \seq_clear:N \l__acro_tmpa_seq + \prop_clear:N \l__acro_tmpa_prop + \prop_clear:N \l__acro_tmpb_prop + \prop_map_inline:Nn \l__acro_sort_prop + { + \seq_put_right:Nn \l__acro_tmpa_seq { ##2 } + \prop_put:Nnn \l__acro_tmpa_prop { ##2 } { ##1 } + } \seq_sort:Nn \l__acro_tmpa_seq { \tl_to_lowercase:n { @@ -1061,80 +1337,47 @@ { \sort_reversed: } } } - \prop_clear:N \l__acro_tmpa_prop \seq_map_inline:Nn \l__acro_tmpa_seq { - \prop_get:NnN #1 { ##1 } \l__acro_tmpa_tl - \prop_put:NnV \l__acro_tmpa_prop { ##1 } \l__acro_tmpa_tl + % get ID: + \prop_get:NnN \l__acro_tmpa_prop { ##1 } \l__acro_tmpa_tl + % get prop entry of ID in #1: + \prop_get:NVNT #1 \l__acro_tmpa_tl \l__acro_tmpb_tl + { + \prop_put:NVV \l__acro_tmpb_prop + \l__acro_tmpa_tl + \l__acro_tmpb_tl + } } - \prop_set_eq:NN #1 \l__acro_tmpa_prop + \prop_set_eq:NN #1 \l__acro_tmpb_prop } } } % -------------------------------------------------------------------------- -% print the whole list: -\cs_new:Npn \acro_print_acronyms:nn #1#2 - { - \iow_now:Nx \@auxout { \string \acro@print@list } - \bool_if:NT \l__acro_sort_bool - { \acro_sort_prop:N \l__acro_short_prop } - \UseInstance { acro-title } { \l__acro_list_title_tl } - { \l__acro_list_name_tl } - \cs_if_exist:NTF \acro@printed@list - { - \UseInstance { acro-list } { \l__acro_list_instance_tl } - { \l__acro_list_type_tl } { #1 } { #2 } - } - { \@latex@warning@no@line {Rerun~to~get~acronym~list~right} } - } - +% regarding list printing: \cs_new:Npn \acro@print@list { \cs_if_exist:NF \acro@printed@list { \cs_new:Npn \acro@printed@list {} } } -% -------------------------------------------------------------------------- -% USER COMMANDS -% adding an acronym, user command: -% #1: use/replace plural (boolean) -% #2: id -% #3: short -% #4: short plural -% #5: alt -% #6: long -% #7: long plural -% #8: class -% #9: extra -\NewDocumentCommand \DeclareAcronym - { sm>{\SplitArgument{1}{,}}mo>{\SplitArgument{1}{,}}+mgo } - { \acro_new:nnnnnnnnn { #1 } { #2 } #3 { #4 } #5 { #7 } { #6 } } -\@onlypreamble \DeclareAcronym - -\NewDocumentCommand \DeclareAcronymFormat { mm } - { \acro_format:nn { #1 } { #2 } } -\@onlypreamble \DeclareAcronymFormat - -\NewDocumentCommand \DeclareAcronymCitation { moom } - { \acro_citation:nnnn { #1 } { #2 } { #3 } { #4 } } -\@onlypreamble \DeclareAcronymCitation - -\NewDocumentCommand \DeclareAcronymPDFString - { m >{ \SplitArgument { 1 } { , } } m } - { \acro_pdfstring:nnn { #1 } #2 } -\@onlypreamble \DeclareAcronymPDFstring - -\cs_new:Npn \acro_use_if:n #1 + +\cs_new:Npn \acro_use_if:nn #1#2 { \IfBooleanTF { #1 } { \bool_set_false:N \l__acro_mark_as_used_bool } - { \bool_set_true:N \l__acro_mark_as_used_bool } + { + \__acro_record_page_number:n { #2 } + \bool_set_true:N \l__acro_mark_as_used_bool + } } +% -------------------------------------------------------------------------- +% the user commands: % automatic: \NewDocumentCommand \ac { sm } { \group_begin: \acro_defined:n { #2 } - \acro_use_if:n { #1 } + \acro_use_if:nn { #1 } { #2 } \acro_use:n { #2 } \group_end: } @@ -1143,7 +1386,7 @@ { \group_begin: \acro_defined:n { #2 } - \acro_use_if:n { #1 } + \acro_use_if:nn { #1 } { #2 } \bool_set_true:N \l__acro_first_upper_bool \acro_use:n { #2 } \group_end: @@ -1153,7 +1396,7 @@ { \group_begin: \acro_defined:n { #2 } - \acro_use_if:n { #1 } + \acro_use_if:nn { #1 } { #2 } \bool_set_true:N \l__acro_use_plural_bool \acro_use:n { #2 } \group_end: @@ -1163,7 +1406,7 @@ { \group_begin: \acro_defined:n { #2 } - \acro_use_if:n { #1 } + \acro_use_if:nn { #1 } { #2 } \bool_set_true:N \l__acro_use_plural_bool \bool_set_true:N \l__acro_first_upper_bool \acro_use:n { #2 } @@ -1175,7 +1418,7 @@ { \group_begin: \acro_defined:n { #2 } - \acro_use_if:n { #1 } + \acro_use_if:nn { #1 } { #2 } \acro_short:n { #2 } \group_end: } @@ -1184,7 +1427,7 @@ { \group_begin: \acro_defined:n { #2 } - \acro_use_if:n { #1 } + \acro_use_if:nn { #1 } { #2 } \bool_set_true:N \l__acro_use_plural_bool \acro_short:n { #2 } \group_end: @@ -1195,7 +1438,7 @@ { \group_begin: \acro_defined:n { #2 } - \acro_use_if:n { #1 } + \acro_use_if:nn { #1 } { #2 } \acro_alt:n { #2 } \group_end: } @@ -1204,7 +1447,7 @@ { \group_begin: \acro_defined:n { #2 } - \acro_use_if:n { #1 } + \acro_use_if:nn { #1 } { #2 } \bool_set_true:N \l__acro_use_plural_bool \acro_alt:n { #2 } \group_end: @@ -1215,7 +1458,7 @@ { \group_begin: \acro_defined:n { #2 } - \acro_use_if:n { #1 } + \acro_use_if:nn { #1 } { #2 } \acro_long:n { #2 } \group_end: } @@ -1224,7 +1467,7 @@ { \group_begin: \acro_defined:n { #2 } - \acro_use_if:n { #1 } + \acro_use_if:nn { #1 } { #2 } \bool_set_true:N \l__acro_first_upper_bool \acro_long:n { #2 } \group_end: @@ -1234,7 +1477,7 @@ { \group_begin: \acro_defined:n { #2 } - \acro_use_if:n { #1 } + \acro_use_if:nn { #1 } { #2 } \bool_set_true:N \l__acro_use_plural_bool \acro_long:n { #2 } \group_end: @@ -1244,7 +1487,7 @@ { \group_begin: \acro_defined:n { #2 } - \acro_use_if:n { #1 } + \acro_use_if:nn { #1 } { #2 } \bool_set_true:N \l__acro_use_plural_bool \bool_set_true:N \l__acro_first_upper_bool \acro_long:n { #2 } @@ -1256,7 +1499,7 @@ { \group_begin: \acro_defined:n { #2 } - \acro_use_if:n { #1 } + \acro_use_if:nn { #1 } { #2 } \acro_first:n { #2 } \group_end: } @@ -1265,7 +1508,7 @@ { \group_begin: \acro_defined:n { #2 } - \acro_use_if:n { #1 } + \acro_use_if:nn { #1 } { #2 } \bool_set_true:N \l__acro_first_upper_bool \acro_first:n { #2 } \group_end: @@ -1275,7 +1518,7 @@ { \group_begin: \acro_defined:n { #2 } - \acro_use_if:n { #1 } + \acro_use_if:nn { #1 } { #2 } \bool_set_true:N \l__acro_use_plural_bool \acro_first:n { #2 } \group_end: @@ -1285,7 +1528,7 @@ { \group_begin: \acro_defined:n { #2 } - \acro_use_if:n { #1 } + \acro_use_if:nn { #1 } { #2 } \bool_set_true:N \l__acro_use_plural_bool \bool_set_true:N \l__acro_first_upper_bool \acro_first:n { #2 } @@ -1321,9 +1564,7 @@ \NewDocumentCommand \acuse { > { \SplitList { , } } m } { \ProcessList { #1 } { \acro_mark_as_used:n } } -% typeset the list: -\NewDocumentCommand \printacronyms { G{}o } - { \acro_print_acronyms:nn { #1 } { #2 } } + \ProcessKeysOptions { acro } @@ -1352,20 +1593,6 @@ { \prop_get:Nn \l__acro_pdfstring_plural_prop { #1 } } } -\cs_new:Npn \acro_pdfstring:nnn #1#2#3 - { - \prop_put:Nnx \l__acro_pdfstring_prop { #1 } { #2 } - \IfNoValueTF { #3 } - { - \prop_put:Nnx \l__acro_pdfstring_plural_prop - { #1 } { #2 \l__acro_default_plural_tl } - } - { - \prop_put:Nnx \l__acro_pdfstring_plural_prop - { #1 } { #2 #3 } - } - } - \AtBeginDocument { \@ifpackageloaded { hyperref } @@ -1390,12 +1617,15 @@ \cs_set_eq:NN \Acfp \acpdfstringplural \cs_set_eq:NN \acap \acpdfstringplural } + \cs_set_eq:NN \acro_hyper_page:n \hyperpage } {} } % -------------------------------------------------------------------------- % 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 } @@ -1406,6 +1636,31 @@ \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. } +\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. } +\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. } +\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. } +\tl_set:Nn \l__acro_next_pages_tl { \,\GetTranslation {acronym-next-pages }\@ } + +% -------------------------------------------------------------------------- +% load default version +\bool_if:NF \l__acro_version_selected_bool + { \__acro_select_version:n { 1 } } \tex_endinput:D % -------------------------------------------------------------------------- @@ -1443,30 +1698,24 @@ short entry) resolved - option `xspace' added 2013/01/02 v0.6a - \acuseall - +2013/01/16 v1.0 - new syntax of \DeclareAcronym + - new option `version' + - new `accsupp' acronym property + - new `sort' acronym property + - new syntax of \printacronyms + - new default: `sort=true' + - new options `page-ranges', `next-page', `next-pages', + `pages-name', `record-pages' + - no automatic label placement for page number referencing + any more + % -------------------------------------------------------------------------- % TODO: - Option `totoc'!? -- accsupp Support? - revise list styles to allow _full_ customization by creating own instances! this probably needs a handfull of macros that give access to the entries without worrying about internals - record and list _all_ pagenumbers where an acronym occurs - compilation halts instead of throwing an error if an undefined acronym is used -- possibility to add sort key - add \ACF, \ACFP, \ACL and \ACLP that will print all words of the long form - capitalized - -= long term = -- new syntax: - \DeclareAcronym{<ID>} - { - short = ?? , - long = ?? , - sort = ?? , - short-plural = ?? , - long-plural* = ?? ,% * = replacement instead of ending - PDF-text = ?? , - cite = ?? , - ... - }
\ No newline at end of file + capitalized
\ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/acro/acro0.def b/Master/texmf-dist/tex/latex/acro/acro0.def new file mode 100644 index 00000000000..673a6d2a164 --- /dev/null +++ b/Master/texmf-dist/tex/latex/acro/acro0.def @@ -0,0 +1,168 @@ +% -------------------------------------------------------------------------- +% the ACRO package +% +% Typeset Acronyms +% +% -------------------------------------------------------------------------- +% Clemens Niederberger +% Web: https://bitbucket.org/cgnieder/acro/ +% E-Mail: contact@mychemistry.eu +% -------------------------------------------------------------------------- +% Copyright 2011-2013 Clemens Niederberger +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3 +% of this license or (at your option) any later version. +% The latest version of this license is in +% http://www.latex-project.org/lppl.txt +% and version 1.3 or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is Clemens Niederberger. +% -------------------------------------------------------------------------- +% The acro package consists of the files +% - acro.sty, acro0.def, acro1.def, acro_en.tex, acro_en.pdf, README +% -------------------------------------------------------------------------- +% If you have any ideas, questions, suggestions or bugs to report, please +% feel free to contact me. +% -------------------------------------------------------------------------- +\ProvidesFile{acro0.def} + +% -------------------------------------------------------------------------- +% adding an acronym, internal command: +% #1: use/replace plural (boolean) +% #2: id +% #3: short +% #4: short plural +% #5: alt +% #6: long +% #7: long plural +% #8: class +% #9: extra +\cs_new:Npn \acro_new:nnnnnnnnn #1#2#3#4#5#6#7#8#9 + { + \IfBooleanTF { #1 } + { \prop_put:Nnn \l__acro_replace_plural_prop { #2 } { \c_true_bool } } + { \prop_put:Nnn \l__acro_replace_plural_prop { #2 } { \c_false_bool } } + \prop_put:Nnn \l__acro_short_prop { #2 } { #3 } + \prop_put:Nnn \l__acro_sort_prop { #2 } { #2 } + \prop_put:Nnn \l__acro_pdfstring_prop { #2 } { #3 } + \acro_create_page_records:n { #2 } + \IfNoValueTF { #4 } + { + \prop_put:Nnn \l__acro_short_plural_prop + { #2 } { \l__acro_default_plural_tl } + \prop_put:Nnx \l__acro_pdfstring_plural_prop + { #2 } { \exp_not:n { #3 } \exp_not:V \l__acro_default_plural_tl } + } + { + \prop_put:Nnn \l__acro_short_plural_prop { #2 } { #4 } + \prop_put:Nnx \l__acro_pdfstring_plural_prop { #2 } { \exp_not:n { #3 #4 } } + } + \IfNoValueTF { #5 } + { \prop_put:Nnn \l__acro_alt_prop { #2 } { #2 } } + { \prop_put:Nnn \l__acro_alt_prop { #2 } { #5 } } + \prop_put:Nnn \l__acro_long_prop { #2 } { #6 } + \IfNoValueTF { #7 } + { \prop_put:Nnn \l__acro_long_plural_prop { #2 } { \l__acro_default_plural_tl } } + { \prop_put:Nnn \l__acro_long_plural_prop { #2 } { #7 } } + \IfNoValueF { #8 } + { \prop_put:Nnn \l__acro_class_prop { #2 } { #8 } } + \IfNoValueF { #9 } + { \prop_put:Nnn \l__acro_extra_prop { #2 } { #9 } } + \bool_new:c { g__acro_#2_used_bool } + \bool_new:c { g__acro_#2_label_bool } + \bool_if:NT \l__acro_create_macros_bool + { + \cs_if_exist:cTF { #2 } + { + \bool_if:NT \l__acro_strict_bool + { \cs_set:cpn { #2 } { \ac { #2 } \acro_xspace: } } + } + { \cs_new:cpn { #2 } { \ac { #2 } \acro_xspace: } } + } + } + +% set custom format: +\cs_new:Npn \acro_format:nn #1#2 + { \prop_put:Nnn \l__acro_format_prop { #1 } { #2 } } + +% add citation: +\cs_new:Npn \acro_citation:nnnn #1#2#3#4 + { + \prop_put:Nnn \l__acro_citation_prop { #1 } { #4 } + \IfNoValueF { #2 } + { \prop_put:Nnn \l__acro_citation_pre_prop { #1 } { #2 } } + \IfNoValueF { #3 } + { \prop_put:Nnn \l__acro_citation_post_prop { #1 } { #3 } } + } + +% add pdfstring: +\cs_new:Npn \acro_pdfstring:nnn #1#2#3 + { + \prop_put:Nnx \l__acro_pdfstring_prop { #1 } { #2 } + \IfNoValueTF { #3 } + { + \prop_put:Nnx \l__acro_pdfstring_plural_prop + { #1 } { #2 \l__acro_default_plural_tl } + } + { + \prop_put:Nnx \l__acro_pdfstring_plural_prop + { #1 } { #2 #3 } + } + } + +% -------------------------------------------------------------------------- +% USER COMMANDS +% adding an acronym, user command: +% #1: use/replace plural (boolean) +% #2: id +% #3: short +% #4: short plural +% #5: alt +% #6: long +% #7: long plural +% #8: class +% #9: extra +\NewDocumentCommand \DeclareAcronym + { sm>{\SplitArgument{1}{,}}mo>{\SplitArgument{1}{,}}+mgo } + { \acro_new:nnnnnnnnn { #1 } { #2 } #3 { #4 } #5 { #7 } { #6 } } +\@onlypreamble \DeclareAcronym + +\NewDocumentCommand \DeclareAcronymFormat { mm } + { \acro_format:nn { #1 } { #2 } } +\@onlypreamble \DeclareAcronymFormat + +\NewDocumentCommand \DeclareAcronymCitation { moom } + { \acro_citation:nnnn { #1 } { #2 } { #3 } { #4 } } +\@onlypreamble \DeclareAcronymCitation + +\NewDocumentCommand \DeclareAcronymPDFString + { m >{ \SplitArgument { 1 } { , } } m } + { \acro_pdfstring:nnn { #1 } #2 } +\@onlypreamble \DeclareAcronymPDFstring + +% -------------------------------------------------------------------------- +% print the list: +\cs_new:Npn \acro_print_acronyms:nn #1#2 + { + \iow_now:Nx \@auxout { \string \acro@print@list } + \bool_if:NT \l__acro_sort_bool + { \acro_sort_prop:N \l__acro_short_prop } + \UseInstance { acro-title } { \l__acro_list_title_tl } + { \l__acro_list_name_tl } + \cs_if_exist:NTF \acro@printed@list + { + \UseInstance { acro-list } { \l__acro_list_instance_tl } + { \l__acro_list_type_tl } { #1 } { #2 } + } + { \@latex@warning@no@line {Rerun~to~get~acronym~list~right} } + } + +% user command: +\NewDocumentCommand \printacronyms { G{}O{} } + { \acro_print_acronyms:nn { #1 } { #2 } } + +\tex_endinput:D
\ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/acro/acro1.def b/Master/texmf-dist/tex/latex/acro/acro1.def new file mode 100644 index 00000000000..21d4e83fa92 --- /dev/null +++ b/Master/texmf-dist/tex/latex/acro/acro1.def @@ -0,0 +1,337 @@ +% -------------------------------------------------------------------------- +% the ACRO package +% +% Typeset Acronyms +% +% -------------------------------------------------------------------------- +% Clemens Niederberger +% Web: https://bitbucket.org/cgnieder/acro/ +% E-Mail: contact@mychemistry.eu +% -------------------------------------------------------------------------- +% Copyright 2011-2013 Clemens Niederberger +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3 +% of this license or (at your option) any later version. +% The latest version of this license is in +% http://www.latex-project.org/lppl.txt +% and version 1.3 or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is Clemens Niederberger. +% -------------------------------------------------------------------------- +% The acro package consists of the files +% - acro.sty, acro0.def, acro1.def, acro_en.tex, acro_en.pdf, README +% -------------------------------------------------------------------------- +% If you have any ideas, questions, suggestions or bugs to report, please +% feel free to contact me. +% -------------------------------------------------------------------------- +\ProvidesFile{acro1.def} + +% -------------------------------------------------------------------------- +% additional variables: +\tl_new:N \l__acro_current_key_tl + +% -------------------------------------------------------------------------- +% key and order checking +\msg_new:nnnn { acro } { no-id } + { Something~has~gone~wrong,~you've~probably~forgotten~to~set~the~acronym~ID. } + { Something~has~gone~wrong,~you've~probably~forgotten~to~set~the~acronym~ID. } + +\msg_new:nnnn { acro } { before-short } + { The~key~`#2'~needs~to~be~set~after~`short'. } + { + You've~set~The~key~`#2'~before~the~`short'~key~for~acronym~`#1'~but~ + needs~to~be~set~after~it. + } + +\msg_new:nnnn { acro } { missing } + { The~`#2'~key~for~acronym~`#1'~is~missing. } + { The~`#2'~key~for~acronym~`#1'~is~missing. } + +% TODO: checking: +% - `sort' zuerst, darf nicht fehlen +% - `long' darf nicht fehlen +\cs_new:Npn \__acro_key_check:nn #1#2 + { + \tl_if_blank:VT \l__acro_current_key_tl + { \msg_error:nn { acro } { no-id } } + \bool_if:cF { l__acro_short_#1_set_bool } + { \msg_error:nnxx { acro } { before-short } { #1 } { #2 } } + } + +\cs_new:Npn \__acro_first_key_check:n #1 + { + \cs_if_exist:cTF { l__acro_short_#1_set_bool } + { + \bool_if:cTF { l__acro_short_#1_set_bool } + {} + { \bool_set_true:c { l__acro_short_#1_set_bool } } + } + {% error: key already used + } + } + +% -------------------------------------------------------------------------- +% the internal selection functions: +% short: +\cs_new:Npn \__acro_declare_short:nn #1#2 + { + \bool_new:c { l__acro_short_#1_set_bool } + \__acro_first_key_check:n { #1 } + \prop_put:Nnn \l__acro_short_prop { #1 } { #2 } + \prop_put:Nnn \l__acro_sort_prop { #1 } { #1 } + \prop_put:Nnn \l__acro_alt_prop { #1 } { #2 } + \prop_put:Nnx \l__acro_pdfstring_prop { #1 } { \exp_not:n { #2 } } + \prop_put:Nnn \l__acro_short_plural_prop + { #1 } { \l__acro_default_plural_tl } + \prop_put:Nnx \l__acro_pdfstring_plural_prop + { #1 } { \exp_not:n { #2 } \exp_not:V \l__acro_default_plural_tl } + } +\cs_generate_variant:Nn \__acro_declare_short:nn { V } + +\cs_new:Npn \__acro_declare_short_plural:nn #1#2 + { + \__acro_key_check:nn { #1 } { short-plural } + \prop_put:Nnn \l__acro_short_plural_prop { #1 } { #2 } + } +\cs_generate_variant:Nn \__acro_declare_short_plural:nn { V } + +% long: +\cs_new:Npn \__acro_declare_long:nn #1#2 + { + \__acro_key_check:nn { #1 } { long } + \bool_new:c { l__acro_long_#1_set_bool } + \prop_put:Nnn \l__acro_replace_plural_prop { #1 } { \c_false_bool } + \prop_put:Nnn \l__acro_long_prop { #1 } { #2 } + \prop_put:Nnn \l__acro_long_plural_prop + { #1 } { \l__acro_default_plural_tl } + \bool_set_true:c { l__acro_long_#1_set_bool } + } +\cs_generate_variant:Nn \__acro_declare_long:nn { V } + +% long plural: +\cs_new:Npn \__acro_declare_long_plural:nn #1#2 + { + \__acro_key_check:nn { #1 } { long-plural } + \prop_put:Nnn \l__acro_replace_plural_prop { #1 } { \c_false_bool } + \prop_put:Nnn \l__acro_long_plural_prop { #1 } { #2 } + } +\cs_generate_variant:Nn \__acro_declare_long_plural:nn { V } + +% long plural form: +\cs_new:Npn \__acro_declare_long_plural_form:nn #1#2 + { + \__acro_key_check:nn { #1 } { long-plural-form } + \prop_put:Nnn \l__acro_replace_plural_prop { #1 } { \c_true_bool } + \prop_put:Nnn \l__acro_long_plural_prop { #1 } { #2 } + } +\cs_generate_variant:Nn \__acro_declare_long_plural_form:nn { V } + +% sort: +\cs_new:Npn \__acro_declare_sort:nn #1#2 + { + \__acro_key_check:nn { #1 } { sort } + \prop_put:Nnn \l__acro_sort_prop { #1 } { #2 } + } +\cs_generate_variant:Nn \__acro_declare_sort:nn { V } + +% alternative: +\cs_new:Npn \__acro_declare_alt:nn #1#2 + { + \__acro_key_check:nn { #1 } { alt } + \prop_put:Nnn \l__acro_alt_prop { #1 } { #2 } + } +\cs_generate_variant:Nn \__acro_declare_alt:nn { V } + +% format: +\cs_new:Npn \__acro_declare_format:nn #1#2 + { + \__acro_key_check:nn { #1 } { format } + \prop_put:Nnn \l__acro_format_prop { #1 } { #2 } + } +\cs_generate_variant:Nn \__acro_declare_format:nn { V } + +% pdfstring: +\cs_new:Npn \__acro_declare_pdfstring:nw #1#2/#3/#4 \acro_stop: + { + \__acro_key_check:nn { #1 } { pdfstring } + \prop_put:Nnx \l__acro_pdfstring_prop { #1 } { #2 } + \tl_if_empty:nTF { #3 } + { + \prop_put:Nnx \l__acro_pdfstring_plural_prop + { #1 } { \exp_not:n { #2 } \exp_not:V \l__acro_default_plural_tl } + } + { + \prop_put:Nnx \l__acro_pdfstring_plural_prop + { #1 } { \exp_not:n { #2#3 } } + } + } + +% class: +\cs_new:Npn \__acro_declare_class:nn #1#2 + { + \__acro_key_check:nn { #1 } { class } + \prop_put:Nnn \l__acro_class_prop { #1 } { #2 } + } +\cs_generate_variant:Nn \__acro_declare_class:nn { V } + +% extra information: +\cs_new:Npn \__acro_declare_extra:nn #1#2 + { + \__acro_key_check:nn { #1 } { extra } + \prop_put:Nnn \l__acro_extra_prop { #1 } { #2 } + } +\cs_generate_variant:Nn \__acro_declare_extra:nn { V } + +% acc supp: +\cs_new:Npn \__acro_declare_acc_supp:nn #1#2 + { + \__acro_key_check:nn { #1 } { accsupp } + \prop_put:Nnn \l__acro_acc_supp_prop { #1 } { #2 } + } +\cs_generate_variant:Nn \__acro_declare_acc_supp:nn { V } + +% citation: +\cs_new:Npn \__acro_declare_citation:nw #1#2[#3]#4[#5]#6#7 \acro_stop: + { + % no options: #1: ID, #2: key, #3 is blank + % 1 option: #1: ID, #4: key, #3: option, #5 is blank + % 2 options: #1: ID: #6: key, #3: first option, #5: second option + \tl_if_blank:nF { #2#4#6 } + { + \tl_if_empty:nTF { #3 } + { \__acro_declare_citation_aux:nnnn { #1 } { } { } { #2 } } + { + \tl_if_empty:nTF { #5 } + { \__acro_declare_citation_aux:nnnn { #1 } { #3 } { } { #4 } } + { \__acro_declare_citation_aux:nnnn { #1 } { #3 } { #5 } { #6 } } + } + } + } + +\cs_new:Npn \__acro_declare_citation_aux:nnnn #1#2#3#4 + { + \prop_put:Nnn \l__acro_citation_prop { #1 } { #4 } + \tl_if_empty:nF { #2 } + { \prop_put:Nnn \l__acro_citation_pre_prop { #1 } { #2 } } + \tl_if_empty:nF { #3 } + { \prop_put:Nnn \l__acro_citation_post_prop { #1 } { #3 } } + } + +% -------------------------------------------------------------------------- +% the keys of \DeclareAcronym +\keys_define:nn { acro / declare-acronym } + { + short .code:n = + \__acro_declare_short:Vn \l__acro_current_key_tl { #1 } , + short-plural .code:n = + \__acro_declare_short_plural:Vn \l__acro_current_key_tl { #1 } , + alt .code:n = + \__acro_declare_alt:Vn \l__acro_current_key_tl { #1 } , + long .code:n = + \__acro_declare_long:Vn \l__acro_current_key_tl { #1 } , + long-plural .code:n = + \__acro_declare_long_plural:Vn \l__acro_current_key_tl { #1 } , + long-plural-form .code:n = + \__acro_declare_long_plural_form:Vn \l__acro_current_key_tl { #1 } , + sort .code:n = + \__acro_declare_sort:Vn \l__acro_current_key_tl { #1 } , + extra .code:n = + \__acro_declare_extra:Vn \l__acro_current_key_tl { #1 } , + format .code:n = + \__acro_declare_format:Vn \l__acro_current_key_tl { #1 } , + class .code:n = + \__acro_declare_class:Vn \l__acro_current_key_tl { #1 } , + cite .code:n = + \exp_args:NV + \__acro_declare_citation:nw \l__acro_current_key_tl #1 [][] \scan_stop: \acro_stop: , + pdfstring .code:n = + \exp_args:NV + \__acro_declare_pdfstring:nw \l__acro_current_key_tl #1 // \acro_stop: , + accsupp .code:n = + \__acro_declare_acc_supp:Vn \l__acro_current_key_tl { #1 } + } + +\cs_new:Npn \acro_define_acronym_macro:n #1 + { + \bool_if:NT \l__acro_create_macros_bool + { + \cs_if_exist:cTF { #1 } + { + \bool_if:NT \l__acro_strict_bool + { \cs_set:cpn { #1 } { \ac { #1 } \acro_xspace: } } + } + { \cs_new:cpn { #1 } { \ac { #1 } \acro_xspace: } } + } + } + +% -------------------------------------------------------------------------- +% internal acronym declaring function: +\cs_new:Npn \acro_declare_acronym:nn #1#2 + { + \tl_set:Nn \l__acro_current_key_tl { #1 } + \keys_set:nn { acro / declare-acronym } { #2 } + \bool_new:c { g__acro_#1_used_bool } + \bool_new:c { g__acro_#1_label_bool } + \acro_create_page_records:n { #1 } + \acro_define_acronym_macro:n { #1 } + \tl_clear:N \l__acro_current_key_tl + \bool_if:cF { l__acro_short_#1_set_bool } + { \msg_error:nnxx { acro } { missing } { #1 } { short } } + \bool_if:cF { l__acro_long_#1_set_bool } + { \msg_error:nnxx { acro } { missing } { #1 } { long } } + } + +% -------------------------------------------------------------------------- +% the user command: +\NewDocumentCommand \DeclareAcronym { mm } + { \acro_declare_acronym:nn { #1 } { #2 } } +\@onlypreamble\DeclareAcronym + +% -------------------------------------------------------------------------- +% print the list: +% #1: list of classes +% #2: list of excluded classes +\tl_new:N \l__acro_included_classes_tl +\tl_new:N \l__acro_excluded_classes_tl + +\cs_new:Npn \acro_use_list_instance:nn #1#2 + { + \UseInstance { acro-list } { \l__acro_list_instance_tl } + { \l__acro_list_type_tl } { #1 } { #2 } + } +\cs_generate_variant:Nn \acro_use_list_instance:nn { VV } + +\keys_define:nn { acro / print-acronyms } + { + include-classes .tl_set:N = \l__acro_included_classes_tl , + exclude-classes .tl_set:N = \l__acro_excluded_classes_tl , + name .tl_set:N = \l__acro_list_name_tl , + header .tl_set:N = \l__acro_list_title_tl + } + +\cs_new:Npn \acro_print_acronyms:n #1 + { + \tl_clear:N \l__acro_included_classes_tl + \tl_clear:N \l__acro_excluded_classes_tl + \keys_set:nn { acro / print-acronyms } { #1 } + \iow_now:Nx \@auxout { \string \acro@print@list } + \bool_if:NT \l__acro_sort_bool + { \acro_sort_prop:N \l__acro_short_prop } + \UseInstance { acro-title } { \l__acro_list_title_tl } + { \l__acro_list_name_tl } + \cs_if_exist:NTF \acro@printed@list + { + \acro_use_list_instance:VV + \l__acro_included_classes_tl + \l__acro_excluded_classes_tl + } + { \@latex@warning@no@line {Rerun~to~get~acronym~list~right} } + } + +\NewDocumentCommand \printacronyms { O{} } + { \acro_print_acronyms:n { #1 } } +\tex_endinput:D
\ No newline at end of file |