[Tex/LaTex] Customizing the first use of acronyms generated by glossaries

glossarieslanguages

I manage my acronyms using the glossaries package. My minimal example is as follows:

\documentclass[ngerman]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage[acronym,shortcuts]{glossaries}
\makeglossaries

\begin{document}

\newacronym{max}{max.}{maximal}
\printglossary[type=\acronymtype]

Der \ac{max} Genuss (\textit{should be} maximale (max.) \textit{on first use})   \newline
Ein \ac{max} Genuss (\textit{should be} maximaler (max.) \textit{on first use})  \newline
Den \ac{max} Genuss (\textit{should be} maximalen (max.) \textit{on first use})  \newline
Der \ac{max} Genuss (maximale)

\end{document}

The base form of the acronym is maximal. On first use glossaries gives the output base form (abbr.) = maximal (max.). Sadly, in german you cannot be sure that you need the base form on first use. As the definition of \newacronym is equal to

\newglossaryentry{⟨label ⟩}{type=\acronymtype, 
name={ ⟨abbrv ⟩}, 
description={⟨long ⟩}, 
text={⟨abbrv ⟩}, 
first={⟨long ⟩ (⟨abbrv ⟩)}, 
plural={⟨abbrv ⟩\glspluralsuffix}, 
firstplural={ long \glspluralsuffix\space (abbrv \glspluralsuffix)}, 
⟨key-val list ⟩} 

I could just redefine the ⟨long ⟩-part of the first argument to the desired output. In this MWE, it would work just fine as I know which modification of maximal is the first. But my real file is much more voluminous and I won't really know which one is the first used modification in advance. So, when finishing I would have to search the whole document whether the first uses of all acronyms are correct.

So, I am searching for a way to implement that he modifications like maximale, maximaler, maximales, maximalen,… on first use and only on first use, like\acfirst{max}{way it is displayed if it's the first use}.

I already tried to work with the user1, ... ,user6 entries, but this modifies every use, not just if it's the first.

This question is related to this one, but unfortunately not quite so easy to solve.

Best Answer

This seems to work:

\newcommand{\newacronymgerman}[6]{%
  \newacronym{#1}{#2}{\protect\gchoose{#3}{#4}{#5}{#6}}}
\newcommand{\acg}[2][N]{\csname choose#1\endcsname\ac{#2}\chooseN}
\newcommand{\chooseN}{\renewcommand\gchoose[4]{##1}}
\newcommand{\chooseA}{\renewcommand\gchoose[4]{##2}}
\newcommand{\chooseD}{\renewcommand\gchoose[4]{##3}}
\newcommand{\chooseG}{\renewcommand\gchoose[4]{##4}}
\newcommand{\gchoose}[4]{#1}

\newacronymgerman{<name>}{<abbrev>}{<Nom>}{<Akk>}{<Dat>}{<Gen>}

You put in the first argument the acronym symbolic name, in the second the acronym, in the other four the forms for Nominativ, Akkusativ, Dativ and Genitiv. Then you call the acronym with

 \acg[<case>]{<name>}

where <case> stands for N (default), A, D or G. I hope you don't need also plural forms.