18

Is it possible to write a word in uppercase in the glossaries but in lowercase in the text? I could use \glslink instead of \gls, but is there no better solution?

Here is an example to clarify what I want:

\documentclass[a4paper]{article}

\usepackage{hyperref}
\usepackage{glossaries}

\makeglossaries
\newglossaryentry{lowercase}{name={lowercase}, description={In the glossary, this word should be capitalized}}
\newglossaryentry{uppercase}{name={Uppercase}, description={This word is capitalized}}

\begin{document}

Should both be lowercase: \gls{lowercase}, \gls{uppercase}.

Workaround: \gls{lowercase}, \glslink{uppercase}{uppercase}.

\printglossaries

\end{document}

This yields:

Should both be lowercase: lowercase, Uppercase.
Workaround: lowercase, uppercase. 

Glossary
lowercase In the glossary, this word should be capitalized. 1
Uppercase This word is capitalized. 1
32

There is a simple solution. You can set the text that appears in the glossary and the text that appears in the... text separatly.

\newglossaryentry{uppercase}{
    name={Uppercase},
    text={uppercase},
    description={Appears uppercase in the glossary and lowercase in the text}
}
1
  • 2
    The most brilliantly simple solution among some really hacky ones elsewhere, ty sir/ma'm :) – akaIDIOT Mar 8 '13 at 9:56
4

It is possible to use both upper and lower case in the text;\Gls{} will give the capitalized word or term, as in the beginning of the sentence. In other locations, \gls{} can also be used for the lowercase form. See section 3 of the beginner's guide. I'm not sure if this exactly addresses the question asked, but it is a common usage for which people might find this question.

3

For future users encountering same trouble:

I ran into the problem myself and found this question and its duplicate. @Nitram's solution was useful in the case of a first word defined as a macro. However:

  • I didn't want to duplicate all the name entries,
  • I did want to keep control of what is capitalized and what isn't (case of mathematical symbols as first characters),
  • I wanted to keep the usual behaviour if nothing is specifically asked.

From an answer by @nicola-talbot there, I found a simple redefinition that does the trick:

\usepackage{mfirstuc}
\renewcommand{\glsnamefont}[2][]{\capitalisewords{#1}\xspace#2}

Examples:

Usage: outputs "First word capitalized" in the glossary, and \gls{firstexample} in-text outputs "first word capitalized":

\newglossaryentry{firstexample}{
  name={first}{word capitalized}
}

This won't work with a macro (will capitalize whole word), hence use of text field:

\newglossaryentry{boite}{
  name={\Boite de valeurs},
  text={\boite de valeurs}
}

I have maths first, normal use of name: both in the glossary and in-text \gls{firstexample} output "$i$-th blabla":

\newglossaryentry{iblabla}{
  name={$i$-th blabla}
}
3

I've used Nicola's answer, since none of the answers here worked for me.

The glossaries-extra package allows to easily setup the capitalization with firstuc. I didn't had to change much of my previews code, nor calls. Just change the package and add the following code:

\setglossarystyle{long}
\setabbreviationstyle[acronym]{long-short}
\glssetcategoryattribute{acronym}{glossdesc}{firstuc}
2
  • Is there a way to capitalize the first letter of each word? – Sndn Mar 19 '19 at 19:38
  • @Sndn I think you could consider reading about the package mfirstuc and also this question: tex.stackexchange.com/a/304123/75648 – G. Bay Mar 28 '19 at 14:43

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.