cgnieder / acro

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

use of subsequent-style not working #232

Closed GregorDall closed 2 years ago

GregorDall commented 2 years ago

I was trying to use different types of of styles for various acronyms, but the subsequent-style option does not seem to work for me.

\documentclass[11pt,a4paper]{article}

\usepackage{acro}

\DeclareAcronym{MD}{short =MD, long = maturity date,first-style=short-long, subsequent-style=long-short}

\begin{document}
\ac{MD}
\ac{MD}
\ac{MD}

\end{document}

yields: MD (maturity date) MD MD should yield: MD (maturity date) maturity date (MD) maturity date (MD)

GregorDall commented 2 years ago

subsequent-style seems to support only long and short but not short-long or long-short

GregorDall commented 2 years ago

OK, so I just found out that this is a package option rather than an option for the individual acronym. So this becomes a feature request. Do you think this is possible?

cgnieder commented 2 years ago

Hi. The property as well as the option already exists and works just fine. What you're experiencing is the definition of the long-short template itself:

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

It checks itself again for a first appearance and outputs things depending on it… You can either change the definition of the template or define an own template for your case:

\documentclass{article}

\usepackage{acro}

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

\DeclareAcronym{MD}{
  short =MD,
  long = maturity date,
  first-style=short-long,
  subsequent-style=long-short
}

\begin{document}
\ac{MD}
\ac{MD}
\ac{MD}

\end{document}

or

\documentclass{article}

\usepackage{acro}

\NewAcroTemplate{custom}{\acrowrite{long} (\acrowrite{short})}

\DeclareAcronym{MD}{
  short =MD,
  long = maturity date,
  first-style=short-long,
  subsequent-style=custom
}

\begin{document}
\ac{MD}
\ac{MD}
\ac{MD}

\end{document}

Both give

image

GregorDall commented 2 years ago

Looks like I was misunderstanding how this option works. Thank you for clarifying and providing support and code!

cgnieder commented 2 years ago

No you didn't misunderstand it. The option as well as the property work as you've understood. Only the template you chose didn't behave as you've thought :)