# glossaries and REnewglossaryentry

I haven't found anywhere and I wonder is there or would it be very hard to provide a command \REnewglossaryentry[2] for the glossaries package.

Name for the desired command is kinda self explanatory, but bellow is a wanna-be-MWE of what I am looking to achieve:

% !TEX TS-program = arara
% !TEX encoding = UTF-8 Unicode
% arara: xelatex
% arara: makeglossaries
% arara: xelatex
% arara: makeglossaries
% arara: xelatex
% arara: xelatex

\documentclass[a4paper,12pt,onecolumn,oneside,openright]{book}
\pagestyle{plain}

\usepackage[%
xindy,%
acronym,%
toc=true,%
shortcuts,%
style=altlist,
sanitize={%
name=false,%
description=false,%
symbol=false%
}%
]{glossaries}

\makeglossaries

\newglossaryentry{somethingGloss}{
name            = {something},
description     = {some\ldots{} description},
sort            = {something}
}

\newglossaryentry{aSTH}{
type            = {\acronymtype},
first           = {a something (STH){\protect\glsadd{electroencephalographyGloss}\protect\index{electroencephalography}}},
description     = {some\ldots{} description},
see             = [see Glossary:]{somethingGloss},
sort            = {aSTH}
}

% % % % % %
\newcommand{\REnewglossaryentry}[2]{%
some serious stuff here%
to REset the the key-val list%
for a label given!}

\begin{document}

\gls{aSTH}, subsequent \gls{aSTH} is \gls{somethingGloss}

\REnewglossaryentry{label}{new key-val list}

% % % % % %
\REnewglossaryentry{aSTH}{ % % % command desired to REset the key-val list!
type            = {\acronymtype},
name            = {aSTH{\protect\index{electroencephalography}}},
first           = {a something (STH)}},
description     = {some\ldots{} NEW description},
see             = [see Glossary:]{somethingGloss},
sort            = {aSTH}
}

\printglossary

\printglossary[type=\acronymtype]

\REnewglossaryentry{somethingGloss}{new key-val list} % allow to
% change the properties for the somethingGloss to be shown
% in the new occurence of the glossary
% (sort of a test for the \REnewglossaryentry)

\printglossary

\end{document}


Using name = {aSTH{\protect\glsadd{electroencephalographyGloss} \protect \index{electroencephalography}}}, saves a lot of typing hassle in the document body but gets me into serious trouble when typesetting the Glossary

I have tried to produce a minimal example of that trouble, but (contrary) this little-awkward-bastard worked fine, opposite to what my document does when I introduce the \protect\glsadd{...} in the name key. In such case typically page numbers for the references inside of the Glossary are getting all twisted and screwed. And one doesn't really need the extra cross-reference functionality in the glossary since we have the see= key and the \glshyperlink{} available...

Therefore updating at least name= and first= for an entry (label) just before printing of the Glossaries would alleviate problems with cross-reference-loops, etc.

Also, I think that such command may provide various other usability benefits...

Unfortunately this can't be done as it will interfere with the indexing process. In order to explain this, let's consider the following example:

\documentclass{article}

\usepackage{glossaries}

\makeglossaries

\newglossaryentry{sample}{name={Sample},%
description={A sample description},%
symbol={\textbf{S}}%
}

\begin{document}

% Page 1
\gls{sample}.

\newpage
% Page 2
\gls{sample}.

\printglossaries

\end{document}


Each time an entry is referenced using a command like \gls a line is written to the .glo file. By the end of the document, the .glo file contains a list of \glossaryentry lines. The above example generates a file that contains the following:

\glossaryentry{Sample?\glossaryentryfield{sample}{\glsnamefont{Sample}}{A sample description}{\textbf {S}}|setentrycounter[]{page}\glsnumberformat}{1}
\glossaryentry{Sample?\glossaryentryfield{sample}{\glsnamefont{Sample}}{A sample description}{\textbf {S}}|setentrycounter[]{page}\glsnumberformat}{2}


The indexing application (makeindex in this case) parses this file and collects the information in each \glossaryentry{term}{location}. All the entries with the same term part are collated into a single entry. The call to makeindex (either explicitly or implicitly via makeglossaries) creates the .gls file that contains the code for the glossary. The above example produces this:

\glossarysection[\glossarytoctitle]{\glossarytitle}\glossarypreamble
\glossaryentryfield{sample}{\glsnamefont{Sample}}{A sample description}{\textbf {S}}{\glossaryentrynumbers{\relax
\setentrycounter[]{page}\glsnumberformat{1\delimN 2}}}%
\end{theglossary}\glossarypostamble


It's this file that is read in by \printglossaries. Any change to the term's name, description or symbol will have no effect on how it is displayed in the glossary, because the original name, description and symbol are explicitly written in the .gls file.

Now suppose that on page 3 the name of the term is changed to, say, New Sample and another \gls{sample} is used. This means that at the end of the run the .glo file now looks like:

\glossaryentry{Sample?\glossaryentryfield{sample}{\glsnamefont{Sample}}{A sample description}{\textbf {S}}|setentrycounter[]{page}\glsnumberformat}{1}
\glossaryentry{Sample?\glossaryentryfield{sample}{\glsnamefont{Sample}}{A sample description}{\textbf {S}}|setentrycounter[]{page}\glsnumberformat}{2}
\glossaryentry{Sample?\glossaryentryfield{sample}{\glsnamefont{New Sample}}{A sample description}{\textbf {S}}|setentrycounter[]{page}\glsnumberformat}{3}


From the point of view of makeindex, there are now two distinct entries in the glossary and it will list them separately like this:

\glossarysection[\glossarytoctitle]{\glossarytitle}\glossarypreamble
\glossaryentryfield{sample}{\glsnamefont{Sample}}{A sample description}{\textbf {S}}{\glossaryentrynumbers{\relax
\setentrycounter[]{page}\glsnumberformat{1\delimN 2}}}%
\glossaryentryfield{sample}{\glsnamefont{New Sample}}{A sample description}{\textbf {S}}{\glossaryentrynumbers{\relax
\setentrycounter[]{page}\glsnumberformat{3}}}%
\end{theglossary}\glossarypostamble


So you now get both "Sample" and "New Sample" in the glossary.

If you use xindy rather than makeindex the format of the .glo file is different, but the principle (and result) is the same.

From what I can gather from your question, your concern arises from a problem caused by having \glsadd or \index in the name in the glossary. In which case, why not just use those commands in the text field and omit them in the name field. For example:

\newglossaryentry{aSTH}{
type            = {\acronymtype},

• btw, this is parallel what i have done last night --- I have used user1= with the same content as name= but with the additional commands. I have used user1= because I think I don't understand quite well the purpose and functionality of text=. Is it prioritized in any way (over other keys)? When not assigned a value explicitly is it getting its value from name= or symbol=? Will that be a decent and complying with best practices if I define entry with text=Ω, name=ohm and symbol=Ω? And then is it any difference to call for it with either \gls{ohm} \glssymbol{ohm} – NeuroTeX Jul 3 '13 at 13:09
• @NeuroTeX The value of text defaults to the value of name. The name value is used in the glossary and via commands like \glsentryname. The text value is used by \gls (after first use) and \glsentrytext. The difference between using text and symbol comes with the difference between using \gls (varies according to first and subsequent use) and \glssymbol (always displays the symbol value). – Nicola Talbot Jul 3 '13 at 18:39