# Cannot create glossary in memoir using glossaries package

I am using the memoir class. I would like to have key terms/definitions listed first in the chapter that they appear, and then again in the glossary at the end.
However, not only can I not create glossary entries at all, but I also cannot get any glossary, period.

### Error(s)

Any use of e.g. /gls{foo} anywhere breaks everything. Specifically:

Package glossaries Error: Glossary entry foo' has not been defined. ...em [agonist] the process by \gls{foo}
Overriding \printglossary
Overriding theglossary' environment


...and dozens of Underfull \hbox (badness 10000) or Overfull (15.85847pt too wide)  in paragraph. across various chapters.

I have searched exhaustively for a solution, any solution, but what little I could find did not solve the problem: either not specific enough to pertain this exact problem, or I was unable to apply it to my document.

# Minimum (non-)working Example

main.tex

\documentclass[11pt, oneside]{memoir}
\usepackage[utf8]{inputenc}

%%%%%%%%%% Packages %%%%%%%%%%
%%
\usepackage[acronym]{glossaries}

%% For starting tables on new page
\usepackage{afterpage}

%%
\usepackage[english]{babel}

%% For IEEE annotated bibliography
\usepackage[autocite=inline,
backend=biber,
style=ieee]{biblatex}

%%
\usepackage{calc}

%% From TeX stackoverflow: "When using babel or polyglossia with biblatex, loading csquotes is recommended to ensure that quoted texts are typeset according to the rules of your main language."
\usepackage{csquotes}

%% For removing page numbers, headers, etc. from empty pages
\usepackage{emptypage}

%%
\usepackage{enumitem}
\setlist[description]{leftmargin=\parindent,labelindent=\parindent}

%% NSIN -- For removing page numbers on part pages
\usepackage{etoolbox}
\patchcmd{\part}{plain}{partstart}{}{}
\makeatletter
\patchcmd{\@maketitle}{\LARGE}{\fontsize{48pt}{24pt}\selectfont}{}{}
\makeatother

\usepackage{fancyhdr}

%% For margins and page size
\usepackage[a4paper]{geometry}

%%
\usepackage{glossaries}
\makeglossaries

%%
\usepackage{hyperref}

%%
\usepackage{makecell}

%% NSIN
%\usepackage{soul}

%% For sublists
\setlist[itemize]{nosep}
\usepackage{outlines}

%% For breaking up into smaller, more manageable files
\usepackage{subfiles}

%% For underline and strikeout
\usepackage[normalem]{ulem}

%% For highlighting text (in conjunction with soul)
\usepackage[table]{xcolor}

%%% CONFIGURATION %%%
%% Used for subdividing citations into used and unused categories
\DeclareBibliographyCategory{cited}

%%
\let\printglossary\relax
\let\theglossary\relax
\let\endtheglossary\relax

%%%%%%%%%% MACROS %%%%%%%%%%
%% Prepend word 'Chapter' to ToC chapters
\renewcommand\cftchaptername{\chaptername~}

% ceneter column
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}

%% Bullets in front of description items
\let\Item\item
\renewcommand\enddescription{\endlist\global\let\item\Item}

\addto\captionsenglish{% Replace "english" with the language you use
\renewcommand{\contentsname}%
{Contents}%
}

\addto\captionsenglish{% Replace "english" with the language you use
\renewcommand{\appendixname}%
{Appendix}%
}

%% fancyhdr stuff
\pagestyle{fancy}

%% blankpage: blank page
\newcommand\blankpage{\newpage\mbox{}\thispagestyle{empty}\newpage}

%% sectionbreak: starts section on its own page
\newcommand{\sectionbreak}{\clearpage}

%% sectionbreak: starts section on its own page
%\newcommand{\subsectionbreak}{\hfill\\}

%% Used to make ToC chapters use upper-case Arabic numerals
\renewcommand{\thechapter}{\arabic{chapter}}

%% Used to make ToC sections and subsections use Roman numerals upper- and lower-case, resp.
\renewcommand{\thesection}{\Roman{section}.}
\renewcommand{\thesubsection}{\roman{subsection}.}
%\renewcommand{\thesubsubsection}{\roman{subsubsection}}

%% Set table length
%\setlength{\arrayrulewidth}{0.33mm}

%%%%%%%%%% FRONT MATTER %%%%%%%%%%
%% Set ToC and section numbering depth
\settocdepth{section}
\setsecnumdepth{section}

% append '\\ \normalsize{for email, hosting}' immediately after title for subtitle
\title{\HUGE{\bfseries Learnding is Fun}\\[\baselineskip] \LARGE{if ur LaTeX is gud}\vspace{5cm}%
}

\author{\Large by Anon Y. Mous}
\date{\LARGE 2021}
\nocite{*}

%%%%%%%%%% DOCUMENT %%%%%%%%%%
\begin{document}
\frontmatter

% Title Page
\maketitle
\thispagestyle{empty}
\blankpage

%
%\subfile{./chapters/front/abstract}
%\newpage

\setcounter{page}{1}
\tableofcontents*
\listoffigures
\listoftables
%\renewcommand\Decide[1]{}
%\newpage

%
%\subfile{./chapters/front/acknowledgments}
%\newpage

\mainmatter

% chapters
\subfile{./chapters/ch01/ch01}
\subfile{./chapters/ch02/ch02}
\subfile{./chapters/ch03/ch03}
\subfile{./chapters/ch04/ch04}
\subfile{./chapters/ch05/ch05}
\subfile{./chapters/ch06/ch06}
\subfile{./chapters/ch07/ch07}
\subfile{./chapters/ch08/ch08}
\subfile{./chapters/ch09/ch09}
\subfile{./chapters/ch10/ch10}
\subfile{./chapters/ch11/ch11}
\subfile{./chapters/ch12/ch12}
\subfile{./chapters/ch13/ch13}
\subfile{./chapters/ch41/ch41}

% appendices
\subfile{./chapters/appendixA/appendix_a}

\backmatter

% glossaries
\printglossary

% bibliography
%\printbibliography[category=cited]
%\begingroup
%\renewcommand{\cleardoublepage}{}
%\endgroup
\end{document}


Specific chapter (in this case, 11):

/chapters/ch11/ch11.tex

\documentclass[../../main.tex]{subfiles}
\setcounter{chapter}{11}
\label{ch:chapter11}
\clearpage

\newglossaryentry{foo}{name=foo,description={unit of length}}

\begin{document}
\chapter{Principles of Pharmacology}

% putting \gls{foo} anywhere breaks everything

\section*{Definitions}
\begin{description}
\item [agonist] medication that causes stimulation of receptors.
\item [antagonist] medication that binds to a receptor and blocks other medications or chemicals from attaching there.
\item [capsule] gelatin shells filled with powdered or liquid medication.
\item [contraindications] when a medication would either harm the patient or have no positive effect.
\item [diaphoretic] sweating heavily.
\end{description}

\section*{Abbreviations}
\begin{description}[leftmargin=!,labelwidth=\widthof{\bfseries ABCDEF}]
\item [IM] intramuscular
\item [IN] intranasal
\item [IO] intraosseous
\item [IV] intravenous
\item [MDI] metered-dose inhaler
\item [PO] per oral
\item [PR] per rectum
\item [SC] subcutaneous
\item [SL] sublingual
\end{description}\hfill \\


I feel as though I am in "package/config hell" where my package space/ecosystem is so cluttered that finding the specific anomaly is like untangling Christmas lights. In the dark. While wearing heavy gloves. Under local anesthetic. With a concussion.

Needless to say I will be very grateful for any help!

### Edit #1

The section in main.tex

\let\printglossary\relax
\let\theglossary\relax
\let\endtheglossary\relax


is from a previous solution that I attempted. Thank you for pointing it out!

Because sometimes when even the most meticulous diligent well-meaning of us try a million solutions in a row, they forget to revert the one millionth-and-first!

# Solution

See answer (and also this for help installing perl and adding the PATH in Windows).
Second link is for TexMaker, but works the same for TexStudio (in my case).

Thanks again to Simon Dispa for helping me with this very vexing problem!

You will be able to print the glossary in the following way:

Start with a new empty directory with ch11.tex as

\documentclass[./main.tex]{subfiles}

\begin{document}
\setcounter{chapter}{10}
\label{ch:chapter11}
\clearpage

\newglossaryentry{foo}{name=foo,description={unit of length}}

\chapter{Principles of Pharmacology}

Putting \gls{foo} anywhere breaks everything

\section*{Definitions}
\begin{description}
\item [agonist] medication that causes stimulation of receptors.
\item [antagonist] medication that binds to a receptor and blocks other medications or chemicals from attaching there.
\item [capsule] gelatin shells filled with powdered or liquid medication.
\item [contraindications] when a medication would either harm the patient or have no positive effect.
\item [diaphoretic] sweating heavily.
\end{description}

\section*{Abbreviations}
\begin{description}[leftmargin=!,labelwidth=\widthof{\bfseries ABCDEF}]
\item [IM] intramuscular
\item [IN] intranasal
\item [IO] intraosseous
\item [IV] intravenous
\item [MDI] metered-dose inhaler
\item [PO] per oral
\item [PR] per rectum
\item [SC] subcutaneous
\item [SL] sublingual
\end{description}\hfill \\

\end{document}


and main.tex in the same directory with some commented lines:

The double loading of glossaries

%%%%%%%%%% Packages %%%%%%%%%%
%%
%%%\usepackage[acronym]{glossaries}
%%%\makeglossaries


%%%%
\usepackage{glossaries}
\makeglossaries


Also commented

%%
%\let\printglossary\relax
%\let\theglossary\relax
%\let\endtheglossary\relax


Then compile twice main.tex + run makeglossaries.exe (makeglossaries main from the command line, F9 in MikTeX & Texstudio) + compile again.

The first double run will produce a pdf with 6 pages. The last page will be blank. After the last run the Glossary will be typeset there.

This is the final main.tex

\documentclass[11pt, oneside]{memoir}
\usepackage[utf8]{inputenc}

%%%%%%%%%% Packages %%%%%%%%%%
%%
%%%\usepackage[acronym]{glossaries}
%%%\makeglossaries

%% For starting tables on new page
\usepackage{afterpage}

%%
\usepackage[english]{babel}

%% For IEEE annotated bibliography
\usepackage[autocite=inline,
backend=biber,
style=ieee]{biblatex}

%%
\usepackage{calc}

%% From TeX stackoverflow: "When using babel or polyglossia with biblatex, loading csquotes is recommended to ensure that quoted texts are typeset according to the rules of your main language."
\usepackage{csquotes}

%% For removing page numbers, headers, etc. from empty pages
\usepackage{emptypage}

%%
\usepackage{enumitem}
\setlist[description]{leftmargin=\parindent,labelindent=\parindent}

%% NSIN -- For removing page numbers on part pages
\usepackage{etoolbox}
\patchcmd{\part}{plain}{partstart}{}{}
\makeatletter
\patchcmd{\@maketitle}{\LARGE}{\fontsize{48pt}{24pt}\selectfont}{}{}
\makeatother

\usepackage{fancyhdr}

%% For margins and page size
\usepackage[a4paper]{geometry}

%%%%
\usepackage{glossaries}
\makeglossaries

%%
\usepackage{hyperref}

%%
\usepackage{makecell}

%% NSIN
%\usepackage{soul}

%% For sublists
\setlist[itemize]{nosep}
\usepackage{outlines}

%% For breaking up into smaller, more manageable files
\usepackage{subfiles}

%% For underline and strikeout
\usepackage[normalem]{ulem}

%% For highlighting text (in conjunction with soul)
\usepackage[table]{xcolor}

%%% CONFIGURATION %%%
%% Used for subdividing citations into used and unused categories
\DeclareBibliographyCategory{cited}

%% !! what for?
%\let\printglossary\relax
%\let\theglossary\relax
%\let\endtheglossary\relax

%%%%%%%%%% MACROS %%%%%%%%%%
%% Prepend word 'Chapter' to ToC chapters
\renewcommand\cftchaptername{\chaptername~}

% ceneter column
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}

%% Bullets in front of description items
\let\Item\item
\renewcommand\enddescription{\endlist\global\let\item\Item}

\addto\captionsenglish{% Replace "english" with the language you use
\renewcommand{\contentsname}%
{Contents}%
}

\addto\captionsenglish{% Replace "english" with the language you use
\renewcommand{\appendixname}%
{Appendix}%
}

%% fancyhdr stuff
\pagestyle{fancy}

%% blankpage: blank page
\newcommand\blankpage{\newpage\mbox{}\thispagestyle{empty}\newpage}

%% sectionbreak: starts section on its own page
\newcommand{\sectionbreak}{\clearpage}

%% sectionbreak: starts section on its own page
%\newcommand{\subsectionbreak}{\hfill\\}

%% Used to make ToC chapters use upper-case Arabic numerals
\renewcommand{\thechapter}{\arabic{chapter}}

%% Used to make ToC sections and subsections use Roman numerals upper- and lower-case, resp.
\renewcommand{\thesection}{\Roman{section}.}
\renewcommand{\thesubsection}{\roman{subsection}.}
%\renewcommand{\thesubsubsection}{\roman{subsubsection}}

%% Set table length
%\setlength{\arrayrulewidth}{0.33mm}

%%%%%%%%%% FRONT MATTER %%%%%%%%%%
%% Set ToC and section numbering depth
\settocdepth{section}
\setsecnumdepth{section}

% append '\\ \normalsize{for email, hosting}' immediately after title for subtitle
\title{\HUGE{\bfseries Learnding is Fun}\\[\baselineskip] \LARGE{if ur LaTeX is gud}\vspace{5cm}%
}

\author{\Large by Anon Y. Mous}
\date{\LARGE 2021}
\nocite{*}

%%%%%%%%%% DOCUMENT %%%%%%%%%%
\begin{document}
\frontmatter

% Title Page
\maketitle
\thispagestyle{empty}
\blankpage

%
%\subfile{./chapters/front/abstract}
%\newpage

\setcounter{page}{1}
\tableofcontents*
\listoffigures
\listoftables
%\renewcommand\Decide[1]{}
%\newpage

%
%\subfile{./chapters/front/acknowledgments}
%\newpage

\mainmatter

% chapters
%\subfile{./chapters/ch01/ch01}
%\subfile{./chapters/ch02/ch02}
%\subfile{./chapters/ch03/ch03}
%\subfile{./chapters/ch04/ch04}
%\subfile{./chapters/ch05/ch05}
%\subfile{./chapters/ch06/ch06}
%\subfile{./chapters/ch07/ch07}
%\subfile{./chapters/ch08/ch08}
%\subfile{./chapters/ch09/ch09}
%\subfile{./chapters/ch10/ch10}
\subfile{./ch11}
%\subfile{./chapters/ch12/ch12}
%\subfile{./chapters/ch13/ch13}
%\subfile{./chapters/ch41/ch41}

% appendices
%\subfile{./chapters/appendixA/appendix_a}

\backmatter

% glossaries
\printglossary

% bibliography
%\printbibliography[category=cited]
%\begingroup
%\renewcommand{\cleardoublepage}{}
%\endgroup
\end{document}


The main culprits of the problem were (obviously) the lines

%
\let\printglossary\relax
\let\theglossary\relax
\let\endtheglossary\relax

• I could have sworn I tried it without the above problematic section! Another problem was that I did not have perl installed (for anyone with my identical problem in the future). But I'm good now, works 100% tyvm!
– SKNB
Mar 10 at 16:48
• No perl installation needed with MiKTeX + Texstudio! Mar 10 at 18:25
• Interesting. I found no trace of perl on my machine, nor was there any PATH variable set for perl. So I installed Strawberry perl, ran perltex.exe in the MiKTeX folder, and it worked. PATH showed up and everything.
– SKNB
Mar 10 at 22:03

Not a complete answer but more like a request. I have never used the glossaries package but the following works for me.

% glossprob.tex SE 586517  I HAVE NO IDEA PERHAPS IT'S MISUSE OF GLOSSARIES
\documentclass{memoir}
\usepackage[acronym]{glossaries}

\makeglossaries

\begin{document}

\newglossaryentry{foo}{name=foo,description={unit of length}}

Some text. Glossary entry \gls{foo}. More text.

\printglossary

\end{document}


A glossary is not printed and it is unclear to me from the package documentation how to get that done (apologies to the author; the documentation is comprehensive but somewhat overwhelming).

I think it would be very helpful if you actually made your MWE minimal, somewhat like the above. For example no need for all the subfiles --- just put a stripped down version of the ch11.tex code into the body of the document. Eliminate many of the packages and code that have nothing to do with glossaries --- prepending Chapter to ToC entries is irrelevant. And so on. Then it will be so much easier to determine the source of your problem; is it subfiles or a mistaken glossaries setup, or ...?

EDIT

Following @SimonDispa answer and @daleif comment I did manage to get a glossary printed by the following sequence of commands.

pdflatex glossprob
pdflatex glossprob
makeglossaries glossprob
pdflatex glossprob

• Run makeglossaries (I think) Mar 9 at 18:36
• And compile again. Mar 9 at 20:14
• Lamentably my MWE required extensive paring as is :) But your concern is an extremely valid one, and I actually did make every endeavor to trim it down. The balance between less reading for the reader and the author is a delicate one.
– SKNB
Mar 10 at 14:46
• To be fair, from my POV I do not actually know enough about LaTeX to ascertain what IS strictly relevant. Programming in general is rife with seemingly unrelated dependencies interfering with one another in the most Rube Goldberg-esque ways. For instance, I would not have been able to definitively say, beyond any reasonable doubt, that any of the lines above are unrelated to my error. If you told me that my "prepending ToC entries" interfered with the glossary, it would not even be the most far-fetched dependency error I have encountered in LaTeX. But yes I see your point.
– SKNB
Mar 10 at 14:57
• @SKNB Thank you for your understanding. Mar 10 at 19:26