LaTeX forum ⇒ Generalglossary | Token Expansion Problem

LaTeX specific issues not fitting into one of the other forums of this category.
wrh
Posts: 1
Joined: Thu Jul 21, 2011 4:04 pm

glossary | Token Expansion Problem

Postby wrh » Thu Jul 21, 2011 6:48 pm

A few years ago I used the makeidx and glossary packages in LaTeX to typeset a glossary in a book. I now have a newer computer and newer MiKTeX (ver. 2.9). After making some text changes in the source file today, I found that the glossary is no longer working. I've isolated the problem to the macro call
  1. \glossary{name=X,description=Y}

Previously X was expanded prior to making the glossary entry but now it is not. Is there a way to force expansion of X in \glossary?

I know glossary is now obsolete but, since I have \glossary entries throughout the book, it would be time-consuming to upgrade to the glossaries package. Given that this is just a token-expansion issue, I hoped that perhaps some TeXpert might have an easy solution.

Here are some details. To make a glossary entry, I use a private macro \glos:

  1. \def\glos<#1:#2>{\parse{#1}%
  2. \glossary{name=\name { \it \gram}, description=#2}}
  3.  
  4. \parse parses #1 into two parts A and B, and makes two gdefs:
  5. \gdef\name{A}\gdef\gram{B}

which feed into \glossary as above. Previously, this resulted in the name being defined as A { \it B} but now it is the unexpanded \name { \it \gram}.

I tried using a token register but I don't understand these well and I couldn't get it to do what I wanted. I also tried some other things (\expandafter, etc.) but I couldn't get them to work either.

I verified that \parse is still defining \main and \gram correctly. Also the following macro which is very similar to \glos works correctly:
  1. \def\indx<#1>{\parse{#1} \index{\name}}

So the problem is indeed just with \glossary expansion.

My whole index-glossary system in the book is quirky but helps to minimize typing: a single macro call handles glossary and indexing (indicators say whether to call \glos and/or \indx in each case). I can get everything to work if I eliminate the parsing macro, but I would then have to manually redo every index/glossary entry in the book, so I'd rather not do that. Also it seems like giving up, rather than getting LaTeX to do what I want it to do.

Thanks for any help or suggestions you may have!
Last edited by cgnieder on Sat Feb 09, 2013 11:00 pm, edited 1 time in total.
Reason: added code markup

User avatar
nlct
Posts: 276
Joined: Thu Nov 06, 2008 11:15 am

Postby nlct » Sat Feb 09, 2013 10:50 pm

It really is best to update to glossaries (for reasons, see How to upgrade from glossary to glossaries). Since you are using \glossary in a macro, why not just change the definition of the macro to use the new commands? For example
  1. \def\glos<#1:#2>{\parse{#1}%
  2. \ifglsentryexists{\name}
  3. {}%
  4. {\newglossaryentry{\name}{name={\name \textit{\gram}},description={#2}}}%
  5. \glsadd{\name}}

You'll need to switch off the sanitization using
  1. \usepackage[sanitize=none]{glossaries}

Regards
Nicola Talbot


Return to “General”

Who is online

Users browsing this forum: Google [Bot] and 6 guests