0

This is basically a twelve-year update on this question: Howto achieve capitalized description in glossary table?

Using the glossaries package, I would like the description of an entry to start with an uppercase letter inside the Glossary, but with a lowercase letter in the text body. The solution proposed by David Carlisle here is the following (adapted to be even more of a MWE):

\documentclass{article}

\usepackage{glossaries}

\let\firstchar\lowercase
\let\oldprintglossaries\printglossaries
\def\printglossaries{\let\firstchar\uppercase\oldprintglossaries}

\newacronym{test}{Test}{\firstchar{L}owercase is what I want}
\makeglossaries

\begin{document}

Here is the acronym in the text \gls{test}

\printglossaries

\end{document}

Which produces:

enter image description here

Which is nice (lowercase in text body, uppercase in the Glossary). However, if you put the \printglossaries command before the text body, it doesn't work anymore. I.e.:

\documentclass{article}

\usepackage{glossaries}

\let\firstchar\lowercase
\let\oldprintglossaries\printglossaries
\def\printglossaries{\let\firstchar\uppercase\oldprintglossaries}

\newacronym{test}{Test}{\firstchar{L}owercase is what I want}
\makeglossaries

\begin{document}

\printglossaries

Here is the acronym in the text \gls{test}

\end{document}

Yields:

enter image description here

And the word "lowercase" inside the text body begins with an uppercase, which is not wanted. This is annoying since in writing my thesis, I would like the Glossary to be located before the main body of the document.

I suspect this has something to do with the re-definition of the \lowercase or \firstchar which is called when writing \printglossaries and thus applies to everything below the said command, but I am not enough of a LaTeX expert to be able to solve this. Any help would be appreciated.

Note: I would like to avoid using glossaries-extra if possible since it breaks many things / require many additional commands to make it work as glossaries (i.e. the two of them are not interchangeable out-of-the-box).

1 Answer 1

1

You can simply swap \uppercase with \lowercase along with order in \printglossaries as shown below:

\documentclass{article}

\usepackage{glossaries}

\let\firstchar\uppercase
\let\oldprintglossaries\printglossaries
\def\printglossaries{\oldprintglossaries\let\firstchar\lowercase}

\newacronym{test}{Test}{\firstchar{L}owercase is what I want}
\makeglossaries

\begin{document}

\printglossaries

Here is the acronym in the text \gls{test}

\end{document}

So the idea is that we set \firstchar to uppercase and print the glossary, and then only we redefine \firstchar to lowercase so that anywhere after the glossary chapter, the letter is printed in lowercase as wanted.

3
  • Makes me feel so stupid x) It works great! If you have the time, could you explain why this works (i.e. what the code is exactly doing) in your answer? I guess the code is replacing what should firstchar do before and after the printglossaries command, am I right?
    – mranvick
    Commented May 10 at 12:11
  • 1
    I have added an explanation. Hope it helps :)
    – codeR
    Commented May 10 at 12:16
  • Thanks! I accepted it :)
    – mranvick
    Commented May 10 at 12:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .