I'm looking for a way of creating glossaries, with the help of glossaries
package, per chapter or section.
In a particular glossary for section should be only the terms used in this section. If term is used in multiple section – appear in correspondent glossaries.
Example (done with the help of description
environment, just for an example):
How can I achieve this?
Best Answer
Since you don't seem interested in the location list, you could change the location counter to
section
and define a glossary style that checks if the current section is in the location list. You'll probably want to neaten the glossary, but here's an example:¹Note that this uses xindy rather than makeindex to suppress the range formation, which makes it easier to test if the current section is in the list.
The result looks like:
Here's an alternative approach that uses
bib2gls
with theglossaries-extra
extension package. The entries are now defined in a.bib
file, for examplesyms.bib
:The document code now looks like:
The result is the same as before. If you want to use the
hyperref
package then you need to make a minor adjustment to prevent duplicate target names:This makes
\gls
link to the main (full) glossary at the end of the document.¹ The original answer used some now deprecated commands
\glossarystyle
(now\setglossarystyle
) and\glossaryentryfield
:These should not be used with v4.0 onwards.