I'm in the process of writing my thesis which has a large glossary. The hyperref and glossaries package allow for linking and colouring the references, which is great. Unfortunately the large number of coloured entries is visually overwhelming. To circumvent this I edited the \glsdisplayfirst and \glsdisplay commands as follows,


which works effectively for \gls, \Gls and \GLS. This allows the first use of the glossary entry to be coloured differently to all subsequent uses. In this case the first entry is "blue" and the rest match the colour of the body text (BLACK). I arrived at these commands mostly by trial and error.

Unfortunately when I add the siunitx package \Gls and \GLS building the document returns the following error.

! Argument of \@declaredcolor has an extra }.
<inserted text> 
l.55 ...lised versions: 1) first letter \Gls{tla},
                                                   and 2) entire word \GLS{t...

The conflict seems independent of where the \usepackage{siunitx} statement is located in the preamble. There does not appear to be a reference to @definecolor in siunitx.sty. \usepackage{siunitx} is commended out in the worked example below, uncomment to produce the error. Although I'm familiar with LaTeX, this is definitely beyond my experience. I'm not sure where to start resolving this issue, any help would be appreciated.

A separate and minor issue: using the command \newacronym disables the two edited commands (\glsdisplayfirst and \glsdisplay) reverting all glossary entries to their original colour "red". Although this is an issue I can work around by only using \gls, any insight into why this happens would also be helpful. Code to test this issue is commented out in the worked example below.

Worked example

% document must be saved as "document.tex" for the makeindex command.
% \usepackage{siunitx}

% Colour
    % black must be capitalised due to the way glossaries works

% Hyperlinks
    \hypersetup{colorlinks = true}

% Glossary
    % define the colour of the first instance
    % define the colour of all subsequent instances
    % as the subsequent entries are capitalised the colour BLACK must be defined

% the following code automates the makeindex process
% borrowed from http://www.freiheitsfreund.de/2010/10/automatically-run-makeindex-from-within-a-latex-document-with-write18/
\execute{makeindex -s document.ist -t document.glg -o document.gls document.glo}



    description={Three Letter Acronym},
    first={Three Letter Acronym (TLA)}

%\newacronym{ana}{ANA}{A New Acronym}

Following is an example of a \gls{tla}.
Repeated again to demonstrate the desired change in colour at subsequent use \gls{tla}.
Again using the capitalised versions: 1) first letter \Gls{tla}, and 2) entire word \GLS{tla}.

%Using the newacronym command \gls{ana}, \Gls{ana} and \GLS{ana}


Thanks in advance for your help.


The second \renewcommand that is causing the issues. By removing it and placing the statement \hypersetup{linkcolor=black} after the table of contents (in my own example) I have been able to achieve the same result without the siunitx conflict; avoiding the problem rather than solving it.


Issue with color

The documentation for \glsdisplay contains a red box:

Care needs to be taken when redefining \glsdisplay and \glsdisplayfirst as commands like \Gls will expand the displayed text before applying \makefirstuc. If you want to use formatting commands, it’s best to define a robust version that deals with all the formatting. For example, suppose you want the text to appear in bold italic, it’s best to do something like:

\DeclareRobustCommand{\textbfit}[1]{\emph{\bfseries #1}}

See the mfirstuc documentation for further details on the limitations of \makefirstuc.

The following works with siunitx:


Issue with \newacronym



to the preamble helped.

  • Thanks for your help @Oberdiek. Those four commands work brilliantly. I'll spend some time reading up on mfirdtuc. RE: \newacronym I get the error (/usr/local/texlive/2013/texmf-dist/tex/latex/glossaries/styles/glossary-tree.s ty)) ! Undefined control sequence. <argument> \glsdefaulttyp l.33 \DeclareAcronymList{\glsdefaulttyp} – user37061 Sep 22 '13 at 8:12
  • Sorry about the formatting there. I'm trying to improve it. – user37061 Sep 22 '13 at 8:15
  • @user37061: A typo, fixed now: \glsdefaulttype. – Heiko Oberdiek Sep 22 '13 at 8:15
  • 1
    @Oberdiek fantastic! It had to be something simple. Thanks again! – user37061 Sep 22 '13 at 8:18

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.