summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/acro
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-03-14 21:24:09 +0000
committerKarl Berry <karl@freefriends.org>2016-03-14 21:24:09 +0000
commita067ac95d311257396b00e472c84f8c8d069db02 (patch)
tree3a96e6bb25761a5c7d98bc9560c21f106fb93336 /Master/texmf-dist/tex/latex/acro
parentf9ac0eb7dec4057b4a1b00376562de0062c5b7c6 (diff)
acro (14mar16)
git-svn-id: svn://tug.org/texlive/trunk@40022 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/acro')
-rw-r--r--Master/texmf-dist/tex/latex/acro/acro.sty258
1 files changed, 194 insertions, 64 deletions
diff --git a/Master/texmf-dist/tex/latex/acro/acro.sty b/Master/texmf-dist/tex/latex/acro/acro.sty
index 9e058b76913..a566c25a487 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/02/02}
- {2.2c}
+ {2016/03/14}
+ {2.3}
{Typeset Acronyms}
% --------------------------------------------------------------------------
@@ -229,6 +229,7 @@
\tl_new:N \l__acro_long_format_tl
\tl_new:N \l__acro_first_long_format_tl
\tl_new:N \l__acro_list_long_format_tl
+\tl_new:N \l__acro_single_format_tl
\tl_new:N \l__acro_default_indefinite_tl
\tl_set:Nn \l__acro_default_indefinite_tl { a }
\tl_new:N \l__acro_extra_tl
@@ -238,8 +239,10 @@
\tl_new:N \l__acro_foreign_format_tl
\tl_new:N \l__acro_foreign_list_format_tl
\tl_set:Nn \l__acro_foreign_list_format_tl { \acroenparen }
+\tl_new:N \l__acro_foreign_lang_tl
\tl_new:N \l__acro_first_instance_tl
\tl_set:Nn \l__acro_first_instance_tl { default }
+\tl_new:N \l__acro_first_style_tl
\tl_new:N \l__acro_extra_instance_tl
\tl_set:Nn \l__acro_extra_instance_tl { default }
\tl_new:N \l__acro_page_instance_tl
@@ -265,6 +268,7 @@
\tl_new:N \l__acro_short_tl
\tl_new:N \l__acro_alt_tl
\tl_new:N \l__acro_long_tl
+\tl_new:N \l__acro_single_tl
\tl_new:N \l__acro_long_pre_tl
\tl_new:N \l__acro_long_post_tl
\tl_new:N \l__acro_custom_format_tl
@@ -343,6 +347,8 @@
first-long-format .code:n =
\tl_set:Nn \l__acro_first_long_format_tl {#1} ,
first-long-format .value_required:n = true ,
+ single-format .tl_set:N = \l__acro_single_format_tl ,
+ single-format .value_required:n = true ,
format-include-endings .bool_set:N = \l__acro_include_endings_format_bool ,
display-foreign .bool_set:N = \l__acro_foreign_bool ,
foreign-format .tl_set:N = \l__acro_foreign_format_tl ,
@@ -603,14 +609,8 @@
!\l__acro_first_only_short_bool
}
{
- \prop_get:NnNT \l__acro_foreign_prop {#1} \l__acro_foreign_tl
- {
- \group_begin:
- \tl_use:N \l__acro_foreign_format_tl
- \tl_use:N \l__acro_foreign_tl
- \group_end:
- \tl_use:N \l__acro_foreign_sep_tl
- }
+ \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 }
@@ -643,20 +643,10 @@
\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}
- \bool_if:NT \l__acro_foreign_bool
- {
- \prop_get:NnNT \l__acro_foreign_prop {#1} \l__acro_foreign_tl
- {
- \tl_use:N \l__acro_foreign_sep_tl
- \group_begin:
- \tl_use:N \l__acro_foreign_format_tl
- \tl_use:N \l__acro_foreign_tl
- \group_end:
- }
- }
+ \acro_if_foreign:nT {#1}
+ { \acroenparen { \acro_write_foreign:n {#1} } }
}
- \bool_if:nT
- { \l__acro_group_citation_bool && !\l__acro_first_reversed_bool }
+ \bool_if:NT \l__acro_group_citation_bool
{ \acro_group_cite:n {#1} }
\bool_if:nT
{ \l__acro_first_use_brackets_bool && !\l__acro_first_only_short_bool }
@@ -690,18 +680,10 @@
\__acro_note_command:n
{
\acro_write_long:Vo \l__acro_first_long_format_tl {#3}
- \bool_if:NT \l__acro_foreign_bool
+ \acro_if_foreign:nT {#1}
{
- \prop_get:NnNT \l__acro_foreign_prop {#1} \l__acro_foreign_tl
- {
- \tl_use:N \l__acro_foreign_sep_tl
- (
- \group_begin:
- \tl_use:N \l__acro_foreign_format_tl
- \tl_use:N \l__acro_foreign_tl
- \group_end:
- )
- }
+ \tl_use:N \l__acro_foreign_sep_tl
+ \acroenparen { \acro_write_foreign:n {#1} }
}
\acro_cite_if:Nn \l__acro_citation_first_bool {#1}
\acro_index_if:Nn \l__acro_addto_index_bool {#1}
@@ -1147,20 +1129,6 @@
\cs_new_protected:Npn \acro_print_list_entry:nnnn #1#2#3#4
{ #1 #2 #3 #4 }
-\cs_new:Npn \acroenparen #1 { ( #1 ) }
-
-\cs_new_protected:Npn \acro_get_foreign:n #1
- {
- \prop_get:NnNT \l__acro_foreign_prop {#1} \l__acro_foreign_tl
- {
- \tl_use:N \l__acro_foreign_sep_tl
- \group_begin:
- \tl_use:N \l__acro_foreign_list_format_tl
- { \tl_use:N \l__acro_foreign_tl }
- \group_end:
- }
- }
-
\cs_new_protected:Npn \acro_for_all_acronyms_do:n #1
{ \prop_map_inline:Nn \l__acro_short_prop {#1} }
@@ -1224,7 +1192,7 @@
% --------------------------------------------------------------------------
% declare templates for the list:
-% list template:
+% `list' template:
\DeclareTemplateInterface {acro-list} {list} {2}
{
foreign-sep : tokenlist = {~} ,
@@ -1265,7 +1233,7 @@
}
}
-% list-of template:
+% `list-of' template:
\DeclareTemplateInterface {acro-list} {list-of} {2}
{
foreign-sep : tokenlist = {~} ,
@@ -1354,7 +1322,7 @@
}
}
-% table template:
+% `table' template:
\DeclareTemplateInterface {acro-list} {table} {2}
{
table : tokenlist = tabular ,
@@ -1397,7 +1365,7 @@
}
}
-% extra-table template:
+% `extra-table' template:
\DeclareTemplateInterface {acro-list} {extra-table} {2}
{
table : tokenlist = tabular ,
@@ -1526,7 +1494,13 @@
\bool_gset_true:c { g__acro_#1_first_use_bool }
\acro_if_is_single:nTF {#1}
{ \acro_single:n {#1} }
- {
+ {
+ \tl_if_blank:VF \l__acro_first_style_tl
+ {
+ \tl_set_eq:NN
+ \l__acro_first_instance_tl
+ \l__acro_first_style_tl
+ }
\acro_first_instance:VnVV
\l__acro_first_instance_tl
{#1}
@@ -1536,6 +1510,13 @@
}
}
+% single appearances:
+\cs_new_protected:Npn \acro_single:n #1
+ {
+ \acro_single_form:nV {#1} \l__acro_single_form_tl
+ \acro_after:n {#1}
+ }
+
% #1: ID
% #2: long|first|<other>
\cs_new_protected:Npn \acro_single_form:nn #1#2
@@ -1544,27 +1525,50 @@
\str_case:nnF {#2}
{
{long} {
- \acro_write_expanded:nnV {#1} {long} \l__acro_long_tl
- \acro_cite:n {#1}
+ \tl_if_blank:VT \l__acro_single_format_tl
+ {
+ \bool_if:NTF \l__acro_custom_long_format_bool
+ {
+ \tl_set_eq:NN
+ \l__acro_single_format_tl
+ \l__acro_custom_long_format_tl
+ }
+ {
+ \tl_set_eq:NN
+ \l__acro_single_format_tl
+ \l__acro_long_format_tl
+ }
+ }
+ \tl_if_blank:VT \l__acro_single_tl
+ { \tl_set_eq:NN \l__acro_single_tl \l__acro_long_tl }
+ \acro_write_long:VV \l__acro_single_format_tl \l__acro_single_tl
}
{first} {
+ \tl_if_blank:VF \l__acro_single_format_tl
+ {
+ \tl_set_eq:NN
+ \l__acro_first_long_format_tl
+ \l__acro_single_format_tl
+ }
+ \tl_if_blank:VT \l__acro_single_tl
+ { \tl_set_eq:NN \l__acro_single_tl \l__acro_long_tl }
\acro_first_instance:VnVV
\l__acro_first_instance_tl
{#1}
\l__acro_short_tl
- \l__acro_long_tl
+ \l__acro_single_tl
}
}
{ % other (e.g. short)
+ \tl_if_blank:VF \l__acro_single_tl
+ { \tl_set_eq:cN {l__acro_#2_tl} \l__acro_single_tl }
+ \tl_if_blank:VF \l__acro_single_format_tl
+ { \tl_set_eq:cN {l__acro_#2_format_tl} \l__acro_single_format_tl }
\acro_write_compact:nn {#1} {#2}
- \acro_cite:n {#1}
}
}
\cs_generate_variant:Nn \acro_single_form:nn {nV}
-\cs_new_protected:Npn \acro_single:n #1
- { \acro_single_form:nV {#1} \l__acro_single_form_tl }
-
\prg_new_conditional:Npnn \acro_if_is_single:n #1 { p,T,TF }
{
\bool_if:nTF { !\l__acro_use_single_bool || \cs_if_exist_p:c { acro@#1@twice } }
@@ -1597,8 +1601,19 @@
\prop_get:NnNF \l__acro_long_prop {#1} \l__acro_long_tl {}
% foreign:
\prop_get:NnNF \l__acro_foreign_prop {#1} \l__acro_foreign_tl {}
+ % foreign:
+ \prop_get:NnNF \l__acro_foreign_lang_prop {#1} \l__acro_foreign_lang_tl {}
+ % \tl_if_blank:VF \l__acro_foreign_lang_tl
+ % {
+ % \tl_set:Nx \l__acro_foreign_lang_tl
+ % { \baselanguage \l__acro_foreign_lang_tl }
+ % }
% extra:
\prop_get:NnNF \l__acro_extra_prop {#1} \l__acro_extra_tl {}
+ % single:
+ \prop_get:NnNF \l__acro_single_prop {#1} \l__acro_single_tl {}
+ % single:
+ \prop_get:NnNF \l__acro_first_style_prop {#1} \l__acro_first_style_tl {}
% formatting
\prop_get:NnNTF \l__acro_long_format_prop {#1}
\l__acro_custom_long_format_tl
@@ -1610,13 +1625,16 @@
\prop_get:NnNTF \l__acro_format_prop {#1} \l__acro_custom_format_tl
{ \bool_set_true:N \l__acro_custom_format_bool }
{ \bool_set_false:N \l__acro_custom_format_bool }
+ \prop_get:NnNF \l__acro_single_format_prop {#1}
+ \l__acro_single_format_tl
+ {}
\acro_for_endings_do:n
{
\bool_if:cT {l__acro_##1_bool}
{ \__acro_set_ending_for:nnn {##1} {#1} {long} }
}
- \prop_get:NnNT \l__acro_long_post_prop {#1} \l__acro_long_post_tl
- { \tl_put_right:NV \l__acro_long_tl \l__acro_long_post_tl }
+ \prop_get:NnNF \l__acro_long_post_prop {#1} \l__acro_long_post_tl
+ { \tl_clear:N \l__acro_long_post_tl }
\prop_get:NnNT \l__acro_long_pre_prop {#1} \l__acro_long_pre_tl
{ \tl_put_left:NV \l__acro_long_tl \l__acro_long_pre_tl }
}
@@ -1664,7 +1682,12 @@
{
\acro_for_endings_do:n
{
- \bool_if:nT { \prop_item:cn {l__acro_#2_##1_form_prop} {#1} }
+ \bool_if:nT
+ {
+ \prop_item:cn {l__acro_#2_##1_form_prop} {#1}
+ &&
+ \use:c {l__acro_##1_bool}
+ }
{ \prop_get:cncF {l__acro_#2_##1_prop} {#1} {l__acro_#2_tl} {} }
}
}
@@ -2005,6 +2028,72 @@
}
\cs_generate_variant:Nn \acro_write_long:nn { VV,Vo,Vf,Vn,vn }
+\prg_new_conditional:Npnn \acro_if_foreign:n #1 {T,F,TF}
+ {
+ \bool_if:nTF
+ {
+ \l__acro_foreign_bool
+ &&
+ \prop_if_in_p:Nn \l__acro_foreign_prop {#1}
+ }
+ { \prg_return_true: }
+ { \prg_return_false: }
+ }
+
+\cs_new_protected:Npn \acro_foreign_language:nn #1#2 {}
+\AtBeginDocument{
+ \cs_if_exist:NTF \foreignlanguage
+ {
+ \cs_set_protected:Npn \acro_foreign_language:nn #1#2
+ {
+ \tl_if_blank:nTF {#1}
+ {#2}
+ { \foreignlanguage {#1} {#2} }
+ }
+ }
+ {
+ \cs_set_protected:Npn \acro_foreign_language:nn #1#2
+ { \use_ii:nn {#1} {#2} }
+ }
+}
+\cs_generate_variant:Nn \acro_foreign_language:nn {VV}
+
+\cs_new_protected:Npn \acro_write_foreign:n #1
+ {
+ \acro_if_foreign:nT {#1}
+ {
+ \prop_get:NnNT \l__acro_foreign_prop {#1} \l__acro_foreign_tl
+ {
+ \group_begin:
+ \tl_use:N \l__acro_foreign_format_tl
+ {
+ \acro_foreign_language:VV
+ \l__acro_foreign_lang_tl
+ \l__acro_foreign_tl
+ }
+ \group_end:
+ }
+ }
+ }
+
+\cs_new:Npn \acroenparen #1 { ( #1 ) }
+
+\cs_new_protected:Npn \acro_get_foreign:n #1
+ {
+ \prop_get:NnNT \l__acro_foreign_prop {#1} \l__acro_foreign_tl
+ {
+ \tl_use:N \l__acro_foreign_sep_tl
+ \group_begin:
+ \tl_use:N \l__acro_foreign_list_format_tl
+ {
+ \acro_foreign_language:VV
+ \l__acro_foreign_lang_tl
+ \l__acro_foreign_tl
+ }
+ \group_end:
+ }
+ }
+
% --------------------------------------------------------------------------
% #1: id
% #2: short|alt
@@ -2033,6 +2122,8 @@
\tl_replace_all:Nnn \l__acro_tmpa_tl {-} {_}
\acro_write_long:vn {l__acro_ \l__acro_tmpa_tl _format_tl} {#3}
\acro_endings:nn {#1} {long}
+ \tl_if_in:nnT {#2} {long}
+ { \l__acro_long_post_tl }
}
\cs_generate_variant:Nn \acro_write_expanded:nnn { nnV }
@@ -2123,6 +2214,12 @@
\acro_is_used:n {#1}
\acro_if_is_single:nT {#1}
{ \cs_set_eq:NN \acro_hyper_link:nn \use_ii:nn }
+ \tl_if_blank:VF \l__acro_first_style_tl
+ {
+ \tl_set_eq:NN
+ \l__acro_first_instance_tl
+ \l__acro_first_style_tl
+ }
\acro_first_instance:VnVV
\l__acro_first_instance_tl
{#1}
@@ -2762,6 +2859,13 @@
\acro_single:n {#1}
}
+\NewAcroCommand \Acsingle
+ {
+ \acro_get:n {#1}
+ \acro_first_upper:
+ \acro_single:n {#1}
+ }
+
% short:
\NewAcroCommand \acs
{ \acro_short:n {#1} }
@@ -2789,6 +2893,12 @@
\NewAcroCommand \aca
{ \acro_alt:n {#1} }
+\NewAcroCommand \Aca
+ {
+ \acro_first_upper:
+ \acro_alt:n {#1}
+ }
+
\NewAcroCommand \iaca
{
\acro_indefinite:
@@ -3116,6 +3226,8 @@
}
}
+\acro_declare_simple_key:n{first-style}
+
% list:
\acro_declare_simple_key:n {list}
@@ -3162,6 +3274,9 @@
% foreign:
\acro_declare_simple_key:n {foreign}
+% foreign:
+\acro_declare_simple_key:n {foreign-lang}
+
% format:
\acro_declare_simple_key:n {format}
@@ -3178,7 +3293,7 @@
\prop_new:N \l__acro_pdfstring_short_prop
\cs_new_protected:Npn \__acro_declare_pdfstring:nw #1#2/#3/#4 \acro_stop:
{
- \__acro_key_check:nn {#1} { pdfstring }
+ \__acro_key_check:nn {#1} {pdfstring}
\prop_put:Nnn \l__acro_pdfstring_short_prop {#1} {#2}
\acro_for_endings_do:n
{
@@ -3228,6 +3343,12 @@
% extra information:
\acro_declare_simple_key:n {extra}
+% single appearances:
+\acro_declare_simple_key:n {single}
+
+% single format:
+\acro_declare_simple_key:n {single-format}
+
% acc supp:
\acro_declare_key:nn {acc_supp} {accsupp}
@@ -3593,6 +3714,15 @@
2016/01/07 v2.2a - \prop_get:Nn => \prop_item:Nn
2016/01/21 v2.2b - fix issue #59
2016/02/02 v2.2c - fix issue #60
+2016/03/14 v2.3 - foreign-format may be a macro taking an argument
+ - \Aca, \Acsingle
+ - properties `single' and `single-format', option
+ `single-format' => issue #62
+ - property `first-style' => issue #61
+ - fix issue #64: long-post entry is now added *after* the
+ endings
+ - property `foreign-lang'
+ - fix issue #65
% --------------------------------------------------------------------------
update => http://tex.stackexchange.com/questions/236362