diff options
author | Karl Berry <karl@freefriends.org> | 2015-09-06 23:19:31 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2015-09-06 23:19:31 +0000 |
commit | 1b2ecd77871ef20cc07ab3df20ccbce3660456d8 (patch) | |
tree | da997d2518099d6084b6aea406cfa6d64eff2c8c /Master/texmf-dist/tex/latex/acro/acro.sty | |
parent | 3cb4e75696df6c7abebf17fbc606ca86dcdfb520 (diff) |
acro (6sep15)
git-svn-id: svn://tug.org/texlive/trunk@38306 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 | 438 |
1 files changed, 303 insertions, 135 deletions
diff --git a/Master/texmf-dist/tex/latex/acro/acro.sty b/Master/texmf-dist/tex/latex/acro/acro.sty index 67a429a5a4b..d9b996a194a 100644 --- a/Master/texmf-dist/tex/latex/acro/acro.sty +++ b/Master/texmf-dist/tex/latex/acro/acro.sty @@ -23,16 +23,16 @@ % 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 +% - acro.sty, acro_en.tex, acro_en.pdf, README % -------------------------------------------------------------------------- % If you have any ideas, questions, suggestions or bugs to report, please % feel free to contact me. % -------------------------------------------------------------------------- -\RequirePackage{expl3,l3sort,xparse,l3keys2e,xtemplate} +\RequirePackage{expl3,l3sort,xparse,l3keys2e,xtemplate,etoolbox} \ProvidesExplPackage {acro} - {2015/08/29} - {2.0b} + {2015/09/05} + {2.1} {Typeset Acronyms} % -------------------------------------------------------------------------- @@ -88,8 +88,6 @@ } % message macros: -\bool_new:N \l__acro_silence_bool - \cs_new:Npn \__acro_remove_backslash:N #1 { \exp_after:wN \use_none:n \token_to_str:N #1 } @@ -165,6 +163,7 @@ % -------------------------------------------------------------------------- % boolean variables: +\bool_new:N \l__acro_silence_bool \bool_new:N \l__acro_mark_as_used_bool \bool_new:N \g__acro_mark_first_as_used_bool \bool_new:N \l__acro_use_single_bool @@ -189,6 +188,8 @@ \bool_set_true:N \l__acro_citation_first_bool \bool_new:N \l__acro_group_citation_bool \bool_new:N \l__acro_acc_supp_bool +\bool_new:N \l__acro_tooltip_bool +\bool_new:N \l__acro_inside_tooltip_bool \bool_new:N \l__acro_following_page_bool \bool_new:N \l__acro_following_pages_bool \bool_new:N \l__acro_record_pages_bool @@ -286,6 +287,9 @@ { \dim_set:Nn \l__acro_table_width_dim { .7\columnwidth } } \dim_new:N \l__acro_page_space_dim +\dim_new:N \l__acro_short_width_dim +\dim_set:Nn \l__acro_short_width_dim {3em} + % -------------------------------------------------------------------------- % small commands for use at various places \cs_new:Npn \acro_no_break: { \tex_penalty:D \c_ten_thousand } @@ -313,6 +317,9 @@ messages .value_required:n = true , accsupp .bool_set:N = \l__acro_acc_supp_bool , accsupp-options .tl_set:N = \l__acro_acc_supp_options_tl , + tooltip .bool_set:N = \l__acro_tooltip_bool , + tooltip-cmd .code:n = \cs_set:Npn \__acro_tooltip_cmd:nn {#1} , + tooltip-cmd .value_required:n = true , 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 , @@ -336,6 +343,8 @@ foreign-format .value_required:n = true , list-short-format .tl_set:N = \l__acro_list_short_format_tl , list-short-format .value_required:n = true , + list-short-width .dim_set:N = \l__acro_short_width_dim , + list-short-width .value_required:n = true , list-long-format .tl_set:N = \l__acro_list_long_format_tl , list-long-format .value_required:n = true , list-foreign-format .tl_set:N = \l__acro_foreign_list_format_tl , @@ -376,6 +385,10 @@ next-page .value_required:n = true , next-pages .tl_set:N = \l__acro_next_pages_tl , next-pages .value_required:n = true , + % TODO: get rid of list-type (set it implicitly?) + % proposed syntax: list-style = table : longtable + % with list-style = longtable + % being an alias if it is unique list-style .tl_set:N = \l__acro_list_instance_tl , list-style .value_required:n = true , list-type .tl_set:N = \l__acro_list_type_tl , @@ -457,7 +470,7 @@ \cs_new_eq:NN \acro_hyper_target:nn \use_ii:nn \cs_new_eq:NN \acro_hyper_link:nn \use_ii:nn -\cs_new_protected:Npn \__acro_activate_hyperref_support: +\cs_new_protected:Npn \acro_activate_hyperref_support: { \bool_if:nT { \l__acro_hyperref_loaded_bool && \l__acro_use_hyperref_bool } { @@ -517,10 +530,10 @@ % #1: id % #2: short % #3: long -\DeclareObjectType { acro-first } { 3 } +\DeclareObjectType {acro-first} {3} % template for inline appearance: -\DeclareTemplateInterface { acro-first } { inline } { 3 } +\DeclareTemplateInterface {acro-first} {inline} {3} { brackets : boolean = true , brackets-type : tokenlist = () , @@ -529,7 +542,7 @@ between : tokenlist , foreign-sep : tokenlist = { , ~ } } -\DeclareTemplateCode { acro-first } { inline } { 3 } +\DeclareTemplateCode {acro-first} {inline} {3} { brackets = \l__acro_first_use_brackets_bool , brackets-type = \l__acro_first_brackets_tl , @@ -580,9 +593,7 @@ \prop_map_inline:Nn \l__acro_trailing_tokens_prop { \acro_deactivate_trailing_action:n {##1} } } - \acro_get_ending_form:nn {#1} {short} - \acro_acc_supp:nn {#1} { \acro_write_short:nn {#1} {#2} } - \acro_endings:nn {#1} {short} + \acro_write_compact:nn {#1} {short} \group_end: \bool_if:nT { \l__acro_group_citation_bool && !\l__acro_first_reversed_bool } @@ -670,22 +681,22 @@ } % the different styles: -\DeclareInstance { acro-first } +\DeclareInstance {acro-first} { default } { inline } { } -\DeclareInstance { acro-first } +\DeclareInstance {acro-first} { square } { inline } { brackets-type = [] } -\DeclareInstance { acro-first } +\DeclareInstance {acro-first} { plain } { inline } { brackets = false , between = -- } -\DeclareInstance { acro-first } +\DeclareInstance {acro-first} { plain-reversed } { inline } { @@ -693,35 +704,35 @@ between = -- , reversed = true } -\DeclareInstance { acro-first } +\DeclareInstance {acro-first} { footnote } { note } { } -\DeclareInstance { acro-first } +\DeclareInstance {acro-first} { sidenote } { note } { note-command = \sidenote {#1} } -\DeclareInstance { acro-first } +\DeclareInstance {acro-first} { empty } { note } { use-note = false } -\DeclareInstance { acro-first } +\DeclareInstance {acro-first} { short } { inline } { only-short = true , brackets = false } -\DeclareInstance { acro-first } +\DeclareInstance {acro-first} { reversed } { inline } { reversed = true } % -------------------------------------------------------------------------- % formatting the extras information: -\DeclareObjectType { acro-extra } { 1 } +\DeclareObjectType {acro-extra} {1} -\DeclareTemplateInterface { acro-extra } { default } { 1 } +\DeclareTemplateInterface {acro-extra} {default} {1} { punct : boolean = false , punct-symbol : tokenlist = {,} , @@ -729,7 +740,7 @@ brackets-type : tokenlist = () } -\DeclareTemplateCode { acro-extra } { default } { 1 } +\DeclareTemplateCode {acro-extra} {default} {1} { punct = \l__acro_extra_punct_bool , punct-symbol = \l__acro_extra_punct_tl , @@ -748,20 +759,20 @@ } % the different styles: -\DeclareInstance { acro-extra } { default } { default } +\DeclareInstance {acro-extra} {default} {default} { brackets = false , punct = true , punct-symbol = . } -\DeclareInstance { acro-extra } { plain } { default } - { brackets = false , punct = false } -\DeclareInstance { acro-extra } { paren } { default } +\DeclareInstance {acro-extra} {plain} {default} + { brackets = false , punct = true , punct-symbol = } +\DeclareInstance {acro-extra} {paren} {default} { punct = true , punct-symbol = } -\DeclareInstance { acro-extra } { bracket } { default } +\DeclareInstance {acro-extra} {bracket} {default} { punct = true , punct-symbol = , brackets-type=[] } -\DeclareInstance { acro-extra } { comma } { default } +\DeclareInstance {acro-extra} {comma} {default} { punct = true, brackets = false } % -------------------------------------------------------------------------- % outputting the page numbers: -\RequirePackage { zref-abspage } +\RequirePackage {zref-abspage} \cs_new_protected:Npn \acro_create_page_records:n #1 { @@ -927,9 +938,9 @@ \cs_generate_variant:Nn \acro_determine_page_ranges:NNn { NNV } % -------------------------------------------------------------------------- -\DeclareObjectType { acro-page-number } { 1 } +\DeclareObjectType {acro-page-number} {1} -\DeclareTemplateInterface { acro-page-number } { default } { 1 } +\DeclareTemplateInterface {acro-page-number} {default} {1} { display : boolean = true , punct : boolean = false , @@ -939,7 +950,7 @@ space : length = .3ex } -\DeclareTemplateCode { acro-page-number } { default } { 1 } +\DeclareTemplateCode {acro-page-number} {default} {1} { display = \l__acro_page_display_bool , punct = \l__acro_page_punct_bool , @@ -964,14 +975,15 @@ } % the different styles: -\DeclareInstance { acro-page-number } { default } { default } +\DeclareInstance {acro-page-number} {default} {default} { punct = true , punct-symbol = . } -\DeclareInstance { acro-page-number } { plain } { default } +\DeclareInstance {acro-page-number} {plain} {default} { punct = false } -\DeclareInstance { acro-page-number } { comma } { default } { punct = true } -\DeclareInstance { acro-page-number } { paren } { default } +\DeclareInstance {acro-page-number} {comma} {default} + { punct = true } +\DeclareInstance {acro-page-number} {paren} {default} { brackets=true , punct-symbol = ~ } -\DeclareInstance { acro-page-number } { none } { default } +\DeclareInstance {acro-page-number} {none} {default} { display = false } % -------------------------------------------------------------------------- @@ -991,36 +1003,36 @@ } % the different styles: -\DeclareInstance {acro-title} {chapter*} {sectioning} +\DeclareInstance {acro-title} {chapter*} {sectioning} { name-format = \chapter* {#1} } -\DeclareInstance {acro-title} {part*} {sectioning} +\DeclareInstance {acro-title} {part*} {sectioning} { name-format = \part* {#1} } -\DeclareInstance {acro-title} {section*} {sectioning} +\DeclareInstance {acro-title} {section*} {sectioning} { name-format = \section* {#1} } -\DeclareInstance {acro-title} {subsection*} {sectioning} +\DeclareInstance {acro-title} {subsection*} {sectioning} { name-format = \subsection* {#1} } \DeclareInstance {acro-title} {subsubsection*} {sectioning} { name-format = \subsubsection* {#1} } -\DeclareInstance {acro-title} {chapter} {sectioning} +\DeclareInstance {acro-title} {chapter} {sectioning} { name-format = \chapter {#1} } -\DeclareInstance {acro-title} {part} {sectioning} +\DeclareInstance {acro-title} {part} {sectioning} { name-format = \part {#1} } -\DeclareInstance {acro-title} {section} {sectioning} +\DeclareInstance {acro-title} {section} {sectioning} { name-format = \section {#1} } -\DeclareInstance {acro-title} {subsection} {sectioning} +\DeclareInstance {acro-title} {subsection} {sectioning} { name-format = \subsection {#1} } -\DeclareInstance {acro-title} {subsubsection} {sectioning} +\DeclareInstance {acro-title} {subsubsection} {sectioning} { name-format = \subsubsection {#1} } -\DeclareInstance {acro-title} {addchap} {sectioning} +\DeclareInstance {acro-title} {addchap} {sectioning} { name-format = \addchap {#1} } -\DeclareInstance {acro-title} {addsec} {sectioning} +\DeclareInstance {acro-title} {addsec} {sectioning} { name-format = \addsec {#1} } -\DeclareInstance {acro-title} {none} {sectioning} +\DeclareInstance {acro-title} {none} {sectioning} { name-format = \use_none:n {#1} } % -------------------------------------------------------------------------- % outputting the whole list -\DeclareObjectType { acro-list } { 3 } +\DeclareObjectType {acro-list} {3} % #1: id % #2: excluded classes @@ -1091,35 +1103,41 @@ { \tl_if_blank:nTF {#1} { - \acro_print_list_short:nn {##1} {##2} - \bool_if:NT \l__acro_capitalize_list_bool - { \bool_set_true:N \l__acro_first_upper_bool } - \acro_print_list_long:n {##1} - \bool_set_false:N \l__acro_first_upper_bool - \bool_if:NT \l__acro_foreign_bool - { \acro_get_foreign:n {##1} } - \acro_print_list_extra:n {##1} - \acro_print_list_page:n {##1} + \acro_print_list_entry:nnn + { \acro_print_list_short:nn {##1} {##2} } + { + \bool_if:NT \l__acro_capitalize_list_bool + { \bool_set_true:N \l__acro_first_upper_bool } + \acro_print_list_long:n {##1} + \bool_set_false:N \l__acro_first_upper_bool + \bool_if:NT \l__acro_foreign_bool + { \acro_get_foreign:n {##1} } + \acro_print_list_extra:n {##1} + } + { \acro_print_list_page:n {##1} } } { \clist_map_inline:nn {#1} { \prop_get:NnNT \l__acro_class_prop {##1} \l__acro_tmpa_tl { - \tl_set:Nn \l__acro_tmpb_tl { ####1 } + \tl_set:Nn \l__acro_tmpb_tl {####1} \tl_trim_spaces:N \l__acro_tmpa_tl \tl_trim_spaces:N \l__acro_tmpb_tl \tl_if_eq:NNT \l__acro_tmpa_tl \l__acro_tmpb_tl { - \acro_print_list_short:nn {##1} { ##2 } - \bool_if:NT \l__acro_capitalize_list_bool - { \bool_set_true:N \l__acro_first_upper_bool } - \acro_print_list_long:n {##1} - \bool_set_false:N \l__acro_first_upper_bool - \bool_if:NT \l__acro_foreign_bool - { \acro_get_foreign:n {##1} } - \acro_print_list_extra:n {##1} - \acro_print_list_page:n {##1} + \acro_print_list_entry:nnn + { \acro_print_list_short:nn {##1} {##2} } + { + \bool_if:NT \l__acro_capitalize_list_bool + { \bool_set_true:N \l__acro_first_upper_bool } + \acro_print_list_long:n {##1} + \bool_set_false:N \l__acro_first_upper_bool + \bool_if:NT \l__acro_foreign_bool + { \acro_get_foreign:n {##1} } + \acro_print_list_extra:n {##1} + } + { \acro_print_list_page:n {##1} } } } } @@ -1138,8 +1156,9 @@ { \AssignTemplateKeys \bool_set_true:N \l__acro_in_list_bool - \__acro_activate_hyperref_support: - \cs_set:Npn \acro_print_list_short:nn ##1##2 + \acro_activate_hyperref_support: + \cs_set_eq:NN \acro_print_list_entry:nnn \use:nnn + \cs_set_protected:Npn \acro_print_list_short:nn ##1##2 { \item [ @@ -1152,7 +1171,7 @@ } ] } - \cs_set:Npn \acro_print_list_long:n ##1 + \cs_set_protected:Npn \acro_print_list_long:n ##1 { \acro_write_long:Vf \l__acro_list_long_format_tl { @@ -1166,20 +1185,105 @@ { \prop_get:NnNT \l__acro_extra_prop {##1} \l__acro_tmpa_tl { - \UseInstance { acro-extra } { \l__acro_extra_instance_tl } + \UseInstance {acro-extra} { \l__acro_extra_instance_tl } { \l__acro_tmpa_tl } } } - \cs_set:Npn \acro_print_list_page:n ##1 + \cs_set_protected:Npn \acro_print_list_page:n ##1 { \bool_if:nT { \cs_if_exist_p:c { acro@##1@once } } - { \UseInstance { acro-page-number } { \l__acro_page_instance_tl } {##1} } + { \UseInstance {acro-page-number} { \l__acro_page_instance_tl } {##1} } } \begin {#1} \acro_list_allow_items:nn {#2} {#3} \end {#1} } +\DeclareTemplateInterface {acro-list} {list-of} {3} + { + foreign-sep : tokenlist = { ~ } , + style : tokenlist = {toc} + } + +\DeclareTemplateCode {acro-list} {list-of} {3} + { + foreign-sep = \l__acro_foreign_sep_tl , + style = \l__acro_list_of_style + } + { + \AssignTemplateKeys + \bool_set_true:N \l__acro_in_list_bool + \tl_if_eq:VnT \l__acro_page_instance_tl {none} + { \tl_set:Nn \l__acro_page_instance_tl {plain} } + \tl_set:Nn \l__acro_page_name_tl {} + \tl_set:Nn \l__acro_pages_name_tl {} + \acro_activate_hyperref_support: + \srt_case:NnF \l__acro_list_of_style + { + {toc} + { % similar to the table of contents + \cs_set_protected:Npn \acro_print_list_entry:nnn ##1##2##3 + { + \cs_if_exist:NTF \chapter + { + \contentsline{chapter}{##1}{}{} + \contentsline{section}{##2}{##3}{} + } + { + \contentsline{section}{##2}{##3}{} + \contentsline{subsection}{##2}{##3}{} + } + } + } + {lof} + { % similar to the list of figures + \cs_set_protected:Npn \l@acro + { \@dottedtocline {1} {1.5em} {\l__acro_short_width_dim} } + \cs_set_protected:Npn \acro_print_list_entry:nnn ##1##2##3 + { + \contentsline{acro}{\numberline{##1}{##2}}{##3}{} + } + } + } + { \ERROR } + \cs_set_protected:Npn \acro_print_list_short:nn ##1##2 + { + \acro_hyper_target:nn + {##1} + { + \acro_acc_supp:nn + {##1} + { \acro_write_short:nn {##1} { \l__acro_list_short_format_tl {##2} } } + } + } + \cs_set_protected:Npn \acro_print_list_long:n ##1 + { + \acro_write_long:Vf \l__acro_list_long_format_tl + { + \prop_if_in:NnTF \l__acro_list_prop {##1} + { \prop_item:Nn \l__acro_list_prop {##1} } + { \prop_item:Nn \l__acro_long_prop {##1} } + } + \acro_cite_if:Nn \l__acro_citation_all_bool {##1} + } + \cs_set_protected:Npn \acro_print_list_extra:n ##1 + { + \prop_get:NnNT \l__acro_extra_prop {##1} \l__acro_tmpa_tl + { + \UseInstance {acro-extra} { \l__acro_extra_instance_tl } + { \l__acro_tmpa_tl } + } + } + \cs_set_protected:Npn \acro_print_list_page:n ##1 + { + \bool_if:nT { \cs_if_exist_p:c {acro@##1@once} } + { \UseInstance {acro-page-number} { \l__acro_page_instance_tl } {##1} } + } + % \begin {#1} + \acro_list_allow_items:nn {#2} {#3} + % \end {#1} + } + % table template: \DeclareTemplateInterface {acro-list} {table} {3} { @@ -1188,7 +1292,7 @@ foreign-sep : tokenlist = { ~ } } -\DeclareTemplateCode { acro-list } { table } { 3 } +\DeclareTemplateCode {acro-list} {table} {3} { table = \l__acro_list_table_tl , table-spec = \l__acro_list_table_spec_tl , @@ -1196,8 +1300,9 @@ } { \AssignTemplateKeys - \__acro_activate_hyperref_support: - \cs_set:Npn \acro_print_list_short:nn ##1##2 + \acro_activate_hyperref_support: + \cs_set_eq:NN \acro_print_list_entry:nnn \use:nnn + \cs_set_protected:Npn \acro_print_list_short:nn ##1##2 { \acro_hyper_target:nn {##1} @@ -1208,7 +1313,7 @@ } & } - \cs_set:Npn \acro_print_list_long:n ##1 + \cs_set_protected:Npn \acro_print_list_long:n ##1 { \acro_write_long:Vf \l__acro_list_long_format_tl { @@ -1222,42 +1327,42 @@ { \prop_get:NnNT \l__acro_extra_prop {##1} \l__acro_tmpa_tl { - \UseInstance { acro-extra } { \l__acro_extra_instance_tl } + \UseInstance {acro-extra} { \l__acro_extra_instance_tl } { \l__acro_tmpa_tl } } } - \cs_set:Npn \acro_print_list_page:n ##1 + \cs_set_protected:Npn \acro_print_list_page:n ##1 { \bool_if:nT { \cs_if_exist_p:c { acro@##1@once } } - { \UseInstance { acro-page-number } { \l__acro_page_instance_tl } {##1} } + { \UseInstance {acro-page-number} { \l__acro_page_instance_tl } {##1} } \tabularnewline } - % \exp_args:Noo \begin { \l__acro_list_table_tl } { \l__acro_list_table_spec_tl } - % \acro_list_allow_items:nn {#2} {#3} - % \exp_args:No \end { \l__acro_list_table_tl } - \use:x { - \exp_not:N \begin { \exp_not:V \l__acro_list_table_tl } { \exp_not:V \l__acro_list_table_spec_tl } - \exp_not:n { \acro_list_allow_items:nn {#2} {#3} } - \exp_not:N \end { \exp_not:V \l__acro_list_table_tl } - } + \use:x + { + \exp_not:N \begin { \exp_not:V \l__acro_list_table_tl } + { \exp_not:V \l__acro_list_table_spec_tl } + \exp_not:n { \acro_list_allow_items:nn {#2} {#3} } + \exp_not:N \end { \exp_not:V \l__acro_list_table_tl } + } } % extra-table template: -\DeclareTemplateInterface { acro-list } { extra-table } { 3 } +\DeclareTemplateInterface {acro-list} {extra-table} {3} { table : tokenlist = longtable , table-spec : tokenlist = lp{\l__acro_table_width_dim}ll } -\DeclareTemplateCode { acro-list } { extra-table } { 3 } +\DeclareTemplateCode {acro-list} {extra-table} {3} { table = \l__acro_list_table_tl , table-spec = \l__acro_list_table_spec_tl } { \AssignTemplateKeys - \__acro_activate_hyperref_support: - \cs_set:Npn \acro_print_list_short:nn ##1##2 + \acro_activate_hyperref_support: + \cs_set_eq:NN \acro_print_list_entry:nnn \use:nnn + \cs_set_protected:Npn \acro_print_list_short:nn ##1##2 { \acro_hyper_target:nn {##1} @@ -1268,7 +1373,7 @@ } & } - \cs_set:Npn \acro_print_list_long:n ##1 + \cs_set_protected:Npn \acro_print_list_long:n ##1 { \acro_write_long:Vf \l__acro_list_long_format_tl { @@ -1283,15 +1388,15 @@ { \prop_get:NnNT \l__acro_extra_prop {##1} \l__acro_tmpa_tl { - \UseInstance { acro-extra } { \l__acro_extra_instance_tl } + \UseInstance {acro-extra} { \l__acro_extra_instance_tl } { \l__acro_tmpa_tl } } & } - \cs_set:Npn \acro_print_list_page:n ##1 + \cs_set_protected:Npn \acro_print_list_page:n ##1 { \bool_if:nT { \cs_if_exist_p:c { acro@##1@once } } - { \UseInstance { acro-page-number } { \l__acro_page_instance_tl } {##1} } + { \UseInstance {acro-page-number} { \l__acro_page_instance_tl } {##1} } \tabularnewline } \exp_args:Noo @@ -1302,21 +1407,22 @@ } % extra-table-rev template: -\DeclareTemplateInterface { acro-list } { extra-table-rev } { 3 } +\DeclareTemplateInterface {acro-list} {extra-table-rev} {3} { table : tokenlist = longtable , table-spec : tokenlist = llp{\l__acro_table_width_dim}l } -\DeclareTemplateCode { acro-list } { extra-table-rev } { 3 } +\DeclareTemplateCode {acro-list} {extra-table-rev} {3} { table = \l__acro_list_table_tl , table-spec = \l__acro_list_table_spec_tl } { \AssignTemplateKeys - \__acro_activate_hyperref_support: - \cs_set:Npn \acro_print_list_short:nn ##1##2 + \acro_activate_hyperref_support: + \cs_set_eq:NN \acro_print_list_entry:nnn \use:nnn + \cs_set_protected:Npn \acro_print_list_short:nn ##1##2 { \acro_hyper_target:nn {##1} @@ -1340,15 +1446,15 @@ { \prop_get:NnNT \l__acro_extra_prop {##1} \l__acro_tmpa_tl { - \UseInstance { acro-extra } { \l__acro_extra_instance_tl } + \UseInstance {acro-extra} { \l__acro_extra_instance_tl } { \l__acro_tmpa_tl } } & } - \cs_set:Npn \acro_print_list_page:n ##1 + \cs_set_protected:Npn \acro_print_list_page:n ##1 { \bool_if:nT { \cs_if_exist_p:c { acro@##1@once } } - { \UseInstance { acro-page-number } { \l__acro_page_instance_tl } {##1} } + { \UseInstance {acro-page-number} { \l__acro_page_instance_tl } {##1} } \tabularnewline } \exp_args:Noo \begin { \l__acro_list_table_tl } { \l__acro_list_table_spec_tl } @@ -1360,22 +1466,28 @@ \DeclareInstance {acro-list} {list} { list } { } -\DeclareInstance { acro-list } { tabular } +\DeclareInstance {acro-list} {toc} + { list-of } + { } +\DeclareInstance {acro-list} {lof} + { list-of } + { style = lof } +\DeclareInstance {acro-list} {tabular} { table } { table = tabular } -\DeclareInstance { acro-list } { longtable } +\DeclareInstance {acro-list} {longtable} { table } { table = longtable } -\DeclareInstance { acro-list } { extra-longtable } +\DeclareInstance {acro-list} {extra-longtable} { extra-table } { table = longtable } -\DeclareInstance { acro-list } { extra-tabular } +\DeclareInstance {acro-list} {extra-tabular} { extra-table } { table = tabular } -\DeclareInstance { acro-list } { extra-longtable-rev } +\DeclareInstance {acro-list} {extra-longtable-rev} { extra-table-rev } { table = longtable } -\DeclareInstance { acro-list } { extra-tabular-rev } +\DeclareInstance {acro-list} {extra-tabular-rev} { extra-table-rev } { table = tabular } @@ -1455,7 +1567,7 @@ \cs_new_protected:Npn \acro_get:n #1 { \bool_if:NF \l__acro_in_list_bool { \leavevmode } - \__acro_activate_hyperref_support: + \acro_activate_hyperref_support: % short: \prop_get:NnNF \l__acro_short_prop {#1} \l__acro_tmpa_tl {} \__acro_make_link:NnV \l__acro_short_tl {#1} \l__acro_tmpa_tl @@ -1881,13 +1993,20 @@ % -------------------------------------------------------------------------- % #1: id % #2: short|alt -\cs_new_protected:Npn \acro_write_compact:nn #1#2 +\cs_set_protected:Npn \acro_write_compact:nn #1#2 { \acro_get_ending_form:nn {#1} {#2} \acro_acc_supp:nn {#1} - { \use:c {acro_write_#2:nv} {#1} {l__acro_#2_tl} } - \acro_endings:nn {#1} {#2} + { + \acro_write_tooltip:nnV + {#1} + { + \use:c {acro_write_#2:nv} {#1} {l__acro_#2_tl} + \acro_endings:nn {#1} {#2} + } + \l__acro_long_tl + } } % #1: ID @@ -1989,10 +2108,14 @@ \acro_is_used:n {#1} \acro_if_is_single:nT {#1} { \cs_set_eq:NN \acro_hyper_link:nn \use_ii:nn } - \UseInstance {acro-first} { \l__acro_first_instance_tl } - {#1} - { \l__acro_short_tl } - { \l__acro_long_tl } + \use:x + { + \UseInstance {acro-first} + { \exp_not:V \l__acro_first_instance_tl } + { \exp_not:n {#1} } + { \exp_not:V \l__acro_short_tl } + { \exp_not:V \l__acro_long_tl } + } } % output like the first time with own long version: @@ -2133,20 +2256,53 @@ } \cs_generate_variant:Nn \acro_do_acc_supp:nnn { VV } -% macro to redefine to adapt definition of \acro_acc_supp:nn, for cases like -% http://tex.stackexchange.com/a/161521/ -\cs_new_protected:Npn \acro_set_accsupp: - { \cs_set_eq:NN \acro_acc_supp:nn \acro_get_acc_supp:nn } - -\AtBeginDocument +\AtEndPreamble { \bool_if:NT \l__acro_acc_supp_bool { \RequirePackage {accsupp} - \acro_set_accsupp: + \cs_set_eq:NN \acro_acc_supp:nn \acro_get_acc_supp:nn + } + \bool_if:NT \l__acro_tooltip_bool + { + \RequirePackage {pdfcomment} + \cs_if_eq:NNT \__acro_tooltip_cmd:nn \use_i:nn + { \cs_set:Npn \__acro_tooltip_cmd:nn { \pdftooltip } } + } + } + +% -------------------------------------------------------------------------- +% tooltips for acronyms + +% #1: id +% #2: printed text +% #3: tool tip text +\cs_new_protected:Npn \acro_write_tooltip:nnn #1#2#3 + { + \prop_get:NnNTF \l__acro_tooltip_prop {#1} \l__acro_tmpa_tl + { \__acro_check_tooltip:nV {#2} \l__acro_tmpa_tl } + { \__acro_check_tooltip:nn {#2} {#3} } + } +\cs_generate_variant:Nn \acro_write_tooltip:nnn { nnV } + +% #1: printed text +% #2: tool tip text +\cs_new_protected:Npn \__acro_check_tooltip:nn #1#2 + { + \bool_if:NTF \l__acro_inside_tooltip_bool + {#1} + { + \bool_set_true:N \l__acro_inside_tooltip_bool + \__acro_tooltip_cmd:nn {#1} {#2} } } +\cs_generate_variant:Nn \__acro_check_tooltip:nn { nV } +% use whatever command you like for creating tooltips here: +% #1: printed text +% #2: tool tip text +\cs_new_eq:NN \__acro_tooltip_cmd:nn \use_i:nn + % -------------------------------------------------------------------------- % indefinite articles: @@ -2218,11 +2374,15 @@ } \seq_sort:Nn \l__acro_tmpa_seq { - \tl_to_lowercase:n { - \int_compare:nTF { \acro_strcmp:nn {##1} { ##2 } = -1 } - { \sort_ordered: } - { \sort_reversed: } - } + \int_compare:nTF + { + \acro_strcmp:nn + { \str_fold_case:n {##1} } + { \str_fold_case:n {##2} } + = \c_minus_one + } + { \sort_ordered: } + { \sort_reversed: } } \seq_map_inline:Nn \l__acro_tmpa_seq { @@ -3051,6 +3211,9 @@ % acc supp: \acro_declare_key:nn {acc_supp} {accsupp} +% tooltip: +\acro_declare_simple_key:n {tooltip} + % citation: \prop_new:N \l__acro_citation_prop \prop_new:N \l__acro_citation_pre_prop @@ -3163,7 +3326,7 @@ \cs_new_protected:Npn \acro_use_list_instance:nn #1#2 { - \UseInstance { acro-list } { \l__acro_list_instance_tl } + \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 } @@ -3388,6 +3551,11 @@ 2015/08/29 v2.0b - fix https://bitbucket.org/cgnieder/acro/issue/44 - fix https://bitbucket.org/cgnieder/acro/issue/45 - implement https://bitbucket.org/cgnieder/acro/issue/42 +2015/09/05 v2.1 - add list object type `list-of' that prints the list like a + toc or lof, new option `list-short-width', + - correct bug in the `plain' extra style + - implemented `tooltip' property + - remove \tl_to_lowercase:n % -------------------------------------------------------------------------- update => http://tex.stackexchange.com/questions/236362 |