From 8591b56496b93eed20f638ee1ce46b11c3f7be58 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Sun, 17 Jan 2021 03:02:33 +0000 Subject: CTAN sync 202101170302 --- macros/latex/contrib/acro/README | 7 +- macros/latex/contrib/acro/acro-examples.sty | 166 +++++++++++++ macros/latex/contrib/acro/acro-manual.pdf | Bin 884055 -> 889312 bytes macros/latex/contrib/acro/acro-manual.tex | 79 ++++++- macros/latex/contrib/acro/acro.sty | 350 ++++++++++++++++++++++------ 5 files changed, 519 insertions(+), 83 deletions(-) create mode 100644 macros/latex/contrib/acro/acro-examples.sty (limited to 'macros/latex/contrib/acro') diff --git a/macros/latex/contrib/acro/README b/macros/latex/contrib/acro/README index 8f09cc322b..b0382e1302 100644 --- a/macros/latex/contrib/acro/README +++ b/macros/latex/contrib/acro/README @@ -1,5 +1,5 @@ --------------------------------------------------------------------------- -the ACRO package v3.4 2020/12/25 +#-------------------------------------------------------------------------- +the ACRO package v3.5 2021/01/16 Typeset Acronyms @@ -8,7 +8,7 @@ Clemens Niederberger Web: https://github.com/cgnieder/acro E-Mail: contact@mychemistry.eu -------------------------------------------------------------------------- -Copyright 2012--2020 Clemens Niederberger +Copyright 2012--2021 Clemens Niederberger This work may be distributed and/or modified under the conditions of the LaTeX Project Public License, either version 1.3c @@ -26,6 +26,7 @@ The acro package consists of code files: acro.sty acro2.sty + acro-examples.sty The acro package consists of documentation files: diff --git a/macros/latex/contrib/acro/acro-examples.sty b/macros/latex/contrib/acro/acro-examples.sty new file mode 100644 index 0000000000..01fca6ada3 --- /dev/null +++ b/macros/latex/contrib/acro/acro-examples.sty @@ -0,0 +1,166 @@ +\RequirePackage{acro} +\ProvidesPackage{acro-examples}[\csname c_acro_date_tl\endcsname\space v0.1 +example definitions with acro (CN)] + +\DeclareAcronym{afaik}{ + short = AFAIK , + long = as far as I know +} +\DeclareAcronym{afk}{ + short = AFK , + long = away from keyboard +} +\DeclareAcronym{asap}{ + short = ASAP , + long = as soon as possible +} +\DeclareAcronym{ba}{ + short = BA , + long = Bachelor of Arts +} +\DeclareAcronym{bnd}{ + short = BND , + long = Bundesnachrichtendienst +} +\DeclareAcronym{bs}{ + short = BS , + long = Bachelor of Science +} +\DeclareAcronym{cd}{ + short = CD , + long = compact disc +} +\DeclareAcronym{cdu}{ + short = CDU , + long = Christlich-Demokratische Union +} +\DeclareAcronym{ceo}{ + short = CEO , + long = chief executive officer +} +\DeclareAcronym{cia}{ + short = CIA , + long = Central Intelligence Agency +} +\DeclareAcronym{csu}{ + short = CSU , + long = Christlich-Soziale Union +} +\DeclareAcronym{ctan}{ + short = CTAN , + long = Comprehensive \TeX\ Archive Network +} +\DeclareAcronym{dea}{ + short = DEA , + long = Drug Enforcement Administration +} +\DeclareAcronym{diy}{ + short = DIY , + long = do it yourself +} +\DeclareAcronym{dpa}{ + short = DPA , + long = Deutsche Presseagentur +} +\DeclareAcronym{eta}{ + short = ETA , + long = estimated time of arrival +} +\DeclareAcronym{fbi}{ + short = FBI , + long = Federal Bureau of Investigation +} +\acroifpropertyTF{ + \DeclareAcronym{hadopi}{ + short = HADOPI , + long = Haute Autorité pour la diffusion des œuvres et la protection des + droits sur l’Internet , + short-definite = l'\nospace , + long-definite = la + } +}{ + \DeclareAcronym{hadopi}{ + short = HADOPI , + long = Haute Autorité pour la diffusion des œuvres et la protection des + droits sur l’Internet + } +} +\DeclareAcronym{iirc}{ + short = IIRC , + long = if I remember correctly +} +\DeclareAcronym{imho}{ + short = IMHO , + long = in my humble opinion +} +\DeclareAcronym{jpg}{ + short = JPEG , + sort = jpeg , + alt = JPG , + long = joint photographic experts group +} +\DeclareAcronym{ksk}{ + short = KSK , + long = Kommando Spezialkräfte +} +\DeclareAcronym{lol}{ + short = LOL , + long = loughing out loud +} +\DeclareAcronym{lppl}{ + short = LPPL , + long = \unexpanded{\LaTeX} Project Public License +} +\DeclareAcronym{ma}{ + short = MA , + long = Master of Arts +} +\DeclareAcronym{nato}{ + short = NATO , + long = North Atlantic Treaty Organization +} +\DeclareAcronym{nsa}{ + short = NSA , + long = National Security Agency +} +\DeclareAcronym{omg}{ + short = OMG , + long = oh my god +} +\DeclareAcronym{otan}{ + short = OTAN , + long = Organisation du Traité de l'Atlantique Nord +} +\DeclareAcronym{pdf}{ + short = PDF , + long = portable document format +} +\DeclareAcronym{png}{ + short = PNG , + long = portable network graphics +} +\DeclareAcronym{rofl}{ + short = ROFL , + long = rolling on the floor laughing +} +\DeclareAcronym{spd}{ + short = SPD , + long = Sozialdemokratische Partei Deutschlands +} +\DeclareAcronym{tiff}{ + short = TIFF , + long = tagged image file format +} +\DeclareAcronym{ufo}{ + short = UFO , + long = unidentified flying object , + long-indefinite = an +} +\DeclareAcronym{yolo}{ + short = YOLO , + long = you only live once +} + +\endinput + +2021/01/13 - first version diff --git a/macros/latex/contrib/acro/acro-manual.pdf b/macros/latex/contrib/acro/acro-manual.pdf index 24026d28a3..54c8b151c6 100644 Binary files a/macros/latex/contrib/acro/acro-manual.pdf and b/macros/latex/contrib/acro/acro-manual.pdf differ diff --git a/macros/latex/contrib/acro/acro-manual.tex b/macros/latex/contrib/acro/acro-manual.tex index 4f2a5d2442..b8288eb6ca 100644 --- a/macros/latex/contrib/acro/acro-manual.tex +++ b/macros/latex/contrib/acro/acro-manual.tex @@ -1,3 +1,5 @@ +% arara: pdflatex +% arara: pdflatex % -------------------------------------------------------------------------- % the ACRO package % @@ -8,7 +10,7 @@ % Web: https://github.com/cgnieder/acro/ % E-Mail: contact@mychemistry.eu % -------------------------------------------------------------------------- -% Copyright 2011--2020 Clemens Niederberger +% Copyright 2011--2021 Clemens Niederberger % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3c @@ -218,7 +220,7 @@ \clearpage \part{Get started with \acro}\label{part:get-started-with} -\section{Licence and requirements}\label{sec:licence-requirements} +\section{Licence}\label{sec:licence} \license \section{Glossary} @@ -409,7 +411,7 @@ the same. In that case you can use %% sort \propval{sort}{text}\Default={short} If used the acronym will be sorted according to this property instead of - its \ac{id}. + its short form. %% tag \propval{tag}{csv list}\Default The tag(s) of an acronym. @@ -432,6 +434,11 @@ the same. In that case you can use value of the \property{sort} property. This property allows to set an individual sorting option for the index. See section~\vref{sec:indexing} for details. + %% index-cmd + \propval{index-cmd}{index command}\Default + This sets the indexing command for the acronym. If unused then the + command set by the corresponding option is used. See + section~\vref{sec:indexing} for details. \end{properties} \subsection{Properties related to plural and indefinite forms}\label{sec:prop-relat-plur} @@ -585,8 +592,32 @@ the same. In that case you can use set then the appropriate value might be derived from \property{foreign-babel}. See section~\vref{sec:fore-lang-acronyms} for details. + %% preset + \propval{preset}{set name}\Default + \sinceversion{3.5}Enables to load a set of properties that has been + defined earlier with \cs{NewAcroPreset}, siehe + section~\vref{sec:presets}. + %% uselist + \propval{uselist}{csv list of acronym ids}\Default + \sinceversion{3.5}If this property is given and all acronyms specified in + this property have been used before the first time the current acronym is + used it behaves as if it has been used before. \end{properties} +\subsection{Presets}\label{sec:presets} +\sinceversion{3.5}Sometimes it can be useful to have different kinds of +acronyms or abbreviations or similar which share a common set of properties. +Such sets can be defined with these commands: +\begin{commands} + \command{NewAcroPreset}[\marg{set name}\marg{csv list of properties}] + Defines the property set \meta{set name}. Any valid property can be set + in \meta{csv list of properties}. + \command{RenewAcroPreset}[\marg{set name}\marg{csv list of properties}] + Redefines the property set \meta{set name}. + \command{DeclareAcroPreset}[\marg{set name}\marg{csv list of properties}] + Defines or redefines the property set \meta{set name} without checking. +\end{commands} + \section{Using acronyms}\label{sec:using-acronyms} There are a number of commands to use acronyms with. Their names always follow the same pattern which should make their usage intuitive immediately. @@ -883,12 +914,18 @@ the list of acronym you can use these options: The threshold for a page range to be turned into \latin{sequentes}. A page range above the threshold is still typeset as a range: \meta{num1}--\meta{num2}. - \keyval{fill}{code}\Module{pages}\Default{\cs*{dotfill}} + \keyval{fill}{code}\Module{pages}\Default{\cs*{acrdotfill}} This is the code that is placed between acronym description and actual page numbers. \keybool{name}\Module{pages}\Default{false} If set to true the page numbers are preceded with p.\ or pp. \end{options} +\begin{commands} + \command{acrodotfill} + \sinceversion{3.5}Creates a dotted line like those in the table of + contents. If the macro \cs*{cftdotfill} is defined it is equal to + \cs*{cftdotfill}\Marg{\cs*{cftdotsep}}. +\end{commands} Additionally\sinceversion{3.3} to setting these options with \cs{acsetup} they can be set as options to \cs{printacronyms}: \begin{sourcecode} @@ -1274,7 +1311,7 @@ have no effect, of course. } \end{sourcecode} -\pagebreak +% \pagebreak There are a number of options to control the uppercasing behavior: \begin{options} @@ -1370,8 +1407,10 @@ Maybe you want to add your acronyms to an index. In that case it is probably desirable to let \acro\ make this automatically. In the simplest case just enable it: \begin{options} - \keybool{use}\Module{index}\Default{false} - Enable indexing. + \keychoice{use}{\default{true},false,indexed}\Module{index}\Default{false} + \changedversion{3.5}Enable indexing. If \code{indexed} is chosen only the + acronyms for which the property \property{index} has been set are indexed. + With \code{true} \emph{all} acronyms are indexed. \keyval{cmd}{index command}\Module{index}\Default{\cs*{index}} Choose a command for indexing. \keyval{disable}{code}\Module{index}\Default{\cs*{def}\cs*{@}\{\}} @@ -1568,6 +1607,10 @@ option: \keybool{make-links}\Default{false} If this is activated then every short or alternative appearance of an acronym will be linked to its description in the list of acronyms. + \keybool{link-only-first}\Default{false} + \sinceversion{3.5}If this is activated in addition to \option{make-links} + then \emph{only the first} short or alternative appearance of an acronym + will be linked to its description in the list of acronyms. \end{options} \begin{bewareofthedog} This will fail miserably together with local lists if an acronym appears in @@ -1883,7 +1926,7 @@ to defines own such objects: page ranges. \end{templates} -\subsubsection{Header templates} +\subsubsection{Heading templates} \begin{templates} \tmpl{addchap} Only defined in a \KOMAScript\ class and if \cs*{chapter} is defined. Uses @@ -1985,9 +2028,22 @@ and \cs*{acroifF} each have an argument less than \cs*{acroifTF}. \command{acroiftag\TF}[\marg{tag}\marg{true}\marg{false}] Checks if the current acronym has been given the tag \meta{tag} and either leaves \meta{true} or \meta{false} in the input stream. + \command{acroifstarred\TF}[\marg{true}\marg{false}] + \sinceversion{3.5}Checks if the current call of the acronym is a starred + command or not and either leaves \meta{true} or \meta{false} in the input + stream. \command{AcroPropertiesMap}[\marg{code}] Maps over all defined acronym properties. Within \meta{code} you can refer to the current property with \code{\#1}. + \command{AcroAcronymsMap}[\marg{code}] + \sinceversion{3.5}Maps over all defined acronyms. Within \meta{code} you + can refer to the current property with \code{\#1} or with \cs{AcronymID}. + \command{AcroMapBreak} + \sinceversion{3.5}Stops the map \cs{AcroAcronymsMap} and is usually used + in combination with a boolean check. + \command{AcroPropertiesSet}[\marg{id}\marg{csv list of properties}] + \sinceversion{3.5}Allows the setting of properties of acronym \meta{id} + outside of \cs{declareAcronym}. \end{commands} \subsubsection{Commands for usage in acronym templates} @@ -2173,6 +2229,13 @@ first the table body is built and only then the table itself is printed: \end{sourcecode} \subsection{New heading templates}\label{sec:new-head-templ} +Let's take a look at the two templates \template{section} and +\template{section*} which should give you enough information to build your +own: +\begin{sourcecode} + \NewAcroTemplate[heading]{section} {\section {\acrolistname}} + \NewAcroTemplate[heading]{section*}{\section*{\acrolistname}} +\end{sourcecode} \section{Endings}\label{sec:endings} Referring to section~\vref{sec:other-endings} this section explains how to diff --git a/macros/latex/contrib/acro/acro.sty b/macros/latex/contrib/acro/acro.sty index 8efd343d1d..cfa5193f85 100644 --- a/macros/latex/contrib/acro/acro.sty +++ b/macros/latex/contrib/acro/acro.sty @@ -8,7 +8,7 @@ % Web: https://github.com/cgnieder/acro/ % E-Mail: contact@mychemistry.eu % -------------------------------------------------------------------------- -% Copyright 2011--2020 Clemens Niederberger +% Copyright 2011--2021 Clemens Niederberger % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3c @@ -22,14 +22,14 @@ % % The Current Maintainer of this work is Clemens Niederberger. % -------------------------------------------------------------------------- -\RequirePackage{l3keys2e} +\RequirePackage {l3keys2e} \ExplSyntaxOn % setup package: \tl_const:Nn \c_acro_package_name_tl {acro} -\tl_const:Nn \c_acro_date_tl {2020/12/25} +\tl_const:Nn \c_acro_date_tl {2021/01/16} \tl_const:Nn \c_acro_version_major_number_tl {3} -\tl_const:Nn \c_acro_version_minor_number_tl {4} +\tl_const:Nn \c_acro_version_minor_number_tl {5} \tl_const:Nn \c_acro_version_subrelease_tl {} \tl_const:Nx \c_acro_version_number_tl { @@ -47,7 +47,7 @@ {\c_acro_package_name_tl} {\c_acro_date_tl} {\c_acro_version_tl} - {\c_acro_info_tl} + {\c_acro_info_tl \c_space_tl (CN)} % -------------------------------------------------------------------------- % document hooks: @@ -84,23 +84,23 @@ \bool_new:N \g__acro_rerun_bool \tl_new:N \g__acro_rerun_message_tl -\tl_const:Nn \l__acro_rerun_general_tl +\tl_const:Nn \c__acro_rerun_general_tl { Rerun~ to~ get~ `acro'~ synchronized. } -\tl_const:Nn \l__acro_rerun_property_tl +\tl_const:Nn \c__acro_rerun_property_tl { Acronym~ properties~ may~ have~ changed.~ Rerun~ to~ get~ them~ synchronized. } -\tl_const:Nn \l__acro_rerun_list_tl +\tl_const:Nn \c__acro_rerun_list_tl { Empty~ acronym~ list.~ If~ you~ have~ used~ acronyms~ then~ re-compile~ to~ get~ the~ list~ filled.~ Otherwise~ remove~ \token_to_str:N \printacronyms } -\msg_new:nnn {acro} {rerun} { \use:c {l__acro_rerun_#1_tl} } +\msg_new:nnn {acro} {rerun} { \use:c {c__acro_rerun_#1_tl} } \prg_new_conditional:Npnn \acro_if_rerun: {p,T,F,TF} { @@ -191,11 +191,11 @@ debug .initial:n = false , upgrade .bool_gset:N = \g__acro_upgrade_bool , upgrade .initial:n = true , - final .bool_set:N = \g__acro_final_bool , + final .bool_gset:N = \g__acro_final_bool , final .initial:n = false , version .choice: , - version / 2 .code:n = \int_set:Nn \g__acro_version_int {2} , - version / 3 .code:n = \int_set:Nn \g__acro_version_int {3} , + version / 2 .code:n = \int_gset:Nn \g__acro_version_int {2} , + version / 3 .code:n = \int_gset:Nn \g__acro_version_int {3} , version .initial:n = 3 , unknown .code:n = \__acro_loadtime_warning:n {unknown-option} } @@ -486,10 +486,11 @@ \cs_generate_variant:Nn \tl_remove_all:Nn {NV} \cs_generate_variant:Nn \tl_remove_once:Nn {NV} \cs_generate_variant:Nn \tl_if_in:NnF {NV} +\cs_generate_variant:Nn \tl_if_eq:nnTF {VV} \cs_generate_variant:Nn \tl_put_right:Nn {Ne} \cs_generate_variant:Nn \clist_set:Nn {Ne} \cs_generate_variant:Nn \str_if_eq:nnT {x} -\cs_generate_variant:Nn \str_fold_case:n {e} +\cs_generate_variant:Nn \str_foldcase:n {e} \cs_generate_variant:Nn \str_lowercase:n {e} \cs_generate_variant:Nn \msg_error:nnnnn {nnnxx} \cs_generate_variant:Nn \msg_warning:nn {nV} @@ -648,6 +649,14 @@ \NewDocumentCommand \AcroPropertiesMap {+m} { \acro_properties_map:n {#1} } +\NewDocumentCommand \AcroAcronymsMap {+m} + { \acro_map_acronyms:n { \tl_set:Nn \AcronymID {##1} #1 } } + +\NewExpandableDocumentCommand \AcroMapBreak {} { \acro_map_break: } + +\NewDocumentCommand \AcroPropertiesSet {m+m} + { \acro_properties_set:nn {#1} {#2} } + \NewDocumentCommand \AcroMap {m+m} { \acro_list_map:nn {#1} {#2} } @@ -668,9 +677,24 @@ \NewDocumentCommand \acroloadstyle {m} { \acro_style_load:n {#1} } +\NewExpandableDocumentCommand \acroifstarredTF {} + { \bool_if:NTF \l__acro_star_bool } + +\NewExpandableDocumentCommand \acroifstarredT {} + { \bool_if:NT \l__acro_star_bool } + +\NewExpandableDocumentCommand \acroifstarredF {} + { \bool_if:NF \l__acro_star_bool } + \NewExpandableDocumentCommand \acroifusedTF {m} { \acro_boolean_property_if:nnTF {#1} {used} } +\NewExpandableDocumentCommand \acroifusedT {m} + { \acro_boolean_property_if:nnT {#1} {used} } + +\NewExpandableDocumentCommand \acroifusedF {m} + { \acro_boolean_property_if:nnF {#1} {used} } + \NewDocumentCommand \acuse {m} { \acro_use:n {#1} } @@ -726,6 +750,16 @@ \NewDocumentCommand \MakeAcroPropertyAlias {mm} { \acro_property_make_alias:nn {#1} {#2} } +\NewDocumentCommand \NewAcroPreset {m+m} + { \acro_preset_new:nn {#1} {#2} } + +\NewDocumentCommand \RenewAcroPreset {m+m} + { \acro_preset_renew:nn {#1} {#2} } + +\NewDocumentCommand \DeclareAcroPreset {m+m} + { \acro_preset_declare:nn {#1} {#2} } + +% -------------------------------------------------------------------------- \NewDocumentCommand \UseAcroTemplate {O{acronym}mO{1}} { \acro_template_use:nnn {#3} {#1} {#2} } @@ -828,7 +862,7 @@ { \acro_write:en {#1} {#2} } } -\NewExpandableDocumentCommand \acrofieldifTF {+m+m+m+m} +\NewExpandableDocumentCommand \acroiffieldTF {+m+m+m+m} { \acro_property_if_set:nnTF {#1} {#2} {#3} {#4} } \NewDocumentCommand \acroifanyfieldTF {mm+m+m} @@ -866,6 +900,15 @@ \NewDocumentCommand \acrocite {} { \bool_set_true:N \l__acro_cite_always_bool } +\NewExpandableDocumentCommand \acroifpropertyTF {m} + { \acro_property_if_exist:nTF {#1} } + +\NewExpandableDocumentCommand \acroifpropertyT {m} + { \acro_property_if_exist:nT {#1} } + +\NewExpandableDocumentCommand \acroifpropertyF {m} + { \acro_property_if_exist:nF {#1} } + \NewExpandableDocumentCommand \acroifbooleanTF {m} { \acro_boolean_property_if:enTF { \AcronymID } {#1} } @@ -911,11 +954,11 @@ { \acro_if_first:eTF { \AcronymID } {} {#1} } \NewDocumentCommand \acroiftagTF {m+m+m} - { \acro_if_tag:enTF { \AcronymID } {#1} {#2} {#3} } + { \acro_tag_if:enTF { \AcronymID } {#1} {#2} {#3} } \NewDocumentCommand \acroiftagT {m+m} - { \acro_if_tag:enT { \AcronymID } {#1} {#2} } + { \acro_tag_if:enT { \AcronymID } {#1} {#2} } \NewDocumentCommand \acroiftagF {m+m} - { \acro_if_tag:enF { \AcronymID } {#1} {#2} } + { \acro_tag_if:enF { \AcronymID } {#1} {#2} } \NewDocumentCommand \acropages {mm} { \acro_print_pages:enn { \AcronymID } {#1} {#2} } @@ -929,6 +972,8 @@ \NewDocumentCommand \acropagefill {} { \acro_if_pages:eT { \AcronymID } { \tl_use:N \l__acro_pages_fill_tl } } +\NewDocumentCommand \acrodotfill {} { \acro_dot_fill: } + \NewExpandableDocumentCommand \acroifpagesTF {} { \acro_if_pages:eTF { \AcronymID } } @@ -962,7 +1007,7 @@ \tl_const:Nx \c_acro_auxfile_tl { \c_sys_jobname_str .acr } \iow_new:N \l__acro_aux_file_iow -\tl_new:N \g__acro_mdfive_hash_tl +\tl_new:N \l__acro_mdfive_hash_tl \acro_at_begin_document:n { @@ -973,7 +1018,7 @@ } \file_get_mdfive_hash:VN \c_acro_auxfile_tl - \g__acro_mdfive_hash_tl + \l__acro_mdfive_hash_tl \iow_open:NV \l__acro_aux_file_iow \c_acro_auxfile_tl } @@ -983,7 +1028,7 @@ \file_get_mdfive_hash:VN \c_acro_auxfile_tl \l__acro_tmpa_tl - \tl_if_eq:NNF \g__acro_mdfive_hash_tl \l__acro_tmpa_tl + \tl_if_eq:NNF \l__acro_mdfive_hash_tl \l__acro_tmpa_tl { \acro_rerun:n {general} } \legacy_if:nT {@filesw} { \iow_now:Nx \@auxout { \token_to_str:N \ACRO {readaux} } } @@ -1092,8 +1137,8 @@ % #1: name \cs_new_protected:Npn \__acro_auxlist_update:n #1 { - \seq_remove_duplicates:c {g__acro_auxlist_#1_seq} - \seq_remove_duplicates:c {g__acro_auxlist_recorded_#1_seq} + \seq_gremove_duplicates:c {g__acro_auxlist_#1_seq} + \seq_gremove_duplicates:c {g__acro_auxlist_recorded_#1_seq} \str_set:Nx \l__acro_tmpa_str { \seq_use:cn {g__acro_auxlist_#1_seq} {} } \str_set:Nx \l__acro_tmpb_str @@ -1167,6 +1212,17 @@ needs~ a~ (possibly~ empty)~ value! } +\msg_new:nnn {acro} {preset-defined} + { + The~ acronym~ preset~ `#1'~ is~ already~ defined~ \msg_line_context: . \\ + Try~ \RenewAcroPreset ~ or~ \DeclareAcroPreset ~ instead. + } + +\msg_new:nnn {acro} {preset-not-defined} + { + The~ acronym~ preset~ `#1'~ is~ not~ defined~ \msg_line_context: , yet. \\ + Try~ \NewAcroPreset ~ or~ \DeclareAcroPreset ~ instead. + } % ---------------------------------------------------------------------------- % declare properties: @@ -1549,7 +1605,68 @@ \__acro_parse_property:nn {#2} } -\cs_generate_variant:Nn \acro_properties_set:nnn {nnx,nxx,nV,nVx} +\cs_generate_variant:Nn \acro_properties_set:nn {nV} + +% -------------------------------------------------------------------------- +% define a set of properties that can be assigned to acronyms +% #1: preset name +\prg_new_conditional:Npnn \acro_preset_if_defined:n #1 {p,T,F,TF} + { + \tl_if_exist:cTF {l__acro_preset_#1_tl} + { \prg_return_true: } + { \prg_return_false: } + } + +% #1: preset name +\cs_new_protected:Npn \acro_preset_define:n #1 + { \tl_new:c {l__acro_preset_#1_tl} } + +% #1: preset name +% #2: properties +\cs_new_protected:Npn \acro_preset_set:nn #1#2 + { \tl_set:cn {l__acro_preset_#1_tl} {#2} } + +% #1: preset name +% #2: properties +\cs_new_protected:Npn \acro_preset_declare:nn #1#2 + { + \acro_preset_if_defined:nF {#1} + { \acro_preset_define:n {#1} } + \acro_preset_set:nn {#1} {#2} + } + +% #1: preset name +% #2: properties +\cs_new_protected:Npn \acro_preset_new:nn #1#2 + { + \acro_preset_if_defined:nTF {#1} + { \msg_error:nnn {acro} {preset-defined} {#1} } + { + \acro_preset_define:n {#1} + \acro_preset_set:nn {#1} {#2} + } + } + +% #1: preset name +% #2: properties +\cs_new_protected:Npn \acro_preset_renew:nn #1#2 + { + \acro_preset_if_defined:nTF {#1} + { \acro_preset_set:nn {#1} {#2} } + { \msg_error:nnn {acro} {preset-not-defined} {#1} } + } + +% #1: ID +\cs_new_protected:Npn \acro_preset_set_properties:n #1 + { + \acro_property_if_set:nnT {#1} {preset} + { + \tl_set_eq:Nc + \l__acro_tmpa_tl + {l__acro_preset_ \acro_property_get:nn {#1} {preset} _tl} + \acro_properties_set:nV {#1} \l__acro_tmpa_tl + } + } % ---------------------------------------------------------------------------- % inspect properties: @@ -1703,6 +1820,9 @@ \DeclareAcroProperty {alt} \DeclareAcroProperty !{long} +\DeclareAcroProperty{uselist} +\DeclareAcroProperty{preset} + % sorting, indexing, ... : \DeclareAcroPropertyAlias {sort} {short} \DeclareAcroProperty {index} @@ -1771,7 +1891,7 @@ % -------------------------------------------------------------------------- % declaration of acronyms: -\seq_new:N \g__acro_acronyms_seq +\seq_new:N \g_acro_acronyms_seq \tl_new:N \l__acro_first_style_tl @@ -1801,7 +1921,7 @@ {g__acro_#1_barriers_intarray} { \g_acro_barrier_total_int } } - \seq_gput_right:Nn \g__acro_acronyms_seq {#1} + \seq_gput_right:Nn \g_acro_acronyms_seq {#1} \acro_attribute_set:nnn {acronyms} {#1} {} % set defaults: \__acro_set_article_defaults:n {#1} @@ -1814,6 +1934,7 @@ { !\acro_property_if_set_p:nn {#1} {short} } { \acro_property_set:nnn {#1} {short} {#1} } \acro_property_set:nnn {#1} {id} {#1} + \acro_preset_set_properties:n {#1} \acro_property_set_aliases:n {#1} % check mandatory properties: \acro_property_foreach_mandatory:n @@ -1838,10 +1959,31 @@ { \prg_return_false: } } +\prg_new_protected_conditional:Npnn \__acro_uselist_if_used:n #1 {T,F,TF} + { + \acro_property_if_set:nnTF {#1} {uselist} + { + \clist_set:Nx \l__acro_tmpa_clist + { \acro_property_get:nn {#1} {uselist} } + \clist_clear:N \l__acro_tmpb_clist + \clist_map_inline:Nn \l__acro_tmpa_clist + { + \acro_boolean_property_if:nnT {##1} {used} + { \clist_put_right:Nn \l__acro_tmpb_clist {##1} } + } + \tl_if_eq:VVTF \l__acro_tmpa_clist \l__acro_tmpb_clist + { \prg_return_true: } + { \prg_return_false: } + } + { \prg_return_false: } + } + \cs_new_protected:Npn \acro_check_definition:n #1 { \acro_if_defined:nF {#1} { \msg_error:nnn {acro} {undefined} {#1} } + \acro_boolean_property_if:nnF {#1} {used} + { \__acro_uselist_if_used:nT {#1} { \acro_use:n {#1} } } } % -------------------------------------------------------------------------- @@ -1849,6 +1991,12 @@ \bool_new:N \l__acro_use_bool \bool_set_true:N \l__acro_use_bool +\cs_new_protected:Npn \acro_map_acronyms:n #1 + { \seq_map_inline:Nn \g_acro_acronyms_seq {#1} } + +\cs_new:Npn \acro_map_break: { \seq_map_break: } +\cs_new:Npn \acro_map_break:n { \seq_map_break:n } + \cs_new_protected:Npn \acro_use_false: { \bool_set_false:N \l__acro_use_bool } @@ -1867,7 +2015,7 @@ \cs_generate_variant:Nn \acro_use:n {e} \cs_new_protected:Npn \acro_use_all: - { \seq_map_inline:Nn \g__acro_acronyms_seq { \__acro_use:n {##1} } } + { \seq_map_inline:Nn \g_acro_acronyms_seq { \__acro_use:n {##1} } } \cs_new_protected:Npn \__acro_reset:n #1 { @@ -1882,7 +2030,7 @@ { \clist_map_inline:nn {#1} { \__acro_reset:n {##1} } } \cs_new_protected:Npn \acro_reset_all: - { \seq_map_inline:Nn \g__acro_acronyms_seq { \__acro_reset:n {##1} } } + { \seq_map_inline:Nn \g_acro_acronyms_seq { \__acro_reset:n {##1} } } \cs_new_protected:Npn \acro_switch_off: { \bool_set_false:N \l__acro_use_bool } @@ -2196,6 +2344,16 @@ \__acro_set_endings:nn {#1} {long} } +% #1: ending +\cs_new_protected:Npn \acro_unset_ending:n #1 + { \bool_set_false:c {l__acro_ending_#1_bool} } + +\cs_new_protected:Npn \acro_reset_endings: + { + \tl_map_tokens:Nn \l__acro_endings_tl { \acro_unset_ending:n } + \bool_set_false:N \l__acro_ending_bool + } + % ---------------------------------------------------------------------------- \AcroModuleEnd \AcroModule{tools}{tools for treating different aspects} @@ -2460,6 +2618,7 @@ % -------------------------------------------------------------------------- % indexing \bool_new:N \l__acro_index_bool +\bool_new:N \l__acro_index_prop_bool \tl_new:N \l_acro_index_disable_tl \cs_new_protected:Npn \__acro_index:n {} @@ -2468,9 +2627,16 @@ % #1: id \cs_new_protected:Npn \acro_index:n #1 { - \bool_lazy_and:nnT - { \l__acro_index_bool } - { !\acro_boolean_property_if_p:nn {#1} {no-index} } + \bool_lazy_all:nT + { + { \l__acro_index_bool } + { !\acro_boolean_property_if_p:nn {#1} {no-index} } + { + \bool_if:NTF \l__acro_index_prop_bool + { \acro_property_if_set_p:nn {#1} {index} } + { !\acro_property_if_set_p:nn {#1} {index} } + } + } { \group_begin: \acro_trailing_map:n @@ -2500,15 +2666,26 @@ \keys_define:nn {acro/index} { - use .bool_set:N = \l__acro_index_bool , - use .initial:n = false , - cmd .cs_set:Np = \__acro_index:n , - cmd .initial:n = \index , - cmd .value_required:n = true , - disable .code:n = \tl_put_right:Nn \l_acro_index_disable_tl {#1} , - disable .value_required:n = true , - clear .code:n = \tl_clear:N \l_acro_index_disable_tl , - clear .value_forbidden:n = true + use .choice: , + use / true .code:n = + \bool_set_true:N \l__acro_index_bool + \bool_set_false:N \l__acro_index_prop_bool , + use / false .code:n = + \bool_set_false:N \l__acro_index_bool + \bool_set_false:N \l__acro_index_prop_bool , + use / indexed .code:n = + \bool_set_true:N \l__acro_index_bool + \bool_set_true:N \l__acro_index_prop_bool , + use .initial:n = false , + use .default:n = true , + use .initial:n = false , + cmd .cs_set:Np = \__acro_index:n , + cmd .initial:n = \index , + cmd .value_required:n = true , + disable .code:n = \tl_put_right:Nn \l_acro_index_disable_tl {#1} , + disable .value_required:n = true , + clear .code:n = \tl_clear:N \l_acro_index_disable_tl , + clear .value_forbidden:n = true } \keys_set:nn {acro/index} { disable = \def\@{} } @@ -2601,13 +2778,10 @@ } \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 } + \int_compare:nNnTF \l__acro_nest_int > 1 { \prg_return_true: } { \prg_return_false: } } @@ -2615,9 +2789,8 @@ \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_reset_endings: \__acro_check_after_end:w } @@ -2636,7 +2809,6 @@ \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 @@ -2714,8 +2886,8 @@ \int_compare:nNnTF { \__acro_strcmp:nn - { \str_fold_case:e { \acro_property_get:nn {##1} {sort} } } - { \str_fold_case:e { \acro_property_get:nn {##2} {sort} } } + { \str_foldcase:e { \acro_property_get:nn {##1} {sort} } } + { \str_foldcase:e { \acro_property_get:nn {##2} {sort} } } } = {-1} { \sort_return_same: } { \sort_return_swapped: } @@ -2850,8 +3022,8 @@ \keys_define:nn {acro} { - case-sensitive .bool_set:N = \g__acro_case_sensitive_bool , - case-sensitive .initial:n = true , + case-sensitive .bool_gset:N = \g__acro_case_sensitive_bool , + case-sensitive .initial:n = true , } % ---------------------------------------------------------------------------- @@ -3028,9 +3200,7 @@ \acro_locale:nnn {#1} {#2} { \__acro_write:nn {#1} {#2} - \bool_lazy_and:nnT - { !\acro_if_nested_p: } - { \l__acro_include_endings_bool } + \bool_if:NT \l__acro_include_endings_bool { \acro_if_ending_form:nnF {#1} {#2} { \__acro_ending:nn {#1} {#2} } @@ -3038,9 +3208,7 @@ } } \group_end: - \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} } @@ -3092,7 +3260,6 @@ { \acro_use:n {#2} \acro_record_page:n {#2} - % \acro_record_barrier:n {#2} \acro_index:n {#2} } } @@ -3108,6 +3275,8 @@ \tl_new:N \l__acro_begin_command_hook_tl \tl_new:N \l__acro_end_command_hook_tl +\tl_new:N \l_acro_id_tl +\tl_new:N \AcronymID % #1: csname % #2: xparse csname @@ -3128,8 +3297,8 @@ \cs_set:Npn \nospace { \exp:w \exp_end_continue_f:w } \acro_check_definition:n {####1} \keys_set:nV {acro} \l__acro_options_tl - \tl_set:Ne \AcronymID { \acro_case_insensitive:n {####1} } \tl_set:Ne \l_acro_id_tl { \acro_case_insensitive:n {####1} } + \tl_set_eq:NN \AcronymID \l_acro_id_tl ##3 \acro_finalize:ne { \l__acro_star_bool } @@ -3511,10 +3680,10 @@ \cs_new_protected:Npn \acro_list_choose_set: { \bool_if:NTF \l__acro_list_display_all_bool - { \seq_gset_eq:NN \g__acro_list_seq \g__acro_acronyms_seq } + { \seq_gset_eq:NN \g__acro_list_seq \g_acro_acronyms_seq } { \seq_gclear:N \g__acro_list_seq - \seq_map_inline:Nn \g__acro_acronyms_seq + \seq_map_inline:Nn \g_acro_acronyms_seq { \acro_if_single:nTF {##1} { @@ -3687,8 +3856,6 @@ \AcroModule{pages}{recording and printing of pages} % ---------------------------------------------------------------------------- % record page numbers: -\RequirePackage {zref-abspage} - \msg_new:nnn {acro} {no-page-range} { The~ list~ template~ `#1'~ cannot~ display~ a~ page~ range. @@ -3704,10 +3871,18 @@ \cs_new_protected:Npn \acro_record_page:n #1 { \seq_if_in:ceF {g__acro_#1_pages_seq} - { \arabic{abspage} @ \int_use:N \g_acro_barrier_int @ \thepage } + { + \int_use:N \g_shipout_totalpages_int + @ \int_use:N \g_acro_barrier_int + @ \thepage + } { \seq_gput_right:ce {g__acro_#1_pages_seq} - { \arabic{abspage} @ \int_use:N \g_acro_barrier_int @ \thepage } + { + \int_use:N \g_shipout_totalpages_int + @ \int_use:N \g_acro_barrier_int + @ \thepage + } } \seq_gremove_duplicates:c {g__acro_#1_pages_seq} \acro_at_end_document:n @@ -3730,10 +3905,8 @@ \group_end: -\RequirePackage {zref-totpages} - \acro_at_begin_document:n - { \intarray_new:Nn \g__acro_pages_intarray { \ztotpages } } + { \intarray_new:Nn \g__acro_pages_intarray { \PreviousTotalPages } } % #1: id % #2: one page @@ -3761,8 +3934,13 @@ { \seq_set_split:Nnx \l__acro_tmpa_seq {|} { \acro_property_get:nn {#1} {pages} } - \exp_last_unbraced:Ne - \__acro_page_name:w { \seq_item:Nn \l__acro_tmpa_seq {1} } \q_stop + \use:e + { + \exp_last_unbraced:Ne + \__acro_page_name:w + { \seq_item:Nn \l__acro_tmpa_seq {1} } + \q_stop + } } % #1: id @@ -3946,6 +4124,25 @@ \int_new:N \l__acro_pages_seq_threshold_int +% ---------------------------------------------------------------------------- +\cs_new_protected:Npn \acro_dot_fill: + { + \leaders \hbox + { + $\m@th + \mkern \@dotsep mu + \hbox {.} + \mkern \@dotsep mu$ + } + \hfill + } + +\hook_gput_code:nnn {begindocument} {xsim} + { + \cs_if_exist:NT \cftdotfill + { \cs_set_protected:Npn \acro_dot_fill: { \cftdotfill { \cftdotsep } } } + } + \keys_define:nn {acro/pages} { display .choice: , @@ -3967,7 +4164,7 @@ { \int_set:Nn \l__acro_pages_seq_threshold_int {#1} } , seq / threshold .initial:n = 3 , fill .tl_set:N = \l__acro_pages_fill_tl , - fill .initial:n = \dotfill , + fill .initial:n = \acro_dot_fill: , sep .tl_set:N = \l__acro_pages_sep_tl , sep .initial:n = {,~} , name .bool_set:N = \l__acro_pages_name_display_bool , @@ -4213,6 +4410,7 @@ % -------------------------------------------------------------------------- % hyper linking \bool_new:N \l__acro_hyperref_use_bool +\bool_new:N \l__acro_link_only_first_bool \cs_new_eq:NN \__acro_hyper_target:nn \use_ii:nn \cs_new_eq:NN \__acro_hyper_link:nn \use_ii:nn @@ -4249,6 +4447,11 @@ { \acro_package_if_loaded_p:n {hyperref} } { \l__acro_hyperref_use_bool } { !\acro_if_single_p:n {#1} } + { + \bool_lazy_or_p:nn + { !\l__acro_link_only_first_bool } + { \l__acro_link_only_first_bool && \acro_if_first_p:n {#1} } + } } { \bool_if:NTF \l__acro_list_bool @@ -4312,13 +4515,16 @@ \keys_define:nn {acro} { - make-links .bool_set:N = \l__acro_hyperref_use_bool , - make-links .initial:n = false + make-links .bool_set:N = \l__acro_hyperref_use_bool , + make-links .initial:n = false , + link-only-first .bool_set:N = \l__acro_link_only_first_bool , + link-only-first .initial:n = false } % -------------------------------------------------------------------------- % accessibility support \bool_new:N \l__acro_accsupp_bool +\bool_new:N \l__acro_use_accsupp_bool \tl_new:N \l__acro_accsupp_options_tl \tl_new:N \l__acro_accsupp_method_tl -- cgit v1.2.3