I'm preparing a document class using the glossaries package to typeset dictionaries. Since many of my entries need figures, tables, and maybe, say, some C++ code, I'd like to know is there a way to put directly these stuff into the description key of the glossaries package?
Here is a simple MWE:
\documentclass[twoside]{book}
\usepackage[]{graphicx}
\usepackage{lipsum}
\usepackage[xindy,nonumberlist]{glossaries}
\makeglossaries
\newcommand{\dict}[4][]{%
\newglossaryentry{#2}%
{%
name=#2,%
symbol=#3,%
description=#4,%
#1%
}%
\glsadd{#2}%
}
\begin{document}
\dict{zero}{n}{\lipsum[4]}
\dict{adhesive}{n}{\lipsum[5]}
\dict{main}{n}{\lipsum[3]}
\dict{material}{n}{\lipsum[1]}
\printglossary
\end{document}
I know that one solution is storing those stuff in a command and then use it as the description, but I don't like this solution. My descriptions are like the below structure:
\dict{lion}{n}{%
Lions live in ...
\begin{center}
\includegraphics[width=3cm]{lion}
\end{center}
They generally eat ...
}
BTW, I must only use xindy
to sort the entries.
\begin{document}
? Or could you define them first and then add them once the document is begun?\begin{document}
.\longnewglossaryentry
and that can only be used in the preamble. It does, however, solve the problem. (See below.) Note that the recommendation is to define or load all entries prior to\begin{document}
and various commands are only available in the preamble. (See the manual for discussion and details.) Why do you want them to be after\begin{document}
?\longnewglossaryentry
because of my old installation. "Why do you want them to be after \begin{document}?" Because I thought by defining the entries before\begin{document}
, I con't use commands like\footnote
, but now I see I was wrong!longtable
in entries and, as you see, you can use paragraph breaks etc. so you have a lot more room to format the entries as you wish.)