1

I am using the glossaries package for acronym handling, and I have already written a large document with many entries all using lowercase labels. However, it turns out that when I use those acronyms in section and chapter headings, they end up in the page headers in uppercase format. As a result, the keys do not work any more, because \acrshort{abc} becomes \acrshort{ABC}.

So since I don't want all of those occurrences to end up in the glossary anyway, I thought the easiest way to deal with this is to define a new command that creates each glossary entry in both uppercase and lowercase, and then moves the uppercase version to a nonexistent secondary glossary.

So here is my attempt:

\documentclass[a4paper,11pt,BCOR=8mm,DIV=14,headsepline,twoside,chapterprefix=true,cleardoublepage=plain]{article}
\usepackage{hyperref}
\usepackage[latin1]{inputenc}
\usepackage[acronym, numberedsection=autolabel, section=section, nomain]{glossaries}
\usepackage{xifthen}
\makeglossaries

\begin{document}
\newcommand*{\newacronymup}[4][]{%
    \ifthenelse{\isempty{#1}}{%
        \newacronym{#2}{#3}{#4}%
        \newacronym{{\expandafter\MakeUppercase\expandafter{#2}}}{#3}{#4}%
    }{%
        \newacronym[sort=#1]{#2}{#3}{#4}%
        \newacronym[sort=#1]{{\expandafter\MakeUppercase\expandafter{#2}}}{#3}{#4}%
    }%
    \glsmoveentry{\MakeUppercase#2}{null}%
}%
\newacronymup[sorting123]{gasp}{GASP}{Global Atmospheric Sampling Program}
\newacronymup{sqp}{SQP}{Sequential Quadratic Programming}

Test
\gls{sqp}
\gls{gasp}

\printglossary[type=\acronymtype] % acronyms
\end{document}

If I comment out the three lines with \MakeUppercase in them, everything works as expected. But I can't seem to figure out how to make the labels uppercase without breaking it. I always end up with an error along the lines of

! Missing \endcsname inserted.
<to be read again>

If I just test the \expandafter\MakeUppercase\expandafter{#2} part, it also works, which is why I don't really know how to debug the problem further.

JulianHzg
  • 111

0 Answers0