summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/acro/acro.sty
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/acro/acro.sty')
-rw-r--r--macros/latex/contrib/acro/acro.sty122
1 files changed, 93 insertions, 29 deletions
diff --git a/macros/latex/contrib/acro/acro.sty b/macros/latex/contrib/acro/acro.sty
index d3ab51cf9b..8efd343d1d 100644
--- a/macros/latex/contrib/acro/acro.sty
+++ b/macros/latex/contrib/acro/acro.sty
@@ -22,14 +22,14 @@
%
% The Current Maintainer of this work is Clemens Niederberger.
% --------------------------------------------------------------------------
-\RequirePackage{expl3,xparse,l3keys2e}
+\RequirePackage{l3keys2e}
\ExplSyntaxOn
% setup package:
\tl_const:Nn \c_acro_package_name_tl {acro}
-\tl_const:Nn \c_acro_date_tl {2020/11/21}
+\tl_const:Nn \c_acro_date_tl {2020/12/25}
\tl_const:Nn \c_acro_version_major_number_tl {3}
-\tl_const:Nn \c_acro_version_minor_number_tl {3}
+\tl_const:Nn \c_acro_version_minor_number_tl {4}
\tl_const:Nn \c_acro_version_subrelease_tl {}
\tl_const:Nx \c_acro_version_number_tl
{
@@ -54,8 +54,8 @@
\tl_new:N \g_acro_end_document_hook_tl
\tl_new:N \g_acro_begin_document_hook_tl
-\AtBeginDocument { \tl_use:N \g_acro_begin_document_hook_tl }
-\AtEndDocument { \tl_use:N \g_acro_end_document_hook_tl }
+\hook_gput_code:nnn {begindocument} {acro} { \tl_use:N \g_acro_begin_document_hook_tl }
+\hook_gput_code:nnn {enddocument} {acro} { \tl_use:N \g_acro_end_document_hook_tl }
\cs_new_protected:Npn \acro_at_begin_document:n #1
{ \tl_gput_right:Nn \g_acro_begin_document_hook_tl {#1} }
@@ -923,6 +923,9 @@
\NewDocumentCommand \acronopagerange {}
{ \acro_no_page_ranges:e { \AcroTemplateName } }
+\NewDocumentCommand \acroneedpages {}
+ { \acro_need_pages: }
+
\NewDocumentCommand \acropagefill {}
{ \acro_if_pages:eT { \AcronymID } { \tl_use:N \l__acro_pages_fill_tl } }
@@ -1725,6 +1728,7 @@
\DeclareAcroProperty {post}
\DeclareAcroProperty {long-post}
\DeclareAcroProperty {first-style}
+\DeclareAcroProperty {subsequent-style}
\DeclareAcroProperty {single-style}
% formatting:
@@ -1775,8 +1779,10 @@
\keys_define:nn {acro}
{
- first-style .tl_set:N = \l__acro_first_style_tl ,
- first-style .initial:n = long-short
+ first-style .tl_set:N = \l__acro_first_style_tl ,
+ first-style .initial:n = long-short ,
+ subsequent-style .tl_set:N = \l__acro_subsequent_tl ,
+ subsequent-style .initial:n = short
}
\cs_new_protected:Npn \acro_declare_acronym:nn #1#2
@@ -1852,6 +1858,7 @@
{
\acro_property_set:nnn {#1} {used} {true}
\acro_step:n {#1}
+ \acro_record_barrier:n {#1}
}
}
@@ -2146,6 +2153,15 @@
}
}
+\cs_new_protected:Npn \acro_disable_endings:
+ {
+ \tl_map_tokens:Nn \l__acro_endings_tl
+ { \__acro_disable_ending:n }
+ }
+
+\cs_new_protected:Npn \__acro_disable_ending:n #1
+ { \bool_set_false:c {l__acro_ending_#1_bool} }
+
% #1: id
% #2: short|long
\cs_new_protected:Npn \__acro_set_endings:nn #1#2
@@ -2229,7 +2245,13 @@
{
\int_compare:nNnTF
{
- \bool_if:NTF \l__acro_usage_local_bool
+ \bool_lazy_or:nnTF
+ { \l__acro_usage_local_bool }
+ {
+ \bool_lazy_and_p:nn
+ { \l__acro_list_bool }
+ { \l__acro_list_local_bool }
+ }
{ \acro_barrier_usage:n {#1} }
{ \acro_property_get:nn {#1} {usage} }
}
@@ -2578,9 +2600,24 @@
}
}
+\int_new:N \l__acro_nest_int
+\bool_new:N \g__acro_nested_bool
+
+\prg_new_conditional:Npnn \acro_if_nested: {p,T,F,TF}
+ {
+ \bool_lazy_and:nnTF
+ { \int_compare_p:n { \l__acro_nest_int = 1 } }
+ { \g__acro_nested_bool }
+ { \prg_return_true: }
+ { \prg_return_false: }
+ }
+
\cs_new_protected:Npn \acro_begin:
{
\group_begin:
+ \int_compare:nNnT \l__acro_nest_int > 0
+ { \bool_gset_true:N \g__acro_nested_bool }
+ \int_incr:N \l__acro_nest_int
\__acro_check_after_end:w
}
@@ -2599,6 +2636,7 @@
\cs_new_protected:Npn \acro_end:
{
+ \acro_if_nested:T { \bool_gset_false:N \g__acro_nested_bool }
\bool_if:NT \g__acro_gobble_trail_bool
{
\bool_gset_false:N \g__acro_gobble_trail_bool
@@ -2990,7 +3028,9 @@
\acro_locale:nnn {#1} {#2}
{
\__acro_write:nn {#1} {#2}
- \bool_if:NT \l__acro_include_endings_bool
+ \bool_lazy_and:nnT
+ { !\acro_if_nested_p: }
+ { \l__acro_include_endings_bool }
{
\acro_if_ending_form:nnF {#1} {#2}
{ \__acro_ending:nn {#1} {#2} }
@@ -2998,9 +3038,11 @@
}
}
\group_end:
- \acro_if_ending_form:nnF {#1} {#2}
+ \bool_lazy_or:nnF
+ { \acro_if_nested_p: }
+ { \l__acro_include_endings_bool }
{
- \bool_if:NF \l__acro_include_endings_bool
+ \acro_if_ending_form:nnF {#1} {#2}
{ \__acro_ending:nn {#1} {#2} }
}
\acro_property_if_eq:nnT {#2} {long}
@@ -3050,7 +3092,7 @@
{
\acro_use:n {#2}
\acro_record_page:n {#2}
- \acro_record_barrier:n {#2}
+ % \acro_record_barrier:n {#2}
\acro_index:n {#2}
}
}
@@ -3268,7 +3310,7 @@
\cs_new_protected:Npn \__acro_template_stop:nn #1#2
{ \group_end: \__acro_clear_template_setup:nn {#1} {#2} }
-% typesetting the first appearance of acronym: pseude template `first'
+% typesetting the first appearance of acronym: pseudo template `first'
% #1: parameter number
% #2: template type
@@ -3314,7 +3356,14 @@
}
{ \tl_set_eq:NN \l__acro_tmpa_tl \l__acro_first_style_tl }
}
- { \tl_set:Nn \l__acro_tmpa_tl {short} }
+ {
+ \acro_property_if_set:VnTF \l_acro_id_tl {subsequent-style}
+ {
+ \tl_set:Ne \l__acro_tmpa_tl
+ { \acro_property_get:Vn \l_acro_id_tl {subsequent-style} }
+ }
+ { \tl_set_eq:NN \l__acro_tmpa_tl \l__acro_subsequent_tl }
+ }
}
}
{single} {
@@ -3457,6 +3506,7 @@
\clist_new:N \l__acro_tag_include_clist
\clist_new:N \l__acro_tag_exclude_clist
+\clist_new:N \l__acro_tag_add_clist
\cs_new_protected:Npn \acro_list_choose_set:
{
@@ -3466,7 +3516,19 @@
\seq_gclear:N \g__acro_list_seq
\seq_map_inline:Nn \g__acro_acronyms_seq
{
- \acro_if_single:nF {##1}
+ \acro_if_single:nTF {##1}
+ {
+ \clist_set:Ne \l__acro_tmpa_clist
+ { \acro_property_get:nn {##1} {tag} }
+ \clist_map_inline:Nn \l__acro_tmpa_clist
+ {
+ \clist_if_in:NnT \l__acro_tag_add_clist {####1}
+ {% acronym is included
+ \seq_gput_right:Nn \g__acro_list_seq {##1}
+ \clist_map_break:
+ }
+ }
+ }
{ \seq_gput_right:Nn \g__acro_list_seq {##1} }
}
}
@@ -3488,7 +3550,7 @@
{ \l__acro_list_local_bool }
{
\int_compare_p:nNn
- { \intarray_count:c {g__acro_##1_barriers_intarray} } > 0
+ { \intarray_count:c {g__acro_##1_barriers_intarray} } > 0
}
{
\bool_set_false:N \l__acro_tmpb_bool
@@ -3596,6 +3658,7 @@
display .initial:n = used ,
include .clist_set:N = \l__acro_tag_include_clist ,
exclude .clist_set:N = \l__acro_tag_exclude_clist ,
+ add .clist_set:N = \l__acro_tag_add_clist ,
local .bool_set:N = \l__acro_list_local_bool ,
heading .tl_set:N = \l__acro_heading_tl ,
preamble .tl_set:N = \l__acro_preamble_tl ,
@@ -3626,8 +3689,10 @@
% record page numbers:
\RequirePackage {zref-abspage}
-\msg_new:nnn {acro} {label}
- { The~ list~ template~ `#1'~ needs~ the~ option~ `labels'~ activated. }
+\msg_new:nnn {acro} {no-page-range}
+ {
+ The~ list~ template~ `#1'~ cannot~ display~ a~ page~ range.
+ }
\msg_new:nnn {acro} {threshold}
{ The~ sequentes~ threshold~ needs~ to~ be~ at~ least~ 3. }
@@ -3863,23 +3928,18 @@
}
\prg_generate_conditional_variant:Nnn \acro_if_pages:n {e} {p,T,F,TF}
-% \acro_at_begin_document:n
-% {
-% \bool_lazy_and:nnT
-% { \l__acro_pages_display_bool }
-% { !\l__acro_pages_all_bool }
-% { \bool_set_true:N \l__acro_label_bool }
-% }
-
% #1: style name
\cs_new_protected:Npn \acro_no_page_ranges:n #1
{
- \bool_if:NF \l__acro_label_bool
- { \msg_warning:nnn {acro} {label} {#1} }
+ \bool_if:NT \l__acro_pages_all_bool
+ { \msg_warning:nnn {acro} {no-page-range} {#1} }
\bool_set_false:N \l__acro_pages_all_bool
}
\cs_generate_variant:Nn \acro_no_page_ranges:n {e}
+\cs_new_protected:Npn \acro_need_pages:
+ { \bool_set_true:N \l__acro_pages_display_bool }
+
\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
@@ -5179,13 +5239,15 @@
\AcronymTable
\end {supertabular}
}
+
+\let\l@acro\l@figure
\NewAcroTemplate [list] {lof}
{
\acroheading
\acropreamble
\acronopagerange
- \let\l@acro\l@figure
+ \acroneedpages
\acronymsmapF
{
\contentsline {acro}
@@ -5212,6 +5274,7 @@
\acroheading
\acropreamble
\acronopagerange
+ \acroneedpages
\acronymsmapF
{
\contentsline { \acroifchapterTF {chapter} {section} }
@@ -5596,6 +5659,7 @@
first-long-format .code:n =
\acro_deprecate_option:nn {format/first-long} {#1} ,
list-short-format .code:n = \acro_remove_option: ,
+ list-short-width .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: ,