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.

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}
share|improve this question

1 Answer 1

up vote 3 down vote accepted

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>}.

share|improve this answer
    
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 Jun 12 '13 at 22:15

Your Answer

 
discard

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.