Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In my document I use the glossariespackage.

When referencing terms, that do not exist in the glossary (yet) the term is simply not displayed. Which IMHO forces a quite complex workflow.

Is there any possibility of displaying non-defined terms, but in a different color?

for example:

\gls{DefinedTerm} would be displayed in my default link-color and

\gls{UndedinfedTerm} would be displayed in another style, like red, underlined.


The following does exactly what i was looking for:


put this in your preamble and simply use \mygls{Term}. Undefined terms will then be highlighted, while defined terms will be displayed using \gls{}

(see JMs answer)

share|improve this question
Please see the update in my answer. With the \let command, you can use only \gls and not worry about switching between your own command and using it. As you update your glossary, the entries will naturally switch from being red/underlined to being used as a normal \gls entry. –  J M Jul 21 '12 at 16:55
beautiful solution indeed - thanks a lot! –  Max Gherkins Jul 21 '12 at 17:36
add comment

1 Answer

up vote 5 down vote accepted


I have updated the command as follows (you must include the xcolor pacakage in order to use the \textcolor command:


You can now use the \gls command for all your entries, and as you define them, they will switch from being red/underlined to being used as a normal \gls entry.


When I compile my thesis (which I'm in the middle of right now) and I include a \gls{UndefinedTerm} my compilation errors out, stating: "Glossary entry UndefinedTerm has not been defined". Does your compilation not fail? I would encourage you to simply add the terms as you go, it is truly not that cumbersome or time-consuming.

It even appears, looking at glossaries.sty, that it should throw an error (from lines 935-940 of glossaries.sty) To someone more able, this may be the place to modify the code and create the output you need.

    \PackageError{glossaries}{Glossary entry `#1' has not been
    defined}{You need to define a glossary entry before you
    can use it.}}%

Otherwise, if all that the \gls for an undefined term will do is print it in red and underline, why not simply make a command for that. You will have to go through the thesis and look for them anyway, then add the entry. I still think that this will be more hassle at the end.

ugls for "Undefined gls" \newcommand{\ugls}[1]{\textcolor{red}{\underline{#1}}}

share|improve this answer
Thank you so much for that! \newcommand{\mygls}[1]{\ifglsentryexists{#1}{\gls{#1}}{\textcolor{red}{\underli‌​ne{#1}}}} did the trick! –  Max Gherkins Jul 21 '12 at 8:05
Oh wonderful! I hadn't thought of using the \ifglsentryexists command. I may include that in my thesis as well. Make sure to include the xcolor package for the \textcolor command. –  J M Jul 21 '12 at 8:30
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.