MakeIndex, Nomenclature, Glossaries and AcronymsCombining glossaries and index?

Information and discussion about MakeIndex - the tool to generate subject indices for LaTeX documents.
Post Reply
eezacque
Posts: 7
Joined: Mon Jan 06, 2020 5:47 pm

Combining glossaries and index?

Post by eezacque »

I am working on a document where glossary entries are referred to from the index. This works, until I add conditional text, indicating whether a description was added or not. It looks like TeX falls into an unbounded recursion, but I cannot seem to wrap my head around this. Without adding an index entry, this works. Any help is appreciated.

Code: Select all

\documentclass{article}

\usepackage{imakeidx}
\usepackage{enumitem}
\usepackage[automake]{glossaries}

\makeindex

\makeatletter
\def\ifentry#1#2#3{%
    \edef\tmp{#1}%
    \ifx\tmp\@empty%
        #3%
    \else%
        #2%
    \fi%
}
\makeatother

\newglossarystyle{descriptiontest}{%

    \setglossarystyle{indexgroup}

    \renewcommand{\glossentry}[2]{
        \item \textbf{{\glossentryname{##1}}}
        \edef\tmp{\glsentrydesc{##1}}
        \ifentry\tmp{Description: '\tmp'}{No description}

    }
} 

\newglossaryentry{ham}{name={ham}, description={goes with eggs\index{ham}}}     
\newglossaryentry{eggs}{name={eggs}, description=}     

\makeglossaries



\begin{document}

 \glsaddall

 \printglossary[style=descriptiontest]

\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
eezacque
Posts: 7
Joined: Mon Jan 06, 2020 5:47 pm

Combining glossaries and index?

Post by eezacque »

Sorted out by Nicola Talbot on usenet group comp.text.tex:
The glossaries package comes with conditional commands for testing if a
key has been set. \ifglshasdesc not only tests for an empty description
but also tests if the description has simply been set to \nopostdesc:
Post Reply