# Glossaries per chapter not produced during compile

I am trying to make glossaries per chapter for my book. This per chapter design for the glossary is tested from this answer at TEX.SX. But I am not able to print the glossary at the end of each chapter separately even the program runs but generates only the expanded version of the glossary every time.

Here is a MWE as per answer from earlier post.

\documentclass{book}% I am trying it for book
\usepackage{datatool-base}
\usepackage[counter=chapter,xindy,section=section]{glossaries}
\GlsSetXdyMinRangeLength{0}
\makeglossaries
\newglossaryentry{E}{name={\ensuremath{E}},description={energy}}
\newglossaryentry{m}{name={\ensuremath{m}},description={mass}}
\newglossaryentry{c}{name={\ensuremath{c}},description={speed of light}}
\newglossaryentry{v}{name={\ensuremath{v}},description=velocity}
\newglossarystyle{mystyle}%
{%
\setglossarystyle{list}%
\renewcommand*{\glossaryentrynumbers}[1]{\striprelax##1\endstriprelax}%
\renewcommand*{\glsXchapterXglsnumberformat}[2]{##2}%
\renewcommand*{\delimR}{,}%
\renewcommand*{\glossentry}[2]{%
\edef\doifinlocation{\noexpand\ifinlocation{\thechapter}{##2}}%
\doifinlocation
{%
\item \glossentryname{##1} \glossentrydesc{##1}%
}%
}%
}
\newcommand{\ifinlocation}[3]{%
\DTLifinlist{#1}{#2}{#3}{}%
}
\def\striprelax\relax#1\endstriprelax{#1}
\setglossarystyle{mystyle}

\begin{document}
\chapter{Sample Chapter}
\printglossary
$$\gls{E} = \gls{m}\cdot \gls{c}^2$$
\glsresetall
\chapter{Another Chapter}
\printglossary
$$\gls{E} = \frac{\gls{m}\gls{v}^2}{2}$$
\end{document}

• have you used makeindex or makeglossaries during the compile? for glossaries your make routine should be: pdflatex -> makeglossaries -> 2x pdflatex -> <pdfviewer> – naphaneal Aug 11 '18 at 12:44
• @naphaneal 2 , I am using WinEdt editor and it auto compile in this mode pdflatex > Bibtex > Makeindex > MakeGlossary > pdflatex > pdfviewer. The output glossary is not printed instead where I have use d\gls{E} its simply print E and not the glossary. – Deb bijan Aug 11 '18 at 15:05
• you don't need makeindex in the compile run. just use makeglossaries. I ran your code with the routine in my last comment. it worked fine. – naphaneal Aug 11 '18 at 15:18
• I am receiving these warning pdfTeX warning (dest): name{glo:m} has been referenced but does not exist, replaced by a fixed one Further on simply running of MakeGlossary gives following messages Command Line: makeindex.exe -s "mainbook.ist" -t "mainbook.glg" -o "mainbook.gls" "mainbook.glo" Index style file mainbook.ist not found. Usage: makeindex [-ilqrcgLT] [-s sty] [-o ind] [-t log] [-p num] [idx0 idx1 ...]` – Deb bijan Aug 11 '18 at 15:55
• what basic latex system are you using? (I tried your code with TL 2018, TeXstudio 2.12.10 and it worked smoothly.) Maybe there's something wrong with your version of WinEdt, but I'm the wrong person to ask. Do try if you can run the compile commands from the command line interface for Windows. – naphaneal Aug 11 '18 at 16:12