2

So I love the glossaries package, and have it tweaked and automated about as well as I'd like it. However, I'm still having one issue: how do I format the symbol in the glossary? I'd like to have it display in a different color than the surrounding text. MWE:

\documentclass{article}
\usepackage{glossaries}
\usepackage{glossary-mcols}
\setglossarystyle{mcolindex}
\makeglossaries
\newglossaryentry{examp}{name={EXAMPLE},%
    description={Just showing what I mean},%
    symbol={Ex.}%
}
\begin{document}
This is my \gls{examp}.
\printglossary
\end{document}

I could clearly redefine the mcolindex glossary style, which itself is a slightly modified version of the index glossary style, but the package is so complete and customizable that I can't help but think there's an easier way to do it. I tried to do it as explained in the manual glossaries-user:

\newglossarystyle{newglssty}{%
    \setglossarystyle{mcolindex}%
    \renewcommand*{\glossentrysymbol}[1]{\textcolor{blue}{##1}}%
}%
\setglossarystyle{newglssty}

But for reasons that aren't clear to me, this produces the glossary key ("examp") where I'd expect the symbol to be.

Can anyone help point out what I'm missing here?

3
\renewcommand*{\glossentrysymbol}[1]{\textcolor{blue}{##1}}%

is the wrong redefinition of \glossentrysymbol -- it's just defined now to print the key in blue colour, not to use the key, fetch its symbol and display this in blue colour.

One way to bypass this is to safe the original \glossentrysymbol command and wrap the \textcolour{blue}{\glossentrysymbolorig{##1}} around this in the \renewcommand*

\documentclass{article}
\usepackage{xcolor}
\usepackage{glossaries}
\usepackage{glossary-mcols}
\setglossarystyle{mcolindex}
\makeglossaries
\newglossaryentry{examp}{name={EXAMPLE},%
    description={Just showing what I mean},%
    symbol={Ex.}%
}

\let\glossentrysymbolorig\glossentrysymbol
\newglossarystyle{newglssty}{%
    \setglossarystyle{mcolindex}%
    \renewcommand*{\glossentrysymbol}[1]{\textcolor{blue}{\glossentrysymbolorig{##1}}}%
}%
\setglossarystyle{newglssty}
\begin{document}
This is my \gls{examp}.
\printglossary
\end{document}

enter image description here

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.