# How to use glossaries for different grammatical acronym forms?

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{\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?!

• As a native speaking German: Use the first case (nominative) unless it is really necessary and use the singular version of a noun, unless you refer to multiple quantities of it. – user31729 May 17 '14 at 14:17
• That is not really an option for me as it would sound quite awkward. – Hemanti May 19 '14 at 12:09
• I can't speak any German, but you can add new keys via \glsaddkey for other grammatical forms. It would help if you could give an example acronym and say what text ought to be produced. – Nicola Talbot May 19 '14 at 13:52
• @NicolaTalbot, I'm not really sure what you mean. Why don't my examples contain acronyms? Just because they are not official or is anything else different? The grammar problem stays the same. And what's the difference between acronyms and "terms that appear differently on first use"? I thought acronyms do that?! My workaround for now is to just define the acronyms, do \glsaddall to create my list of acronyms and take care of the first uses myself without using the package. – Hemanti Jun 2 '14 at 8:49
• Can you give some real life examples? This would be best, using »old man« is not a helpful example. – Johannes_B Jun 2 '14 at 9:44

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
{mnominative}% key
{}% default value

% masculine accusative
{maccusative}% key
{}% default value

% masculine genitive
{mgenitive}% key
{}% default value

% masculine dative
{mdative}% key
{}% default value

% With definite article:

% masculine nominative
{mdefnominative}% key
{der \glsentrymnominative{\glslabel}}% default value

% masculine accusative
{mdefaccusative}% key
{des \glsentrymaccusative{\glslabel}}% default value

% masculine genitive
{mdefgenitive}% key
{dem \glsentrymgenitive{\glslabel}}% default value

% masculine dative
{mdefdative}% key
{den \glsentrymdative{\glslabel}}% default value

% With indefinite article:

% masculine nominative
{mindefnominative}% key
{ein \glsentrymnominative{\glslabel}}% default value

% masculine accusative
{mindefaccusative}% key
{eines \glsentrymaccusative{\glslabel}}% default value

% masculine genitive
{mindefgenitive}% key
{einem \glsentrymgenitive{\glslabel}}% default value

% masculine dative
{mindefdative}% key
{einen \glsentrymdative{\glslabel}}% default value

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

• @Hemanti Decide wisely, if you want to go through all that trouble, or if you simply write the right form by hand every time. I don't know your real use case, but i wouldn't go for it. – Johannes_B Jun 2 '14 at 13:43
• @NicolaTalbot: Following your great idea of bringing the command \glsdisp into play in thread [link] (tex.stackexchange.com/questions/347586/…), I think that -- at least for a paper book -- one may avoid the tedious definitions via glsaddkey for all the flexions of an inflected word, if glossaries is only used for inserting a reference indicator close to the word to be tagged and for indexing purposes. In the example above, Ich bin ein \glsdisp{alt}{$\rightarrow$}alter Mann. should give the same glossary and an arrrow before the tagged word. – Oli Jan 12 '17 at 19:54
• If one dislikes the use of a symbol next to the tagged word, another way out of the glsaddkey "flexion mania" for every tagged word could be to restrict the glossary entry to the lexeme. This should work for most of the inflected German words, as their lexeme (the "root") will remain unchained. Referring to the example above, one could write Ich bin ein \gls{alt}er Mann., which should give the same text and the same glossary as shown in the output above -- as long as the glossary entry is not displayed e.g. in a different colour. – Oli Jan 12 '17 at 20:04
• @Oli yes, that's the main purpose behind both \glsdisp and \glslink, so you can do, say, \glsdisp{alt}{alter} or \glslink{alt}{alter} (so the whole word appears in the same font/colour/hyperlink) or just \gls{alt}[er]. I think it's much simpler to do that than define keys for every possible variation in this type of situation. The custom keys are most useful when used in automated contexts (such as including certain fields in a custom style). – Nicola Talbot Jan 12 '17 at 20:48