# Use different names for glossary entry in glossary and in text

\documentclass{article}

\usepackage{glossaries}

\makeglossaries

\newglossaryentry{date}
{
name=1 October 1999,
description={He saw him}
}

\begin{document}

He saw him on \gls{date}.

\printglossaries

\end{document}


This will result in 1 October 1999 on the left of the glossary. However, I would like it to appear as 1999, 1 October because it is easier to read dates in the glossary when the year always comes first. How can you use different names for a glossary entry depending on whether the glossary entries appears in the glossary or in the text?

The glossaries package offers the keys name which is used in the glossary and text which is used in text (defaulting to name if text is not specified), so the correct way would be to use:

 \documentclass{article}

\usepackage{glossaries}

\makeglossaries

\newglossaryentry{date}
{
name={1999, 1 October},
description={He saw him},
text=1 October 1999
}

\begin{document}

He saw him on \gls{date}.

\printglossaries

\end{document}


The output doesn't change (so see below).

One option could be to use a macro to store the name and change its definition for \printglossaries, I don't know how good this works out if you have more than one entry especially regarding the sorting (but there is the sort key to handle that):

\documentclass{article}

\usepackage{glossaries}

\makeglossaries

\newcommand*\myglossaryentry{1 October 1999}
\newglossaryentry{date}
{
name=\myglossaryentry,
description={He saw him},
sort={1999, 1 October}
}

\begin{document}

He saw him on \gls{date}.

\def\myglossaryentry{1999, 1 October}
\printglossaries

\end{document}