[Tex/LaTex] How to use glossaries for different grammatical acronym forms

casesgermanglossariesgrammar

I'm writing a paper in German and am struggling with how to make glossaries work for me. In German, there are 4 different cases, and depending on which combination a gender, case, singular/plural and definite/indefinite form I want to use, I have to use different forms of the nouns and adjectives. My problem basically is, how to define just the standard form for use in the list acronyms, but use the grammatically correct form for the long form (at the first place where the acronym is used)?

I've already done many hours of research and trial and error, but I haven't quite achieved what I want. One principle is described here: Customizing the first use of acronyms generated by glossaries I like the idea, but unfortunately it's only that easy if I only use nouns as base for acronyms because then I only have four different forms. If I use combinations of adjectives and nouns, I get very many forms, which would mean quite a lot of work to define all of them in the acronym list.

Another proposal (found at Using the glossaries package in other languages.) is to use \glslink or \glsdisp and define the form of the acronym everywhere, where it is used. While this would be quite simple, it doesn't work as I want it to, since it only displays the long form and doesn't seem to set the 'first use' flag.

I am actually thinking of a way very similar to the second suggestion, but with \gls, so it will display the short and long form at first use and after that only the long form. I already tried to modify the first example to my needs, but I do not totally understand all the commands there, so I'm lost.

For illustration, something like this is what I want: \gls{<label>}{<apperance at this point in the text as long form in case of first use>}

Edit: This is the example from the second link I posted:

\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>}

Now I would like to change this to not use any of the pre-defined (Nom, Akk, Dat, Gen) forms,when putting \acg, but give the actual form as an argument to \acg at the place I use it in the text. It should actually be quite simple, but as I don't understand all commands in the example (even after hours of looking them up), I can't do it myself.

Edit:

One example would be:

  • Ich bin ein alter Mann. (I'm an old man.)
  • Ich bin der alte Mann. (I'm the old man.)
  • Ich sehe die Frau des alten Mannes. (I see the old man's wife.)
  • Ich gebe dem alten Mann ein Buch. (I give the old man a book.)
  • Wir sind alte Männer. (We are old men.)
  • Ihr seid die Frauen der alten Männer. (You are the old men's wifes.)
  • Ich gebe den alten Männern meine Bücher. (I give the old men my books).

Another example:

  • Das ist ein kleines Kind. (This is a small child.)
  • Das ist das kleine Kind. (This is the small child.)
  • Die Haarfarbe des kleinen Kindes ist braun. (The child's hair color is brown.)
  • Ich lese dem kleinen Kind ein Buch vor. (I read a book to the child.)
  • Wir sind kleine Kinder. (We are small children.)
  • Wir sind die kleinen Kinder. (We are the small children.)
  • Das ist die Haarfarbe kleiner Kinder. (That is the hair color of small children.)
  • Ich lese kleinen Kindern ein Buch vor. (I read a book to small children.)

In these cases, I listed only the cases which require forms with different suffixes for "alter Mann" (masculine) and "kleines Kind" (neutral). In these two, the different forms are already different for different cases and for feminine words, there will be other forms again.

In this specific case (first example), I would like "alter Mann" in my glossaries, but in the text use something like Ich bin der \gls[alte Mann]{aM}. to produce the second sample sentence. I'm afraid, that defining all the possible forms beforehand for every acronym (when defining the acronyms) would take forever, but perhaps, that's what I will have to do?!

Best Answer

I can't see how acronyms relate to your question, but a new key for \newglossaryentry can be added using \glsaddkey where you specify the new key, a default value if the key hasn't been assigned, and various commands that can be used to later access the information provided by that key. (These commands are analogous to commands like \glsentrytext, \Glsentrytext, \glstext, \Glstext and \GLStext and so are not governed by the first use flag.)

For brevity, I've only defined the masculine cases. You can apply a similar method for the other genders and plural cases. I've also only defined one term also for brevity. I may have made grammatical errors, but this should give you the general gist of how to add new keys:

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{glossaries}

\makeglossaries

% Without article:

% masculine nominative
\glsaddkey
 {mnominative}% key
 {}% default value
 {\glsentrymnominative}% no link cs
 {\Glsentrymnominative}% no link ucfirst cs
 {\glsmnom}% link cs
 {\Glsmnom}% link ucfirst cs
 {\GLSmnom}% link all caps cs

% masculine accusative
\glsaddkey
 {maccusative}% key
 {}% default value
 {\glsentrymaccusative}% no link cs
 {\Glsentrymaccusative}% no link ucfirst cs
 {\glsmacc}% link cs
 {\Glsmacc}% link ucfirst cs
 {\GLSmacc}% link all caps cs

% masculine genitive
\glsaddkey
 {mgenitive}% key
 {}% default value
 {\glsentrymgenitive}% no link cs
 {\Glsentrymgenitive}% no link ucfirst cs
 {\glsmgen}% link cs
 {\Glsmgen}% link ucfirst cs
 {\GLSmgen}% link all caps cs

% masculine dative
\glsaddkey
 {mdative}% key
 {}% default value
 {\glsentrymdative}% no link cs
 {\Glsentrymdative}% no link ucfirst cs
 {\glsmdat}% link cs
 {\Glsmdat}% link ucfirst cs
 {\GLSmdat}% link all caps cs

% With definite article:

% masculine nominative
\glsaddkey
 {mdefnominative}% key
 {der \glsentrymnominative{\glslabel}}% default value
 {\glsentrymdefnominative}% no link cs
 {\Glsentrymdefnominative}% no link ucfirst cs
 {\glsmdefnom}% link cs
 {\Glsmdefnom}% link ucfirst cs
 {\GLSmdefnom}% link all caps cs

% masculine accusative
\glsaddkey
 {mdefaccusative}% key
 {des \glsentrymaccusative{\glslabel}}% default value
 {\glsentrymdefaccusative}% no link cs
 {\Glsentrymdefaccusative}% no link ucfirst cs
 {\glsmdefacc}% link cs
 {\Glsmdefacc}% link ucfirst cs
 {\GLSmdefacc}% link all caps cs

% masculine genitive
\glsaddkey
 {mdefgenitive}% key
 {dem \glsentrymgenitive{\glslabel}}% default value
 {\glsentrymdefgenitive}% no link cs
 {\Glsentrymdefgenitive}% no link ucfirst cs
 {\glsmdefgen}% link cs
 {\Glsmdefgen}% link ucfirst cs
 {\GLSmdefgen}% link all caps cs

% masculine dative
\glsaddkey
 {mdefdative}% key
 {den \glsentrymdative{\glslabel}}% default value
 {\glsentrymdefdative}% no link cs
 {\Glsentrymdefdative}% no link ucfirst cs
 {\glsmdefdat}% link cs
 {\Glsmdefdat}% link ucfirst cs
 {\GLSmdefdat}% link all caps cs

% With indefinite article:

% masculine nominative
\glsaddkey
 {mindefnominative}% key
 {ein \glsentrymnominative{\glslabel}}% default value
 {\glsentrymindefnominative}% no link cs
 {\Glsentrymindefnominative}% no link ucfirst cs
 {\glsmindefnom}% link cs
 {\Glsmindefnom}% link ucfirst cs
 {\GLSmindefnom}% link all caps cs

% masculine accusative
\glsaddkey
 {mindefaccusative}% key
 {eines \glsentrymaccusative{\glslabel}}% default value
 {\glsentrymindefaccusative}% no link cs
 {\Glsentrymindefaccusative}% no link ucfirst cs
 {\glsmindefacc}% link cs
 {\Glsmindefacc}% link ucfirst cs
 {\GLSmindefacc}% link all caps cs

% masculine genitive
\glsaddkey
 {mindefgenitive}% key
 {einem \glsentrymgenitive{\glslabel}}% default value
 {\glsentrymindefgenitive}% no link cs
 {\Glsentrymindefgenitive}% no link ucfirst cs
 {\glsmindefgen}% link cs
 {\Glsmindefgen}% link ucfirst cs
 {\GLSmindefgen}% link all caps cs

% masculine dative
\glsaddkey
 {mindefdative}% key
 {einen \glsentrymdative{\glslabel}}% default value
 {\glsentrymindefdative}% no link cs
 {\Glsentrymindefdative}% no link ucfirst cs
 {\glsmindefdat}% link cs
 {\Glsmindefdat}% link ucfirst cs
 {\GLSmindefdat}% link all caps cs

\newglossaryentry{alt}%
{%
  name={Alt},% how it appears in the glossary
  text={alt},% predicative
  plural={alt},% predicative plural
  description={old},% description
% without article
  mnominative={alter},% nominative
  maccusative={alten},% accusative
  mgenitive={altem},% genitive
  mdative={alten},% dative
% with definite article
  mdefnominative={der alte},% nominative
  mdefgenitive={dem alten}% genitive
}

\begin{document}

Ich bin \glsmindefnom{alt} Mann.

Ich bin \glsmdefnom{alt} Mann.

Ich sehe die Frau \glsmdefacc{alt} Mannes.

Ich gebe \glsmdefgen{alt} Mann ein Buch.

\printglossaries

\end{document}

This produces:

Image of result

Related Question