From 59a2808eabd4143077ca245bb4b699094c8341a5 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sun, 8 Nov 2020 21:40:47 +0000 Subject: acro (8nov20) git-svn-id: svn://tug.org/texlive/trunk@56884 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/acro/README | 2 +- Master/texmf-dist/doc/latex/acro/acro-manual.pdf | Bin 879954 -> 865976 bytes Master/texmf-dist/doc/latex/acro/acro-manual.tex | 40 ++++++- Master/texmf-dist/tex/latex/acro/acro.sty | 134 ++++++++++++++++------- Master/texmf-dist/tex/latex/acro/acro2.sty | 2 + 5 files changed, 136 insertions(+), 42 deletions(-) diff --git a/Master/texmf-dist/doc/latex/acro/README b/Master/texmf-dist/doc/latex/acro/README index 1cfc035d626..abe9d6dbcee 100644 --- a/Master/texmf-dist/doc/latex/acro/README +++ b/Master/texmf-dist/doc/latex/acro/README @@ -1,5 +1,5 @@ -------------------------------------------------------------------------- -the ACRO package v3.2 2020/05/10 +the ACRO package v3.2a 2020/11/08 Typeset Acronyms diff --git a/Master/texmf-dist/doc/latex/acro/acro-manual.pdf b/Master/texmf-dist/doc/latex/acro/acro-manual.pdf index 90a739e61c9..63d5b8d77ee 100644 Binary files a/Master/texmf-dist/doc/latex/acro/acro-manual.pdf and b/Master/texmf-dist/doc/latex/acro/acro-manual.pdf differ diff --git a/Master/texmf-dist/doc/latex/acro/acro-manual.tex b/Master/texmf-dist/doc/latex/acro/acro-manual.tex index 1d21678c63e..49ea2727da0 100644 --- a/Master/texmf-dist/doc/latex/acro/acro-manual.tex +++ b/Master/texmf-dist/doc/latex/acro/acro-manual.tex @@ -641,7 +641,7 @@ The usage should be clear. Let's assume you have defined an acronym long-indefinite = an } \end{sourcecode} -Then typical outputs look like this: +The typical outputs look like this: \begin{example} \ac{ufo} \\ \iac{ufo} \\ @@ -1724,6 +1724,44 @@ shown in table~\vref{tab:translations}. \label{tab:translations} \end{table} +\section{Patches}\label{sec:patches} +In several situations it can lead to wrong results if \acro\ marks an acronym +as used too early or at all. This is why it is possible to disable the +mechanism which is responsible: +\begin{commands} + \command{acswitchoff} + This disables the mechanism which marks acronyms as used. After this + command every acronym command like \cs{ac} acts like its starred version. + \command{acswitchon} + This command enables the mechanism again. +\end{commands} + +In certain circumstances \acro\ uses these commands itself. For example it is +often preferable that acronyms are not counted as used in floats, the table of +contents or the lists of figures and tables. This is why \acro\ turns the +mechanism off in these places. + +Certain table environments typeset their contents twice for measurement +purposes. \acro\ tries to disable the usage mechanism during these phases. +The same is true for single line captions from the \pkg{caption} package. + +All these patches can be turned off: +\begin{options} + \keybool{floats}\Module{patch}\Default{true} + En-/disable the \option{floats} patch. + \keybool{lists}\Module{patch}\Default{true} + En-/disable the \option{lists} patch for the table of contents, the list + of figures and the list of tables. + \keybool{tabularx}\Module{patch}\Default{true} + En-/disable the \option{tabularx} patch. + \keybool{ltxtable}\Module{patch}\Default{true} + En-/disable the \option{ltxtable} patch. + \keybool{tabu}\Module{patch}\Default{true} + En-/disable the \option{tabu} patch. + \keybool{caption}\Module{patch}\Default{true} + En-/disable the \option{caption} patch. +\end{options} + \part{Extending \acro}\label{part:extending-acro} \section{Background}\label{sec:background} \subsection{Templates} diff --git a/Master/texmf-dist/tex/latex/acro/acro.sty b/Master/texmf-dist/tex/latex/acro/acro.sty index d272acdc82e..1e1bfb4baaf 100644 --- a/Master/texmf-dist/tex/latex/acro/acro.sty +++ b/Master/texmf-dist/tex/latex/acro/acro.sty @@ -27,10 +27,10 @@ % setup package: \tl_const:Nn \c_acro_package_name_tl {acro} -\tl_const:Nn \c_acro_date_tl {2020/05/10} +\tl_const:Nn \c_acro_date_tl {2020/11/08} \tl_const:Nn \c_acro_version_major_number_tl {3} \tl_const:Nn \c_acro_version_minor_number_tl {2} -\tl_const:Nn \c_acro_version_subrelease_tl {} +\tl_const:Nn \c_acro_version_subrelease_tl {a} \tl_const:Nx \c_acro_version_number_tl { \c_acro_version_major_number_tl . @@ -295,7 +295,7 @@ \cs_new_protected:Npn \__acro_module_load:n #1 { - \acro_if_module_loaded:nF {#1} + \acro_module_if_loaded:nF {#1} { \acro_module_if_exist:nTF {#1} { @@ -311,7 +311,7 @@ } \cs_generate_variant:Nn \__acro_module_load:n {V} -\prg_new_conditional:Npnn \acro_if_module_loaded:n #1 {p,T,F,TF} +\prg_new_conditional:Npnn \acro_module_if_loaded:n #1 {p,T,F,TF} { \tl_if_in:NnTF \g__acro_modules_loaded_tl {#1} { \prg_return_true: } @@ -332,7 +332,7 @@ % #2: code \cs_new_protected:Npn \acro_module_after:nn #1#2 { - \acro_if_module_loaded:nTF {#1} + \acro_module_if_loaded:nTF {#1} {#2} { \__acro_add_to_module_hook:nnn {#1} {after} {#2} } } @@ -342,7 +342,7 @@ \cs_new_protected:Npn \acro_module_before:nn #1#2 { % TODO: error in T case? - \acro_if_module_loaded:nF {#1} + \acro_module_if_loaded:nF {#1} { \__acro_add_to_module_hook:nnn {#1} {before} {#2} } } @@ -351,7 +351,7 @@ % #3: code \cs_new_protected:Npn \__acro_add_to_module_hook:nnn #1#2#3 { - \acro_if_module_loaded:nF {#1} + \acro_module_if_loaded:nF {#1} { \tl_if_exist:cF {g__acro_module_hook_#1_#2_tl} { \tl_new:c {g__acro_module_hook_#1_#2_tl} } @@ -1857,7 +1857,7 @@ } \cs_new_protected:Npn \acro_use:n #1 - { \clist_map_inline:nn {#1} { \__acro_use:n {#1} } } + { \clist_map_inline:nn {#1} { \__acro_use:n {##1} } } \cs_generate_variant:Nn \acro_use:n {e} \cs_new_protected:Npn \acro_use_all: @@ -1866,10 +1866,10 @@ \cs_new_protected:Npn \__acro_reset:n #1 { \acro_property_set:nnn {#1} {used} {false} - \int_gzero:c {g__acro_ \acro_case_insensitive:n {#1} _int} - \int_compare:nNnF - { \acro_property_get:nn {#1} {usage} } > 0 - { \acro_property_set:nnn {#1} {usage} {0} } + % \int_gzero:c {g__acro_ \acro_case_insensitive:n {#1} _int} + % \int_compare:nNnF + % { \acro_property_get:nn {#1} {usage} } > 0 + % { \acro_property_set:nnn {#1} {usage} {0} } } \cs_new_protected:Npn \acro_reset:n #1 @@ -2748,6 +2748,7 @@ { \g_acro_barrier_int } } } +\cs_generate_variant:Nn \acro_barrier_usage:n {V} % #1: id \cs_new_protected:Npn \acro_set_barriers:n #1 @@ -2940,8 +2941,11 @@ % #1: id % #2: property -\cs_new:Npn \__acro_write_acronym:nn #1#2 +\cs_new_protected:Npn \__acro_write_acronym:nn #1#2 { + \__acro_upper:n { \__acro_article:nn {#1} {#2} } + \bool_if:NT \l__acro_article_bool + { \bool_set_false:N \l__acro_upper_bool } \bool_lazy_and:nnTF { \acro_property_if_eq_p:nn {#2} {long} } { \acro_if_first_p:n {#1} } @@ -2950,7 +2954,6 @@ { \__acro_upper:n { - \__acro_article:nn {#1} {#2} \acro_if_ending_form:nnTF {#1} {#2} { \acro_ending_form:nn {#1} {#2} } { \acro_property_get:nn {#1} {#2} } @@ -3020,7 +3023,7 @@ \bool_if:NF \g__acro_cited_bool { \acro_cite_if:nnT {#1} {#2} { \acro_cite:n {#2} } } \bool_gset_false:N \g__acro_cited_bool - \acro_property_if_set:nnT {#1} {post} + \acro_property_if_set:nnT {#2} {post} { \acro_property_get:nn {#2} {post} } \bool_lazy_all:nT { @@ -3406,8 +3409,8 @@ { \__acro_template_add:nnn {list} {#1} { - \__acro_template_start:nn {list} {#1} \tl_clear_new:N \AcronymTable + \__acro_template_start:nn {list} {#1} #2 \__acro_template_stop:nn {list} {#1} } @@ -4728,42 +4731,89 @@ \msg_new:nnn {acro} {patch} { Patching~ `#1'~ failed.~ Please~ contact~ the~ acro~ author. } +\cs_new_protected:Npn \acro_new_patch:n #1 + { + \bool_new:c {l__acro_patch_#1_bool} + \keys_define:nn + {acro} + { + patch / #1 .bool_set:c = {l__acro_patch_#1_bool} , + patch / #1 .initial:n = true + } + } + +\prg_new_conditional:Npnn \acro_if_patch:n #1 {T,F,TF} + { + \cs_if_exist:cTF {l__acro_patch_#1_bool} + { + \bool_if:cTF {l__acro_patch_#1_bool} + { \prg_return_true: } + { \prg_return_false: } + } + { \prg_return_false: } + } + +\acro_new_patch:n {floats} +\acro_new_patch:n {lists} +\acro_new_patch:n {tabularx} +\acro_new_patch:n {tabu} +\acro_new_patch:n {ltxtable} +\acro_new_patch:n {caption} + \AtEndPreamble { % floats: - \apptocmd \@floatboxreset - { \acswitchoff } - {} - { \msg_error:nnn {acro} {patch} {floats} } + \acro_if_patch:nT {floats} + { + \apptocmd \@floatboxreset + { \acswitchoff } + {} + { \msg_error:nnn {acro} {patch} {floats} } + } % tables: % * tabularx - \cs_if_exist:NT \TX@trial + \acro_if_patch:nT {tabularx} { - \patchcmd \TX@trial - { \let\hbadness\@tempcnta } - { \acswitchoff\let\hbadness\@tempcnta } - {} - { \msg_error:nnn {acro} {patch} {tabularx} } + \cs_if_exist:NT \TX@trial + { + \patchcmd \TX@trial + { \let\hbadness\@tempcnta } + { \acswitchoff\let\hbadness\@tempcnta } + {} + { \msg_error:nnn {acro} {patch} {tabularx} } + } } % * ltxtable - \cs_if_exist:NT \LTXtable + \acro_if_patch:nT {ltxtable} { - \patchcmd \LTXtable - { \input } - { \acswitchoff\input } - {} - { \msg_error:nnn {acro} {patch} {ltxtable} } + \cs_if_exist:NT \LTXtable + { + \patchcmd \LTXtable + { \input } + { \acswitchoff\input } + {} + { \msg_error:nnn {acro} {patch} {ltxtable} } + } } % * tabu - \cs_if_exist:NT \tabuDisableCommands - { \tabuDisableCommands { \acswitchoff } } + \acro_if_patch:nT {tabu} + { + \cs_if_exist:NT \tabuDisableCommands + { \tabuDisableCommands { \acswitchoff } } + } % contents lists: - \addtocontents {toc} { \acswitchoff } - \addtocontents {lof} { \acswitchoff } - \addtocontents {lot} { \acswitchoff } + \acro_if_patch:nT {lists} + { + \addtocontents {toc} { \acswitchoff } + \addtocontents {lof} { \acswitchoff } + \addtocontents {lot} { \acswitchoff } + } % caption package: - \cs_if_exist:NT \caption@prepareslc - { \tl_gput_right:Nn \caption@prepareslc { \acswitchoff } } + \acro_if_patch:nT {caption} + { + \cs_if_exist:NT \caption@prepareslc + { \tl_gput_right:Nn \caption@prepareslc { \acswitchoff } } + } } \AcroModuleEnd @@ -4895,7 +4945,11 @@ } \NewAcroTemplate {long} - { \acrowrite {long} } + { + \acroifTF {single} + { \acrowrite {single} } + { \acrowrite {long} } + } \NewAcroTemplate {short} { \acrowrite {short} } diff --git a/Master/texmf-dist/tex/latex/acro/acro2.sty b/Master/texmf-dist/tex/latex/acro/acro2.sty index c8eb1d6b996..bed07791229 100644 --- a/Master/texmf-dist/tex/latex/acro/acro2.sty +++ b/Master/texmf-dist/tex/latex/acro/acro2.sty @@ -2482,6 +2482,8 @@ \cs_new_protected:Npn \acro@pages #1#2 { \tl_gset:cn {g__acro_#1_recorded_pages_tl} {#2} } +\bool_new:N \g__acro_rerun_bool + \cs_new_protected:Npn \acro@rerun@check { \bool_if:NT \g__acro_rerun_bool -- cgit v1.2.3