summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/acro
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-01-29 23:21:06 +0000
committerKarl Berry <karl@freefriends.org>2013-01-29 23:21:06 +0000
commit13bacf6392e96e4d46c40e1d4b50b9e70055fb18 (patch)
tree8fdf13d699623afeebe235c54bfbd8dfe7d61d58 /Master/texmf-dist/tex/latex/acro
parent86f4995eee505ffb07f244911a667873bba1468c (diff)
acro (29jan13)
git-svn-id: svn://tug.org/texlive/trunk@28981 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/acro')
-rw-r--r--Master/texmf-dist/tex/latex/acro/acro.sty347
-rw-r--r--Master/texmf-dist/tex/latex/acro/acro1.def135
2 files changed, 362 insertions, 120 deletions
diff --git a/Master/texmf-dist/tex/latex/acro/acro.sty b/Master/texmf-dist/tex/latex/acro/acro.sty
index fb8b8c09105..af47b4d9740 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,xparse,l3keys2e,xtemplate}
\ProvidesExplPackage
{acro}
- {2013/01/16}
- {1.0}
+ {2013/01/29}
+ {1.1a}
{Typeset Acronyms}
% warning and error messages:
@@ -85,9 +85,11 @@
\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
+\bool_new:N \l__acro_addto_index_bool
% tokenlist variables:
\tl_new:N \l__acro_short_format_tl
+\tl_new:N \l__acro_list_short_format_tl
\tl_new:N \l__acro_long_format_tl
\tl_new:N \l__acro_list_long_format_tl
\tl_new:N \l__acro_extra_format_tl
@@ -119,6 +121,8 @@
\tl_set:Nn \l__acro_default_plural_tl { s }
\tl_new:N \l__acro_alt_tl
\tl_new:N \l__acro_long_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
\tl_new:N \l__acro_first_between_tl
\tl_new:N \l__acro_citation_space_tl
@@ -133,14 +137,20 @@
\prop_new:N \l__acro_replace_plural_prop
\prop_new:N \l__acro_short_plural_prop
\prop_new:N \l__acro_long_plural_prop
+\prop_new:N \l__acro_long_pre_prop
+\prop_new:N \l__acro_long_post_prop
\prop_new:N \l__acro_extra_prop
\prop_new:N \l__acro_format_prop
+\prop_new:N \l__acro_long_format_prop
\prop_new:N \l__acro_citation_prop
\prop_new:N \l__acro_citation_pre_prop
\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
+\prop_new:N \l__acro_index_prop
+\prop_new:N \l__acro_index_sort_prop
+\prop_new:N \l__acro_index_cmd_prop
% length variables:
\dim_new:N \l__acro_table_width_dim
@@ -148,6 +158,7 @@
\cs_new:Npn \__acro_citation_cmd:w { \cite }
\cs_new:Npn \__acro_no_break: { \tex_penalty:D \c_ten_thousand }
+\cs_new:Npn \__acro_index_cmd:n { \index }
\cs_new:Npn \__acro_first_upper_case:n #1
{ \tl_expandable_uppercase:n { \tl_head:n { #1 } } \tl_tail:n { #1 } }
@@ -185,52 +196,58 @@
% 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 ,
- sort .bool_set:N = \l__acro_sort_bool ,
- short-format .tl_set:N = \l__acro_short_format_tl ,
- long-format .code:n =
+ 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 ,
+ sort .bool_set:N = \l__acro_sort_bool ,
+ short-format .code:n =
+ \tl_set:Nn \l__acro_short_format_tl { #1 }
+ \tl_set:Nn \l__acro_list_short_format_tl { #1 } ,
+ long-format .code:n =
\tl_set:Nn \l__acro_long_format_tl { #1 }
- \tl_set:Nn \l__acro_list_long_format_tl { #1 } ,
- list-long-format .tl_set:N = \l__acro_list_long_format_tl ,
- extra-format .tl_set:N = \l__acro_extra_format_tl ,
- single .bool_set:N = \l__acro_use_single_bool ,
- first-style .tl_set:N = \l__acro_first_instance_tl ,
- 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 ,
- list-name .tl_set:N = \l__acro_list_name_tl ,
- list-table-width .dim_set:N = \l__acro_table_width_dim ,
- hyperref .bool_set:N = \l__acro_use_hyperref_bool ,
- only-used .bool_set:N = \l__acro_print_only_used_bool ,
- plural-ending .tl_set:N = \l__acro_default_plural_tl ,
- list-caps .bool_set:N = \l__acro_capitalize_list_bool ,
- cite .choice: ,
- cite / all .code:n =
+ \tl_set:Nn \l__acro_list_long_format_tl { #1 } ,
+ list-short-format .tl_set:N = \l__acro_list_short_format_tl ,
+ list-long-format .tl_set:N = \l__acro_list_long_format_tl ,
+ extra-format .tl_set:N = \l__acro_extra_format_tl ,
+ single .bool_set:N = \l__acro_use_single_bool ,
+ first-style .tl_set:N = \l__acro_first_instance_tl ,
+ 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 ,
+ list-name .tl_set:N = \l__acro_list_name_tl ,
+ list-table-width .dim_set:N = \l__acro_table_width_dim ,
+ hyperref .bool_set:N = \l__acro_use_hyperref_bool ,
+ only-used .bool_set:N = \l__acro_print_only_used_bool ,
+ plural-ending .tl_set:N = \l__acro_default_plural_tl ,
+ list-caps .bool_set:N = \l__acro_capitalize_list_bool ,
+ cite .choice: ,
+ cite / all .code:n =
\bool_set_true:N \l__acro_citation_all_bool
- \bool_set_true:N \l__acro_citation_first_bool ,
- cite / none .code:n =
+ \bool_set_true:N \l__acro_citation_first_bool ,
+ cite / none .code:n =
\bool_set_false:N \l__acro_citation_all_bool
- \bool_set_false:N \l__acro_citation_first_bool ,
- cite / first .code:n =
+ \bool_set_false:N \l__acro_citation_first_bool ,
+ cite / first .code:n =
\bool_set_false:N \l__acro_citation_all_bool
- \bool_set_true:N \l__acro_citation_first_bool ,
- cite-all .default:n = all ,
- cite-cmd .code:n =
- \cs_set:Npn \__acro_citation_cmd:w { #1 } ,
- cite-space .tl_set:N = \l__acro_citation_space_tl ,
- uc-cmd .code:n =
+ \bool_set_true:N \l__acro_citation_first_bool ,
+ cite-all .default:n = all ,
+ cite-cmd .code:n =
+ \cs_set:Npn \__acro_citation_cmd:w { #1 } ,
+ cite-space .tl_set:N = \l__acro_citation_space_tl ,
+ index .bool_set:N = \l__acro_addto_index_bool ,
+ index-cmd .code:n =
+ \cs_set:Npn \__acro_index_cmd:n { #1 } ,
+ uc-cmd .code:n =
\cs_set_eq:NN \__acro_first_upper_case:n #1
}
@@ -245,7 +262,7 @@
}
{ \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 }
+ { \cs_set_eq:NN \acro_record_page_number:n \use_none:n }
}
% setup command:
@@ -268,16 +285,23 @@
\cs_generate_variant:Nn \__acro_write_short:n { V }
% typeset the longform,...:
+% TODO: rethink the formatting mechanism
+% right now a custom format gets applied additionally to the global one
+% although before it
\cs_new:Npn \__acro_write_long:Nn #1#2
{
\mode_if_horizontal:F { \leavevmode }
\group_begin:
- \exp_args:Nx #1
- {
- \bool_if:NTF \l__acro_first_upper_bool
- { \exp_not:N \__acro_first_upper_case:n { \exp_not:n { #2 } } }
- { \exp_not:n { #2 } }
- }
+ \bool_if:NT \l__acro_custom_long_format_bool
+ { \l__acro_custom_long_format_tl }
+ {
+ \exp_args:Nx #1
+ {
+ \bool_if:NTF \l__acro_first_upper_bool
+ { \exp_not:N \__acro_first_upper_case:n { \exp_not:n { #2 } } }
+ { \exp_not:n { #2 } }
+ }
+ }
\group_end:
}
\cs_generate_variant:Nn \__acro_write_long:Nn { NV,No,Nf }
@@ -340,14 +364,19 @@
\bool_new:N \l__acro_first_use_brackets_bool
\bool_new:N \l__acro_first_only_short_bool
\bool_new:N \l__acro_first_reversed_bool
+\bool_new:N \l__acro_use_note_bool
+
\tl_new:N \l__acro_first_brackets_tl
+\cs_new:Npn \__acro_note_command:n #1 { #1 }
+
% #1: id
% #2: short
% #3: long
\DeclareObjectType { acro-first } { 3 }
-\DeclareTemplateInterface { acro-first } { text } { 3 }
+% template for inline appearance:
+\DeclareTemplateInterface { acro-first } { inline } { 3 }
{
brackets : boolean = true ,
brackets-type : tokenlist = () ,
@@ -355,7 +384,7 @@
reversed : boolean = false ,
between : tokenlist ,
}
-\DeclareTemplateCode { acro-first } { text } { 3 }
+\DeclareTemplateCode { acro-first } { inline } { 3 }
{
brackets = \l__acro_first_use_brackets_bool ,
brackets-type = \l__acro_first_brackets_tl ,
@@ -375,12 +404,15 @@
\tl_use:N \c_space_tl
}
}
- \bool_if:nT { \l__acro_first_use_brackets_bool && !\l__acro_first_reversed_bool }
+ \bool_if:nT
+ { \l__acro_first_use_brackets_bool && !\l__acro_first_reversed_bool }
{ \tl_head:N \l__acro_first_brackets_tl }
\__acro_acc_supp:nn { #1 } { \__acro_write_short:n { #2 } }
- \bool_if:nT { \l__acro_first_use_brackets_bool && !\l__acro_first_reversed_bool }
+ \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 }
+ \bool_if:nT
+ { !\l__acro_first_only_short_bool && \l__acro_first_reversed_bool }
{
\tl_if_blank:VF \l__acro_first_between_tl
{
@@ -388,39 +420,88 @@
\tl_use:N \l__acro_first_between_tl
}
\tl_use:N \c_space_tl
- \bool_if:nT { \l__acro_first_use_brackets_bool && \l__acro_first_reversed_bool }
+ \bool_if:nT
+ { \l__acro_first_use_brackets_bool && \l__acro_first_reversed_bool }
{ \tl_head:N \l__acro_first_brackets_tl }
\__acro_write_long:No \l__acro_long_format_tl { #3 }
- \bool_if:nT { \l__acro_first_use_brackets_bool && \l__acro_first_reversed_bool }
+ \bool_if:nT
+ { \l__acro_first_use_brackets_bool && \l__acro_first_reversed_bool }
{ \tl_tail:N \l__acro_first_brackets_tl }
}
- \__acro_cite_if:Nn \l__acro_citation_first_bool { #1 }
+ \acro_after:n { #1 }
+ }
+
+% template for footnotes, sidenotes, ...
+\DeclareTemplateInterface { acro-first } { note } { 3 }
+ {
+ use-note : boolean = true ,
+ note-command : function 1 = \footnote { #1 }
}
-\DeclareTemplateInterface { acro-first } { footnote } { 3 } { }
-\DeclareTemplateCode { acro-first } { footnote } { 3 } { }
+\DeclareTemplateCode { acro-first } { note } { 3 }
+ {
+ use-note = \l__acro_use_note_bool ,
+ note-command = \__acro_note_command:n
+ }
{
\AssignTemplateKeys
\__acro_acc_supp:nn { #1 } { \__acro_write_short:n { #2 } }
- \footnote
+ \bool_if:NT \l__acro_use_note_bool
{
- \__acro_write_long:No \l__acro_long_format_tl { #3 }
- \__acro_cite_if:Nn \l__acro_citation_first_bool { #1 }
- }
+ \__acro_note_command:n
+ {
+ \__acro_write_long:No \l__acro_long_format_tl { #3 }
+ \__acro_cite_if:Nn \l__acro_citation_first_bool { #1 }
+ }
+ }
}
% the different styles:
-\DeclareInstance { acro-first } { default } { text } { }
-\DeclareInstance { acro-first } { square } { text }
+\DeclareInstance { acro-first }
+ { default }
+ { inline }
+ { }
+\DeclareInstance { acro-first }
+ { square }
+ { inline }
{ brackets-type = [] }
-\DeclareInstance { acro-first } { plain } { text }
- { brackets = false , between = -- }
-\DeclareInstance { acro-first } { plain-reversed } { text }
- { brackets = false , between = -- , reversed = true }
-\DeclareInstance { acro-first } { footnote } { footnote } { }
-\DeclareInstance { acro-first } { short } { text }
- { only-short = true , brackets = false }
-\DeclareInstance { acro-first } { reversed } { text }
+\DeclareInstance { acro-first }
+ { plain }
+ { inline }
+ {
+ brackets = false ,
+ between = --
+ }
+\DeclareInstance { acro-first }
+ { plain-reversed }
+ { inline }
+ {
+ brackets = false ,
+ between = -- ,
+ reversed = true
+ }
+\DeclareInstance { acro-first }
+ { footnote }
+ { note }
+ { }
+\DeclareInstance { acro-first }
+ { sidenote }
+ { note }
+ { note-command = \sidenote { #1 } }
+\DeclareInstance { acro-first }
+ { empty }
+ { note }
+ { use-note = false }
+\DeclareInstance { acro-first }
+ { short }
+ { inline }
+ {
+ only-short = true ,
+ brackets = false
+ }
+\DeclareInstance { acro-first }
+ { reversed }
+ { inline }
{ reversed = true }
% --------------------------------------------------------------------------
@@ -535,7 +616,7 @@
}
\cs_generate_variant:Nn \__acro_convert_to_arabic:n { V }
-\cs_new:Npn \__acro_record_page_number:n #1
+\cs_new:Npn \acro_record_page_number:n #1
{
\seq_if_empty:cTF { g__acro_#1_pages_seq }
{% no pages recorded, yet
@@ -779,6 +860,10 @@
{ name-format = \section { #1 } }
\DeclareInstance { acro-title } { subsection } { sectioning }
{ name-format = \subsection { #1 } }
+\DeclareInstance { acro-title } { addchap } { sectioning }
+ { name-format = \addchap { #1 } }
+\DeclareInstance { acro-title } { addsec } { sectioning }
+ { name-format = \addsec { #1 } }
% --------------------------------------------------------------------------
% outputting the whole list
@@ -879,7 +964,11 @@
[
\acro_hyper_target:nn
{ ##1 }
- { \__acro_acc_supp:nn { ##1 } { \__acro_write_short:n { ##2 } } }
+ {
+ \__acro_acc_supp:nn
+ { ##1 }
+ { \__acro_write_short:n { \l__acro_list_short_format_tl { ##2 } } }
+ }
]
}
\cs_set:Npn \acro_print_list_long:n ##1
@@ -928,7 +1017,11 @@
{
\acro_hyper_target:nn
{ ##1 }
- { \__acro_acc_supp:nn { ##1 } { \__acro_write_short:n { ##2 } } }
+ {
+ \__acro_acc_supp:nn
+ { ##1 }
+ { \__acro_write_short:n { \l__acro_list_short_format_tl { ##2 } } }
+ }
&
}
\cs_set:Npn \acro_print_list_long:n ##1
@@ -975,7 +1068,11 @@
{
\acro_hyper_target:nn
{ ##1 }
- { \__acro_acc_supp:nn { ##1 } { \__acro_write_short:n { ##2 } } }
+ {
+ \__acro_acc_supp:nn
+ { ##1 }
+ { \__acro_write_short:n { \l__acro_list_short_format_tl { ##2 } } }
+ }
&
}
\cs_set:Npn \acro_print_list_long:n ##1
@@ -1078,14 +1175,13 @@
{
% get the acronym and the plural settings:
\acro_get:n { #1 }
- \acro_set_plural:n { #1 }
\acro_is_used:nTF { #1 }
{
% this is not the first time
\__acro_acc_supp:nn
{ #1 }
{ \__acro_write_short:V \l__acro_short_tl }
- \__acro_cite_if:Nn \l__acro_citation_all_bool { #1 }
+ \acro_after:n { #1 }
}
{
% this is the first time
@@ -1127,24 +1223,29 @@
\__acro_make_link:nNN { #1 } \l__acro_short_tl \l__acro_tmpa_tl
\prop_get:NnN \l__acro_short_plural_prop { #1 } \l__acro_short_plural_tl
\prop_get:NnN \l__acro_long_prop { #1 } \l__acro_long_tl
+ \prop_get:NnNTF \l__acro_long_format_prop { #1 } \l__acro_custom_long_format_tl
+ { \bool_set_true:N \l__acro_custom_long_format_bool }
+ { \bool_set_false:N \l__acro_custom_long_format_bool }
+ \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 }
\prop_get:NnN \l__acro_alt_prop { #1 } \l__acro_tmpb_tl
\__acro_make_link:nNN { #1 } \l__acro_alt_tl \l__acro_tmpb_tl
\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 }
+ \__acro_set_plural:n { #1 }
+ \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 }
}
\cs_generate_variant:Nn \tl_put_right:Nn { NV }
-\cs_new:Npn \acro_set_plural:n #1
+\cs_new:Npn \__acro_set_plural:n #1
{
\bool_if:NT \l__acro_use_plural_bool
{
\bool_if:nTF { \prop_get:Nn \l__acro_replace_plural_prop { #1 } }
- {
- \prop_get:NnN \l__acro_short_plural_prop { #1 } \l__acro_alt_tl
- \prop_get:NnN \l__acro_long_plural_prop { #1 } \l__acro_long_tl
- }
+ { \prop_get:NnN \l__acro_long_plural_prop { #1 } \l__acro_long_tl }
{
\tl_put_right:Nn \l__acro_long_tl
{ \prop_get:Nn \l__acro_long_plural_prop { #1 } }
@@ -1197,51 +1298,53 @@
}
% --------------------------------------------------------------------------
+\cs_new:Npn \acro_after:n #1
+ {
+ \__acro_cite_if:Nn \l__acro_citation_all_bool { #1 }
+ \__acro_index_if:Nn \l__acro_addto_index_bool { #1 }
+ }
+
% the standard internals:
\cs_new:Npn \acro_short:n #1
{
\acro_get:n { #1 }
- \acro_set_plural:n { #1 }
\acro_is_used:n { #1 }
\__acro_is_single:nT { #1 }
{ \cs_set_eq:NN \acro_hyper_link:nn \use_ii:nn }
\__acro_acc_supp:nn
{ #1 }
{ \__acro_write_short:V \l__acro_short_tl }
- \__acro_cite_if:Nn \l__acro_citation_all_bool { #1 }
+ \acro_after:n { #1 }
}
% get alternative entry:
\cs_new:Npn \acro_alt:n #1
{
\acro_get:n { #1 }
- \acro_set_plural:n { #1 }
\acro_is_used:n { #1 }
\__acro_is_single:nT { #1 }
{ \cs_set_eq:NN \acro_hyper_link:nn \use_ii:nn }
\__acro_acc_supp:nn
{ #1 }
{ \__acro_write_short:V \l__acro_alt_tl }
- \__acro_cite_if:Nn \l__acro_citation_all_bool { #1 }
+ \acro_after:n { #1 }
}
% get long entry:
\cs_new:Npn \acro_long:n #1
{
\acro_get:n { #1 }
- \acro_set_plural:n { #1 }
\acro_is_used:n { #1 }
\__acro_is_single:nT { #1 }
{ \cs_set_eq:NN \acro_hyper_link:nn \use_ii:nn }
\__acro_write_long:NV \l__acro_long_format_tl \l__acro_long_tl
- \__acro_cite_if:Nn \l__acro_citation_all_bool { #1 }
+ \acro_after:n { #1 }
}
% output like the first time:
\cs_new:Npn \acro_first:n #1
{
\acro_get:n { #1 }
- \acro_set_plural:n { #1 }
\acro_is_used:n { #1 }
\__acro_is_single:nT { #1 }
{ \cs_set_eq:NN \acro_hyper_link:nn \use_ii:nn }
@@ -1251,6 +1354,8 @@
{ \l__acro_long_tl }
}
+% ----------------------------------------------------------------------------
+% citations:
% #1 pre
% #2 post
% #3 key
@@ -1284,6 +1389,48 @@
}
}
+% ----------------------------------------------------------------------------
+% indexing:
+\cs_new:Npn \__acro_index_if:Nn #1#2
+ {
+ \bool_if:nT { #1 && \l__acro_mark_as_used_bool }
+ {
+ \prop_get:NnN \l__acro_index_cmd_prop { #2 } \l__acro_tmpa_tl
+ \prop_get:NnN \l__acro_index_sort_prop { #2 } \l__acro_tmpb_tl
+ \prop_get:NnN \l__acro_index_prop { #2 } \l__acro_tmpc_tl
+ \__acro_index:VnVV
+ \l__acro_tmpa_tl
+ { #2 }
+ \l__acro_tmpb_tl
+ \l__acro_tmpc_tl
+ }
+ }
+
+% #1: cmd
+% #2: key
+% #3: sort
+% #4: replace
+\cs_new:Npn \__acro_index:nnnn #1#2#3#4
+ {
+ \prop_get:NnN \l__acro_short_prop { #2 } \l__acro_tmpa_tl
+ \prop_get:NnN \l__acro_format_prop { #2 } \l__acro_tmpb_tl
+ \quark_if_no_value:VTF \l__acro_tmpb_tl
+ { \tl_set:Nn \l__acro_tmpc_tl { \l__acro_short_format_tl \l__acro_tmpa_tl } }
+ { \tl_set:Nn \l__acro_tmpc_tl { \l__acro_tmpb_tl \l__acro_tmpa_tl } }
+ \quark_if_no_value:nF { #1 }
+ { \cs_set:Npn \__acro_index_cmd:n { #1 } }
+ \quark_if_no_value:nTF { #4 }
+ {
+ \quark_if_no_value:nTF { #3 }
+ { \__acro_index_cmd:n { #2 @ { \l__acro_tmpc_tl } } }
+ { \__acro_index_cmd:n { #3 @ { \l__acro_tmpc_tl } } }
+ }
+ { \__acro_index_cmd:n { #4 } }
+ }
+\cs_generate_variant:Nn \__acro_index:nnnn { VnVV }
+\cs_generate_variant:Nn \quark_if_no_value:nTF { V }
+
+% ----------------------------------------------------------------------------
% accessability support
\tl_new:N \l__acro_acc_supp_tl
\cs_new_eq:NN \__acro_acc_supp:nn \use_ii:nn
@@ -1359,13 +1506,12 @@
\cs_new:Npn \acro@print@list
{ \cs_if_exist:NF \acro@printed@list { \cs_new:Npn \acro@printed@list {} } }
-
\cs_new:Npn \acro_use_if:nn #1#2
{
\IfBooleanTF { #1 }
{ \bool_set_false:N \l__acro_mark_as_used_bool }
{
- \__acro_record_page_number:n { #2 }
+ \acro_record_page_number:n { #2 }
\bool_set_true:N \l__acro_mark_as_used_bool
}
}
@@ -1708,10 +1854,21 @@
`pages-name', `record-pages'
- no automatic label placement for page number referencing
any more
+2013/01/26 v1.1 - bug fix in the plural detection
+ - new keys `long-pre' and `long-post'
+ - new keys `index', `index-sort' and `index-cmd'
+ - new options `index' and `index-cmd'
+2013/01/29 v1.1a - added `long-format' key
+ - renamed `format' key into `short-format', kept `format' for
+ compatibility reasons
% --------------------------------------------------------------------------
% TODO:
- Option `totoc'!?
+- Optionen `list-header = addsec|addchap' (acro-title instance)
+- acro-first instance `none', die nur die Kurzform verwendet
+- Option `list-short-format'
+
- 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
diff --git a/Master/texmf-dist/tex/latex/acro/acro1.def b/Master/texmf-dist/tex/latex/acro/acro1.def
index 21d4e83fa92..f585cadbf5d 100644
--- a/Master/texmf-dist/tex/latex/acro/acro1.def
+++ b/Master/texmf-dist/tex/latex/acro/acro1.def
@@ -51,26 +51,33 @@
{ 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
+\msg_new:nnnn { acro } { doubled-key }
+ { It~seems~to~me~you~have~used~the~`#1'~key~before. }
+ {
+ It~seems~to~me~you~have~used~the~`#1'~key~before.~If~you~haven't~there's~
+ something~different~wrong~and~I'm~lost.~You~'re~on~your~own~now.
+ }
+
\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 }
+ \bool_if:cF { l__acro_#1_short_set_bool }
{ \msg_error:nnxx { acro } { before-short } { #1 } { #2 } }
+ \bool_new:c { l__acro_#1_#2_set_bool }
+ \bool_set_true:c { l__acro_#1_#2_set_bool }
}
\cs_new:Npn \__acro_first_key_check:n #1
{
- \cs_if_exist:cTF { l__acro_short_#1_set_bool }
+ \cs_if_exist:cTF { l__acro_#1_short_set_bool }
{
- \bool_if:cTF { l__acro_short_#1_set_bool }
- {}
- { \bool_set_true:c { l__acro_short_#1_set_bool } }
+ \bool_if:cT { l__acro_#1_short_set_bool }
+ { \msg_error:nnx { acro } { doubled-key } { #1 } }
}
- {% error: key already used
+ {
+ \bool_new:c { l__acro_#1_short_set_bool }
+ \bool_set_true:c { l__acro_#1_short_set_bool }
}
}
@@ -79,12 +86,12 @@
% 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_prop { #1 } { #2 }
+ \prop_put:Nnn \l__acro_sort_prop { #1 } { #1 }
+ \prop_put:Nnn \l__acro_index_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
@@ -103,12 +110,13 @@
\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 }
+ \bool_if:cF { l__acro_#1_long-plural_set_bool }
+ {
+ \prop_put:Nnn \l__acro_long_plural_prop
+ { #1 } { \l__acro_default_plural_tl }
+ }
}
\cs_generate_variant:Nn \__acro_declare_long:nn { V }
@@ -130,11 +138,29 @@
}
\cs_generate_variant:Nn \__acro_declare_long_plural_form:nn { V }
+% pre long:
+\cs_new:Npn \__acro_declare_long_pre:nn #1#2
+ {
+ \__acro_key_check:nn { #1 } { long-pre }
+ \prop_put:Nnn \l__acro_long_pre_prop { #1 } { #2 }
+ }
+\cs_generate_variant:Nn \__acro_declare_long_pre:nn { V }
+
+% post long:
+\cs_new:Npn \__acro_declare_long_post:nn #1#2
+ {
+ \__acro_key_check:nn { #1 } { long-post }
+ \prop_put:Nnn \l__acro_long_post_prop { #1 } { #2 }
+ }
+\cs_generate_variant:Nn \__acro_declare_long_post: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 }
+ \bool_if:cF { l__acro_#1_index-sort_set_bool }
+ { \prop_put:Nnn \l__acro_index_sort_prop { #1 } { #2 } }
}
\cs_generate_variant:Nn \__acro_declare_sort:nn { V }
@@ -154,6 +180,14 @@
}
\cs_generate_variant:Nn \__acro_declare_format:nn { V }
+% format:
+\cs_new:Npn \__acro_declare_long_format:nn #1#2
+ {
+ \__acro_key_check:nn { #1 } { long-format }
+ \prop_put:Nnn \l__acro_long_format_prop { #1 } { #2 }
+ }
+\cs_generate_variant:Nn \__acro_declare_long_format:nn { V }
+
% pdfstring:
\cs_new:Npn \__acro_declare_pdfstring:nw #1#2/#3/#4 \acro_stop:
{
@@ -169,6 +203,7 @@
{ #1 } { \exp_not:n { #2#3 } }
}
}
+\cs_generate_variant:Nn \__acro_declare_pdfstring:nw { V }
% class:
\cs_new:Npn \__acro_declare_class:nn #1#2
@@ -211,9 +246,11 @@
}
}
}
+\cs_generate_variant:Nn \__acro_declare_citation:nw { V }
\cs_new:Npn \__acro_declare_citation_aux:nnnn #1#2#3#4
{
+ \__acro_key_check:nn { #1 } { cite }
\prop_put:Nnn \l__acro_citation_prop { #1 } { #4 }
\tl_if_empty:nF { #2 }
{ \prop_put:Nnn \l__acro_citation_pre_prop { #1 } { #2 } }
@@ -221,6 +258,42 @@
{ \prop_put:Nnn \l__acro_citation_post_prop { #1 } { #3 } }
}
+% TODO:
+% add index entries, by default \index{<sort>@<short>}
+% index: overwrite default <sort>@<short> entry completely
+% index-sort: overwrite the <sort> part of <sort>@<short> entry
+
+% need to take care of custom index cmd, at least
+% - \index{}
+% - \index[]{}
+% question is, though, if it should be the same one for all acronyms?
+% I go for yes but would also add a `post' key that allows to add arbitrary
+% TeX code after an acronym is typeset
+
+% index:
+\cs_new:Npn \__acro_declare_index:nn #1#2
+ {
+ \__acro_key_check:nn { #1 } { index }
+ \prop_put:Nnn \l__acro_index_prop { #1 } { #2 }
+ }
+\cs_generate_variant:Nn \__acro_declare_index:nn { V }
+
+% index-sort:
+\cs_new:Npn \__acro_declare_index_sort:nn #1#2
+ {
+ \__acro_key_check:nn { #1 } { index-sort }
+ \prop_put:Nnn \l__acro_index_sort_prop { #1 } { #2 }
+ }
+\cs_generate_variant:Nn \__acro_declare_index_sort:nn { V }
+
+% index-cmd:
+\cs_new:Npn \__acro_declare_index_cmd:nn #1#2
+ {
+ \__acro_key_check:nn { #1 } { index-cmd }
+ \prop_put:Nnn \l__acro_index_cmd_prop { #1 } { #2 }
+ }
+\cs_generate_variant:Nn \__acro_declare_index_cmd:nn { V }
+
% --------------------------------------------------------------------------
% the keys of \DeclareAcronym
\keys_define:nn { acro / declare-acronym }
@@ -237,22 +310,34 @@
\__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 } ,
+ long-pre .code:n =
+ \__acro_declare_long_pre:Vn \l__acro_current_key_tl { #1 } ,
+ long-post .code:n =
+ \__acro_declare_long_post: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 } ,
+ short-format .code:n =
+ \__acro_declare_format:Vn \l__acro_current_key_tl { #1 } ,
+ long-format .code:n =
+ \__acro_declare_long_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: ,
+ \__acro_declare_citation:Vw \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: ,
+ \__acro_declare_pdfstring:Vw \l__acro_current_key_tl #1 // \acro_stop: ,
accsupp .code:n =
- \__acro_declare_acc_supp:Vn \l__acro_current_key_tl { #1 }
+ \__acro_declare_acc_supp:Vn \l__acro_current_key_tl { #1 } ,
+ index .code:n =
+ \__acro_declare_index:Vn \l__acro_current_key_tl { #1 } ,
+ index-sort .code:n =
+ \__acro_declare_index_sort:Vn \l__acro_current_key_tl { #1 } ,
+ index-cmd .code:n =
+ \__acro_declare_index_cmd:Vn \l__acro_current_key_tl { #1 }
}
\cs_new:Npn \acro_define_acronym_macro:n #1
@@ -279,9 +364,9 @@
\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 }
+ \bool_if:cF { l__acro_#1_short_set_bool }
{ \msg_error:nnxx { acro } { missing } { #1 } { short } }
- \bool_if:cF { l__acro_long_#1_set_bool }
+ \bool_if:cF { l__acro_#1_long_set_bool }
{ \msg_error:nnxx { acro } { missing } { #1 } { long } }
}