12

UPDATE: I have been using glassaries for some time now, and kind of got used to it. It's not as bad as I at first thought.

Is there a nicer alternative to glossaries package? It's a pita to use. Documentation is lacking examples, some commands don't do anything (like \glssee), it is hard to customize (why can't I make my glossary a simple section?), it is stateful - I have to call makeglossaries in a certain place, and also the syntax for defining new entries is ugly:

 \newglossaryentry{blah}{name=blah, description={blabh lbah blah}}   

It's like xml.

No offense to the creators, but I am just curious if anyone else feels this way and if there are alternatives?

  • 4
    I hope you both mean "lovely" for "like xml" – David Carlisle Jun 13 '12 at 22:58
  • 3
    \glssee does ‘something’ if you use it after \makeglossaries. – mhp Jun 14 '12 at 08:42
  • 1
    You are writing a book-type document and want your glossary to appear in a simple section? Try, for example, \usepackage[section=section, numberedsection]{glossaries}. – mhp Jun 14 '12 at 08:47
  • 4
    Undoubtedly, the glossaries package is rather complex, but, in my experience, it enables you to realize nearly anything related to glossaries, lists of acronyms, notations etc. Since the glossaries package includes tree-like styles it might also serve as a replacement for many index-related packages. Moreover, I haven’t seen any package that supports xindy in a comparable manner. – mhp Jun 14 '12 at 08:52
  • What is this xindy? It is mentioned everywhere in the docs, but never explained what it is or why one would use it. – Andriy Drozdyuk Jun 14 '12 at 16:32
  • Traditionally, the makeindex program is used for sorting indexes and glossaries. xindy is an advanced alternative to makeindex that supports multiple languages and input encodings (e.g. UTF-8). – mhp Jun 14 '12 at 21:15
  • @mhp Do I still need it if I use xelatex? – Andriy Drozdyuk Jun 15 '12 at 03:26
  • Yes. The input of both makeindex and xindy is simply a file written by LaTeX. It’s not relevant whether the underlying TeX engine supports Unicode natively (such as XeTeX and LuaTeX) or not (such as pdfTeX). – mhp Jun 15 '12 at 06:21
  • 3
    Would you prefer to have a command that had at least 18 optional arguments? That's the alternative to key=value syntax. The glossaries package comes with 21 sample files and a beginners' guide for people who find the main user manual too large. If something doesn't work, provide a MWE rather than just saying it's a pita. – Nicola Talbot May 05 '13 at 11:45
  • Awesome question. I hope there is a good alternative available. – Dan Aug 26 '13 at 22:34
  • @Dan if there were a good alternative available, people would surely be using it. so perhaps the people who don't like glossaries should actually write code that does what they fancy. (something with lots of options, but none of this new-fangled key-value stuff, and so on.) – wasteofspace Aug 30 '13 at 14:23
  • @wasteofspace the key/value is not my issue. The need for using Perl and doing things outside of the TeX file is the problem. I actually think the stuff done in the TeX file with glossaries is quite simple. It just won't display without first running a Perl utility against the glossaries file. This is a problem for folks like me who are writing code so that users don't have to even know what LaTeX is in order to generate documents with it. – Dan Aug 30 '13 at 14:42

3 Answers3

7

Here is an alternative to a pita.

\documentclass[11pt]{book}
\usepackage{lstdoc,lipsum}
\begin{document}
\makeatletter
\def\alist{}

\let\sort\lst@BubbleSort 
\def\addtolist#1#2{
  \lst@lAddTo\alist{#2}
}

\long\gdef\addterm#1#2{\addtolist\alist{#1,}}

\def\gentry#1#2{%
\long\expandafter\gdef\csname#1\endcsname{\textbf{#1}: #2}
\addterm{#1}{#2}
\sort\alist
}

\def\PrintGlossary{%
  \@for \i:=\alist\do{%
  \csname\i\endcsname\par}
}
%example
\gentry{electrolyte}{Substance containing free ions that make t
        he substance electrically conductive}
\gentry{battery}{\lipsum[3]}
\gentry{poles}{\lipsum[1]}
% print the glossary
\section{Glosary}
\PrintGlossary


\battery
\makeatother
\end{document}

Add ingredients to suit.

It provides one non-xml command:

  \gentry{<term>}{<description>}

...and it does not need Perl. Enjoy!

yannisl
  • 117,160
5

I changed the code above, so that you can do cross references:

\documentclass[11pt]{book} 
\usepackage{lstdoc,lipsum} 
\usepackage{hyperref}
\begin{document} 
\makeatletter 
\def\alist{} 

\let\sort\lst@BubbleSort  
\def\addtolist#1#2{ 
  \lst@lAddTo\alist{#2} 
} 

\long\gdef\addterm#1#2{\addtolist\alist{#1,}} 

\def\gentry#1#2{% 
\long\expandafter\gdef\csname.#1\endcsname{\hypertarget{target#1}{\textbf{#1}: #2}}
\expandafter\gdef\csname#1\endcsname{\hyperlink{target#1}{#1}}
\addterm{#1}{#2} 
\sort\alist 
}

\def\gentryP#1#2#3{% 
\expandafter\gdef\csname#3\endcsname{\hyperlink{target#1}{#3}}
\long\expandafter\gdef\csname.#1\endcsname{\hypertarget{target#1}{\textbf{#1}: #2}}
\expandafter\gdef\csname#1\endcsname{\hyperlink{target#1}{#1}}
\addterm{#1}{#2} 
\sort\alist 
} 

\def\PrintGlossary{%
  \section{Glosary} 
  \ 

  \@for \i:=\alist\do{% 
  \csname.\i\endcsname\par} 

  \newpage
}


%example 
\gentry{electrolyte}{Substance containing free ions that make t 
        he substance electrically conductive}
% use gentryP if the plural is irregular         
\gentryP{battery}{\lipsum[3]}{batteries} 
\gentry{poles}{\lipsum[1]}

% print the glossary 
\PrintGlossary 

\section{normal text}

\electrolyte s are used nearly everywhere.



\newpage

\battery is the singular. but sometimes you need the plural \batteries.



\makeatother 
\end{document}
1

The datagidx package in the datatool bundle might a good solution for you.

Datagidx is an improved version of the code discussed in this article.

Here is some package documentation and a sample document.

I have not tried this myself yet, but it is the one I have settled on trying as my first approach because I don't like that the glossaries package has external dependencies.

Edit: I have now tried this on one project. It works works nicely but can be a slight bit confusing at first, but I haven't tried any of the other solutions to this so I can't really compare them.