cgnieder / acro

acronyms for LaTeX
LaTeX Project Public License v1.3c
40 stars 9 forks source link

Long-Pre has been removed #213

Closed mirkolenz closed 2 years ago

mirkolenz commented 3 years ago

Hi, I am a huge fan of your work and this package! I just discovered that you removed the option long-pre in the version that comes with TeX Live 2021. I have one particular use case for this option that I would like to highlight. When writing about Machine Learning, I often have to deal with corpora. I rely on acro to handle the abbreviation. Using the option long-pre, I was able to put the word the in front of the long version while omitting it for all subsequent occurrences. I could of course put the word the into the long value, but that means that it would also appear in the list of acronyms. Have a look at the following example.

\DeclareAcronym{corp-xx}{short=corp-xx, short-format=\ttfamily, long=XX Corpus, long-pre=\textnormal{the }}

I would like to kindly ask you to reconsider the removal of this option or provide me with some help on how to achieve this result with one of the remaining options.

Keep up your work!

cgnieder commented 2 years ago

You can define the property yourself end redefine the templates to use the property if set. The following demonstrates it for the long-short template:

\documentclass{article}
\usepackage[upgrade=false]{acro}

\DeclareAcroProperty{long-pre}

\RenewAcroTemplate{long-short}{%
  \acroiffirstTF{%
    \acroifT{long-pre}{\acrowrite{long-pre}}%
    \acrowrite{long}%
    \acspace
    (%
      \acroifT{foreign}{\acrowrite{foreign}, }%
      \acrowrite{short}%
      \acroifT{alt}{ \acrotranslate{or} \acrowrite{alt}}%
      \acrogroupcite
    )%
  }{\acrowrite{short}}%
 }

\DeclareAcronym{corp-xx}{
  short=corp-xx,
  short-format=\ttfamily,
  long=XX Corpus,
  long-pre=\textnormal{the }
}

\begin{document}

\ac{corp-xx}

\end{document}

For your example it might be easier to add a definite article:

\documentclass{article}
\usepackage[upgrade=false]{acro}

\DeclareAcroArticle{definite}{the}

\NewAcroCommand\dac{m}{\acrodefinite\UseAcroTemplate{first}{#1}}
\NewAcroCommand\dacs{m}{\acrodefinite\UseAcroTemplate{short}{#1}}
\NewAcroCommand\Dacs{m}{\acroupper\acrodefinite\UseAcroTemplate{short}{#1}}
\NewAcroCommand\dacl{m}{\acrodefinite\UseAcroTemplate{long}{#1}}
\NewAcroCommand\Dacl{m}{\acroupper\acrodefinite\UseAcroTemplate{long}{#1}}

\DeclareAcronym{corp-xx}{
  short=corp-xx,
  short-format=\ttfamily,
  long=XX Corpus ,
  short-definite = \nospace 
}

\begin{document}

\dac{corp-xx}

\dac{corp-xx}

\end{document}
mirkolenz commented 2 years ago

Thank you for the two suggestions, this is a perfectly suitable solution for me.