Text Formattingglossaries | User Keys do not appear

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
sauvage
Posts: 3
Joined: Fri Sep 14, 2012 3:07 pm

glossaries | User Keys do not appear

Post by sauvage »

With the glossaries package, instead of having (long style):

name description.

in the glossary, I would like to use the user key user1 and display:

name user1 (in italic), description

For that purpose, I have defined my own style, but the user key user1 does not appear in the PDF. After investigations, I realize that it does not appear in the GLS and GLO files as well. Where am I wrong? My test code is the following:

Code: Select all

\documentclass{book}

\usepackage{glossaries}[2012/05/21]

\newglossarystyle{mystyle}{%
   \glossarystyle{long}
   \renewcommand*{\glossaryentryfield}[5]{%
     \glstarget{##1}{##2} &%
     \textit{\glsentryuseri{##1}}, ##3 \\%
   }
}

\makeglossaries %% Créer la liste des acronymes

\begin{document}

\printglossary[style=mystyle]

\newglossaryentry{keyOne}{
name=nameOne,
description={descOne},
user1={userOne}
}
\gls{keyOne}

\newglossaryentry{keyTwo}{
name=nameTwo,
description={descTwo},
user1={userTwo}
}
\gls{keyTwo}

\end{document}
Last edited by localghost on Fri Sep 14, 2012 5:56 pm, edited 2 times in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

glossaries | User Keys do not appear

Post by cgnieder »

Actually I have no idea why your code isn't working. The first thing I did when looking for a solution was to rearrange your code and then it worked...

Code: Select all

% arara: pdflatex
% arara: makeglossaries
% arara: pdflatex
\documentclass{book}

\usepackage{glossaries}[2012/05/21]

\newglossarystyle{mystyle}{%
   \glossarystyle{long}
   \renewcommand*{\glossaryentryfield}[5]{%
     \glstarget{##1}{##2} &%
     \textit{\glsentryuseri{##1}}, ##3 \\%
   }
}

\makeglossaries %% Créer la liste des acronymes

\newglossaryentry{keyOne}{
  name        = nameOne,
  description = {descOne},
  user1       = {userOne}
}

\newglossaryentry{keyTwo}{
  name        = nameTwo,
  description = {descTwo},
  user1       = {userTwo}
}

\begin{document}

\glsaddall
\printglossary[style=mystyle]

\end{document}
Regards
site moderator & package author
User avatar
nlct
Posts: 276
Joined: Thu Nov 06, 2008 11:15 am

glossaries | User Keys do not appear

Post by nlct »

For that purpose, I have defined my own style, but the user key user1 does not appear in the PDF. After investigations, I realize that it does not appear in the GLS and GLO files as well.
The user keys don't get written to the glossary files as they aren't used for sorting.

Code: Select all

\printglossary[style=mystyle]

\newglossaryentry{keyOne}{
name=nameOne,
description={descOne},
user1={userOne}
}
\gls{keyOne}
In the above, you've reference the user keys (in \printglossary) before they've been defined, which is why they haven't appeared. (\glsuserentryi etc don't check for the existence of the entry to ensure they are expandable.)

Regards
Nicola Talbot
sauvage
Posts: 3
Joined: Fri Sep 14, 2012 3:07 pm

glossaries | User Keys do not appear

Post by sauvage »

Thanks for your response. As I need to declare the glossary entries in the document, i.e. after \begin{document} and \printglossary, I finally use the symbol key instead of the user1 key. It's now working fine:

Code: Select all

\documentclass{book}

%% === Acronymes ===
\usepackage{glossaries}[2012/05/21]

\newglossarystyle{mystyle}{%
   \glossarystyle{long}
   \renewcommand*{\glossaryentryfield}[5]{%
     \glsentryitem{##1}
     \glstarget{##1}{##2} &%
     \textit{##4}, ##3 \\%
   }
}

\makeglossaries %% Créer la liste des acronymes

\begin{document}

\printglossary[style=mystyle]

\newglossaryentry{keyOne}{
name=nameOne,
description={descOne},
symbol={userOne}
}
\gls{keyOne}

\newglossaryentry{keyTwo}{
name=nameTwo,
description={descTwo},
symbol={userTwo}
}
\gls{keyTwo}

\end{document}
Last edited by cgnieder on Tue Sep 18, 2012 11:07 am, edited 3 times in total.
Post Reply