# Warn if text item should be a glossary entry

I'm writing a large document and I have several glossary entries and one thing that worries me is my potential to miss a glossary entry. An example would be:

Glossary entries:

\usepackage[acronym]{glossaries}
\newacronym{UI}{UI}{user interface}
\newglossaryentry{HTML}
{
name={HTML},
description={Hyper Text Markup Language is the standard tagging library to help generate web pages from text files}
}
\makeglossaries


And then in my text I might put:

Blah blah blah blah blah UI blah blah blah \gls{UI} blah blah blah.
Blah blah blah blah blah HTML blah blah blah \gls{HTML} blah blah blah.


I've correctly referenced the glossary entry the 2nd time, but forgotten to do it the first, what a muppet. At the moment, I would never be warned of this "mistake" and would have to manually check my document for other such errors. Is there any package available that could do that check for me?

Full MWE

I've added in the package hyperref to show the first time the text used isn't being considered a glossary entry. It also doesn't appear as a page number in the said glossary:

\documentclass[a4paper]{report}
\usepackage[bookmarks=true]{hyperref}
\usepackage[acronym]{glossaries}
\newacronym{UI}{UI}{user interface}
\newglossaryentry{HTML}
{
name={HTML},
description={Hyper Text Markup Language is the standard tagging library to help generate web pages from text files}
}
\makeglossaries
\begin{document}
Blah UI blah
\pagebreak
blah \gls{UI} blah HTML blah
\pagebreak
blah \gls{HTML} blah
\printglossaries
\end{document}

• Could you add a bit to the code you paste to make it compilable? That will make helping you so much easier for others and increases your chances of getting an answer – sheß May 4 '16 at 11:48
• Done as requested – Draken May 4 '16 at 11:55
• Unfortunately I think this isn't possible or too complex for TeX. It needs some kind of markup. A better approach might be to write a script to parse the .tex file. It's similar to the problem in automated indexing against keyword file – Nicola Talbot May 4 '16 at 12:06
• Shame if that is the case, I'll write a little program that should be able to do that and post it here in case anyone else would want it – Draken May 4 '16 at 12:09
• @Draken That would be useful :-) – Nicola Talbot May 4 '16 at 12:32

This answer uses XeLaTeX and xesearch, but essentially does what you want. There are mainly two things that you might want to work on if you really use this:

1. The displayed abbreviations are manually replaced by version with an extra \hspace{0pt} to avoid them from causing warnings as well. You might find a way to automatize this based on what the glossaries package provides.

2. It requires that you manually add a list of acronyms to be matched ({UI,HTML}) this is also nicer if updated.

Lastly, note that xesearch is currently unsupported. But it still runs.

Code:

\documentclass[a4paper]{report}
\usepackage[bookmarks=true]{hyperref}
\usepackage[acronym]{glossaries}
\newacronym{UI}{U\hspace{0pt}I}{user interface}
\newglossaryentry{HTML}
{
name={H\hspace{0pt}TML},
description={Hyper Text Markup Language is the standard tagging library to help generate web pages from text files}
}
\usepackage{xesearch}

\makeatletter
\SearchList*{warnme}{#1\@latex@warning{#1 not marked as glossary entry}}{UI,HTML}
\makeatother

\makeglossaries
\begin{document}
Blah blah blah blah blah UI blah

blah blah \gls{UI} blah blah blah

Blah blah blah blah blah HTML blah

blah blah \gls{HTML} blah blah blah

\printglossaries
\end{document}


Warning output:

• Using xesearch results in a lot of errors in TeXstudio, I've created an empty file with the following: \documentclass[a4paper]{report} \usepackage{xesearch} \begin{document} \end{document} And I get errors like Undefined control sequence. \XeTeXinterchartoks – Draken May 4 '16 at 15:39
• Are you compiling it with XeLaTeX? – sheß May 4 '16 at 15:43
• Not used that before, is it something obvious I'm missing? – Draken May 4 '16 at 15:45
• Ah, found the option, testing again – Draken May 4 '16 at 15:46
• let me know if it's working for you – sheß May 4 '16 at 18:21