Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have the following minimal example in which the \Gls command of the glossaries package does not seem to work.

%%
% listgloss.text
% Minimal file to test functionality and use of glossaries package
%
% Compile as
%
% pdflatex listgloss
% makeglossaries listgloss
% pdflatex listgloss
% pdflatex listgloss
%%
\documentclass[a4paper]{article}
%
\setlength{\parindent}{0pt}
%
\usepackage{xcolor}
\usepackage{hyperref}% Must now be the second-last package that is loaded
\usepackage[acronym]{glossaries}% Must be last package, loaded after hyperref
%
\newglossaryentry{htdoc}{name={hypertext document},description={Text file with references to other content via hyperlinks}}
%
\newglossaryentry{web}{name={World Wide Web},first={World Wide Web (WWW)}, text={WWW},description={A distributed system of linked hypertext documents}}
%
\newacronym{WWW}{WWW}{World Wide Web}
%
\newacronym{HTML}{HTML}{HyperText Markup Language}
%
\newacronym{SGML}{SGML}{Standard Generalized Markup Language}
%
% Define appearance of link on first citation
%
\renewcommand{\glsdisplayfirst}[4]{\textsf{\textcolor{magenta}{#1}}}
%
\makeglossaries

\begin{document}

% Test of glossary entries
% 1. Capitalization
Should be capitalized: \Gls{htdoc}\\
Should be lowercase: \gls{htdoc}\\
% 2. First use
First use of web: \gls{web}\\
Second use of web: \gls{web}\\

% Test of acronym entries
% SGML Is cited and should be listed
\gls{SGML} is another markup language.\\
% WWW is never cited but should appear in acronym list
\glsadd{WWW}\\
% HTML should not appear in acronym list because not cited and not added
%
\printglossaries
%
\end{document}

I am using TeXLive 2010 on 64-bit Linux and the version of glossaries is [2010/07/10 v2.07 (NLCT)].

Can anyone throw light on how to get the correct display, please?

TIA

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

The trouble you've got has to do with what \glsdisplayfirst expects to see and what it actually receives after TeX expands this line in your code:

\renewcommand{\glsdisplayfirst}[4]{\textsf{\textcolor{magenta}{#1}}}

\glsdisplayfirst is trying to capitalize \textsf{\textcolor{magenta}{#1}} which, after expansion, is not in the form it needs to be. You can fix things up by protecting it from expansion first, e.g., like this:

\DeclareRobustCommand\textsfmagenta[1]{\textsf{\textcolor{magenta}{#1}}}
\renewcommand{\glsdisplayfirst}[4]{\textsfmagenta{#1}}

Voila, now things work!

BTW, your "minimal" example was anything but. Maybe something this would have been better (incudes my updated to your code):

\documentclass{article}
\usepackage{xcolor}
\usepackage{hyperref}% Must now be the second-last package that is loaded
\usepackage[acronym]{glossaries}% Must be last package, loaded after hyperref

\DeclareRobustCommand\textsfmagenta[1]{\textsf{\textcolor{magenta}{#1}}}
\renewcommand{\glsdisplayfirst}[4]{\textsfmagenta{#1}}
\makeglossaries

\begin{document}
\newglossaryentry{htdoc}{name={hypertext document},%
                         description={Text file with references}}
Should be capitalized: \Gls{htdoc}

Should be lowercase: \gls{htdoc}

\printglossaries
\end{document}
share|improve this answer
    
Thank you for your explanation as well as solution. And my apologies for posting my overall test file rather than a minimal example. –  chandra Nov 4 '10 at 15:20
3  
@chandra: If this answer solved your problem, it would be best if you mark it as ‘Accepted’ by clicking on the tickmark below the vote count. This assigns reputation points to the author of the answer (and to you!). Moreover, in the new question you just asked, it will look better if it doesn't say "0% accept rate" below your name. You might also want to consider accepting answers to some of your other questions. Thanks! –  Hendrik Vogt Feb 28 '11 at 17:09
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.