1

I use the Glossaries package to create both an glossary and a list of acronyms. Now I need a way to determine whether a given term is defined in the glossary (\newglossaryentry {term} ...) or in the acronym list (\newacronym {term} ...).

The package does provide \ifglsentryexists but it only checks for general existence of the entry.

MWE:

\documentclass[english]{article}

\usepackage{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{glossaries}

\makeglossaries

\newglossaryentry{foo} {name = {Foo}, description = {``foo'' glossary entry}}
\newacronym{bar} {BAR} {``bar'' acronym}

\begin{document}

If \gls{foo} is a normal glossary entry a ``X'' should follow, if
its an acronym we want its long form (\\glsentrylong{foo}) instead: ???

\printglossary

\end{document}

1 Answer 1

3

In the form you are using glossaries there is no distinction between foo and bar: both are of type main, as \newacronym will only call \newglossaryentry with type set to \acronymtype. But without the acronym package option \acronymtype is main, i.e., the default glossary type. You can see this in:

\documentclass[english]{article}

\usepackage{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{glossaries}

\makeglossaries

\newglossaryentry{foo} {name = {Foo}, description = {``foo'' glossary entry}}
\newacronym{bar} {BAR} {``bar'' acronym}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}

If \gls{foo} is a normal glossary entry a ``X'' should follow, if
its an acronym we want its long form (\\glsentrylong{foo}) instead: ???

\gls{bar}

\glsentrytype{foo}, \glsentrytype{bar}

\acronymtype

\printglossary

\end{document}

As shown here, in general the type can be inferred from \glsentrytype{<name>}.

1
  • Thanks a lot! In fact, I do use the acronym package option in my actual document and just forgot to add it to the MWE.
    – TableKing
    Commented Jun 12, 2013 at 22:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .