0

I like to make a glossary for my work. For that I have a little stylistic question: Do you link to the glossary entries every time, when a word listed in a glossary appears or just at the first time of the chapter / section / paragraph / ... ? Because in MS Word I had not such problems ^^

Example:

\glslink{bla}{apples} and \glslink{bla}{apples} and \glslink{bla}{apples}

or:

\glslink{bla}{apples} and apples and apples

Which is the better one? Because doing it for every word there would be really annoying.

Thank you ^^

5
  • 3
    Why not using \gls{apples} instead of \glslink{...} directly?
    – user31729
    Dec 29 '18 at 18:43
  • 1
    If I remember correctly, glossaries can be configured to link only the first occurence and then use the non-linked entry
    – user31729
    Dec 29 '18 at 18:49
  • Because in german there are more cases: for example: Der Apfel, die Äpfel, den Äpfeln usw.
    – MrXeth
    Dec 29 '18 at 18:55
  • 1
    I know German ;-) \glsplural is your friend, as well as you could add storage keys like \glsgenitiv and \glsdativ and \glsakkusativ for such issues
    – user31729
    Dec 29 '18 at 18:57
  • mh I really think glslink is the easier way ^^
    – MrXeth
    Dec 29 '18 at 21:01
3

It depends on the document, whether you are predominantly using commands like \gls (which I usually do) or commands like \glslink (as in your question), and if you are using a sophisticated text editor that can be configured to insert commands through key-mappings or similar to reduce typing.

If you have a document that's like a reference book or user manual, where most readers dip in and out rather than reading from start to finish, then they may start mid-chapter if they've looked something up from the index (or used the PDF viewer's search function). In which case, they may miss the first link if you are only hyperlinking once per chapter or on first use only. If you hide the links, then they are less intrusive but are still available to help the drop-in reader who may be unfamiliar with the terms.

If you are using commands like \gls (rather than providing the link text with \glslink or \glsdisp), then this can help consistency. For example, in English some compound words are hyphenated and some aren't. I can't always remember, but if I'm using \gls then I only need to look it up when I'm defining the entry not every time I use it. Similarly, if the term requires some special formatting.

For example, both the bib2gls user manual and the accompanying introductory guide have a lot of hyperlinks resulting from \gls (or similar), but they both use:

\usepackage[hidelinks]{hyperref}

so they don't stand out.

If you are using \glslink a lot due to declension, then I recommend adding keys as per Christian's answer. If you do only want the occasional hyperlink, instead of indexing only the first use, another possibility is to switch off the hyperlinks by default and only enable them for specific use cases. For example:

\documentclass{article}

\usepackage[colorlinks]{hyperref}
\usepackage{glossaries-extra}

% \glslinkpresetkeys requires glossaries-extra.sty:
\renewcommand{\glslinkpresetkeys}{\setkeys{glslink}{hyper=false}}

\newglossaryentry{sample}{name={sample},description={an example}}

\begin{document}
\glslink{sample}{an example},
\glslink+{sample}{an example},
\glslink{sample}{an example}.

\printunsrtglossary % requires glossaries-extra.sty
\end{document}

The + modifier acts like a shortcut for the hyper=true option and works for all the \gls and \glstext type of commands, as well as the commands created by \glsaddkey. (The opposite is the * modifier which applies hyper=false.)

If you have an editor, supervisor, proof-reader or beta readers, then it might be worth asking them whether they find hyperlinks helpful or distracting, since writing is ultimately for the reader's benefit.

2

There is no rule whether the entry should be linked or not. Depending on the setup of hyperref etc, links with colored borders may be tedious to read, so just link the first occurence only or use colorlinks as an option to hyperref.

Depending also on the position within the text, it may be convenient to have a link any time you encounter an entry in order to able to jump to the glossary. If unsure, link any occurrence.

Here is a way without explicit \glslink entries, configuring with \glslinkpostsetkeys whether the entry has been used so far.

This way, \glspl and \gls etc. can be used in various ways. If \setkeys{glslink}{hyper=false} is enabled, the link is disabled. In order to enable the first usage with linking, the \glsentrycurrcount macro is evaluated and hyper=false set, see code below.

If any occurence shall be linked, remove the redefinition of \glslinkpostkeys or say hyper=true there.

As a special use case, I have defined the genitiv and genitivplural keys to be applied with German language.

enter image description here

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage{hyperref}
\usepackage{glossaries}

\usepackage{blindtext}



\makeglossaries

\glsenableentrycount


% Either remove this macro redefinition completely or say hyper=true if any occurence shall be linked. 
\renewcommand*{\glslinkpostsetkeys}{%
  \ifnum\glsentrycurrcount{\glslabel}>1% Did we use it more than once?
  \setkeys{glslink}{hyper=false}% 
  \fi
}

% Defining keys with a lovely mix of English and German words ;-)

\glsaddkey{genitiv}{%
  %empty on purpose since German genitive construction is irregular
}{%
  \glsentrygenitiv% no link
}{%
  \Glsentrygenitiv%
}{%
  \glsgenitiv%
}{%
  \Glsgenitiv%
}{%
  \GLSgenitiv%
}

\glsaddkey{genitivplural}{%
  % empty on purpose since German genitive construction is irregular
}{%
  \glsentrygenitivplural% no link
}{
  \Glsentrygenitivplural%
}{%
  \glsgenitivplural%
}{%
  \Glsgenitivplural%
}{%
  \GLSgenitivplural%
}



\newglossaryentry{apple}{%
  name=Apfel,
  plural=Äpfel,
  genitiv=Apfels,
  genitivplural={{Ä}pfel},
  description={Apple}
}



\begin{document}



Der \Gls{apple} war reif. Das Aussehen des \glsgenitiv{apple} entsprach nicht meinen Vorstellungen. 

Die \glspl{apple} waren reif. Das Aussehen der \GLSgenitivplural{apple} ließ zu Wünschen übrig, daher kaufte ich die \glspl{apple} nicht. 

But again in upper case:\GLS{apple} and here in usual German writting: \Gls{apple}


\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.