[Tex/LaTex] acro-package: Always use long form for defined acronym

acroacronyms

Is there a convenient switch to make acro always use the long form for selected acronyms? I would like to be able to toggle that. Otherwise, I have to search and replace acro commands with (say) \acl, \aclp, etc. (and I'd lose track of where all my \acs's were).

AFTERNOTE: My current approach is to define the short form to be the same as the long form, then list the acronym under \acuse so that the first occurrence isn't treated specially. The fatal drawback is that the acronym still shows up in the list of acronyms at the end of the document.

Best Answer

All acronyms can be set to give their long form by setting \acro_use:n which check the acronyms used status and then picks long/short/first form accordingly to instead always fetch the long form with \acro_long:n

\cs_set_eq:NN \acro_use:n \acro_long:n

This won't affect calls for the short or alt forms, they will still appear as the short/alt forms as internally they use \acro_short:n and \acro_alt:n but these can also be set to call the \acro_long:n form if so desired.

\ExplSyntaxOn
\cs_set_eq:NN \acro_use:n \acro_long:n
\cs_set_eq:NN \acro_short:n \acro_long:n
\cs_set_eq:NN \acro_alt:n \acro_long:n
\ExplSyntaxOff

should essentially turn off all \ac-type macros and make them expand to the long form only.

If looking to only disable it for a set of acronyms, say those identified with class = maybelongonly then one can modify the \acro_use:n to insert a check of the acronyms class and accordingly print it as normal (for acro) or print the long form only. To check the class \acro_get_property:nn is used, which was introduced in v2.7

\documentclass{article}
\usepackage{acro}

\DeclareAcronym{ecm}{
  short = ECM ,
  long  = Electro Chemical Machining,
  class = maybelongonly,
}
\DeclareAcronym{adc}{
  short = ADC ,
  long  = Analog-to-Digital-Converter
}

\ExplSyntaxOn
\tl_new:N \l__acro_longonly_tl
\tl_set:Nn \l__acro_longonly_tl { maybelongonly }

\cs_set_eq:NN \acro_useold:n \acro_use:n
\cs_set:Npn \acro_use:n #1 {
    \acro_get_property:nn { #1 } { class }
    \tl_if_eq:NNTF \l__acro_class_tl \l__acro_longonly_tl {
        \acro_long:n { #1 }
    }{
        \acro_useold:n { #1 }
    }
}
\ExplSyntaxOff

\begin{document}
\ac{ecm}

\ac{ecm}

\acp{adc}

\Ac{ecm}

\acp{ecm}

\Iac{adc}
\end{document}

this will ensure \acp{<key>} prints always printsthe long version with the appropriate plural for acronyms in the appropriate class. In order to catch any explicit calls for the short or alt versions (\acs, \aca etc.) then \acro_short:n and \acro_alt:n should be modified similarly to \acro_use:n.

These acronyms can be removed from the list by giving \printacronyms the key exclude-classes=maybelongonly.

Related Question