# How to combine Acronym and Glossary

I'm using glossaries at LaTeX:

I have a Acronyms (eg. API) that should be explained in the Glossary. It should be linked to the Glossary at occurrence but should be written out at first occurrence.

How can I do that?

Explanation:

I want something like that:

This is a test of Application Programming Interface (API).

And this is the second occurrence of API.

Acronyms

API Application Programming Interface

Glossary

API An Application Programming Interface (API) is a particular set of rules and specifications that a software program can follow to access and make use of the services and resources provided by another particular software program that implements that API

-
If you define a entry and then use it with its label \gls{label} the first time you use it it will be written as longversion (acronym) and on all subsequent \gls{label}-uses it will come out just as acronym. –  Martin H Jan 14 '11 at 14:46
It seems redundant to define the acronym expansion and the term meaning two separate steps… why not index the acronyms as well as the full term in the glossary, and link them together there? –  Damien Pollet Feb 8 '11 at 0:18

a simple example

\documentclass{article}

\usepackage[acronym]{glossaries}
\makeglossaries

%from documentation
%\newacronym[⟨key-val list⟩]{⟨label ⟩}{⟨abbrv ⟩}{⟨long⟩}
%above is short version of this
% \newglossaryentry{⟨label ⟩}{type=\acronymtype,
% name={⟨abbrv ⟩},
% description={⟨long⟩},
% text={⟨abbrv ⟩},
% first={⟨long⟩ (⟨abbrv ⟩)},
% plural={⟨abbrv ⟩\glspluralsuffix},
% firstplural={⟨long⟩\glspluralsuffix\space (⟨abbrv ⟩\glspluralsuffix)},
% ⟨key-val list⟩}

\newacronym{cd}{CD}{compact disk}

\begin{document}
\noindent
First use \gls{cd}\\
subsequent \gls{cd}

\printglossaries

\end{document}


glossaries supports multiple nomenclatures so you can still use something like this

\newglossaryentry{tree}{name={tree},
description={trees are the better humans}}


and because in the above case the type is automatically set to 'main' it will give you a second list called 'Nomenclature'

\documentclass{article}

\usepackage[acronym]{glossaries}
\makeglossaries

%from documentation
%\newacronym[⟨key-val list⟩]{⟨label ⟩}{⟨abbrv ⟩}{⟨long⟩}
%above is short version of this
% \newglossaryentry{⟨label ⟩}{type=\acronymtype,
% name={⟨abbrv ⟩},
% description={⟨long⟩},
% text={⟨abbrv ⟩},
% first={⟨long⟩ (⟨abbrv ⟩)},
% plural={⟨abbrv ⟩\glspluralsuffix},
% firstplural={⟨long⟩\glspluralsuffix\space (⟨abbrv ⟩\glspluralsuffix)},
% ⟨key-val list⟩}

\newacronym{cd}{CD}{compact disk}

\newglossaryentry{tree}{name={tree},
description={trees are the better humans}}

\begin{document}
\noindent
First use \gls{cd}\\
subsequent \gls{cd}

Nomenclature \gls{tree}

\printglossaries

\end{document}


To finally get what you are after, you could use

\documentclass{article}
\usepackage{hyperref}
\usepackage[acronym]{glossaries}
\makeglossaries

%from documentation
%\newacronym[⟨key-val list⟩]{⟨label ⟩}{⟨abbrv ⟩}{⟨long⟩}
%above is short version of this
% \newglossaryentry{⟨label ⟩}{type=\acronymtype,
% name={⟨abbrv ⟩},
% description={⟨long⟩},
% text={⟨abbrv ⟩},
% first={⟨long⟩ (⟨abbrv ⟩)},
% plural={⟨abbrv ⟩\glspluralsuffix},
% firstplural={⟨long⟩\glspluralsuffix\space (⟨abbrv ⟩\glspluralsuffix)},
% ⟨key-val list⟩}

%\newacronym{api}{API}{Application Programming Interface }

%%% define the acronym and use the see= option
\newglossaryentry{api}{type=\acronymtype, name={API}, description={Application
Programming Interface}, first={Application
Programming Interface (API)}, see=[Glossary:]{apig}}

%%% The glossary entry the acronym links to
\newglossaryentry{apig}{name={API},
description={An Application Programming Interface (API) is a particular set
of rules and specifications that a software program can follow to access and
make use of the services and resources provided by another particular software
program that implements that API}}

\begin{document}
\noindent
First use \gls{api}\\
subsequent \gls{api}
\newpage

%%% have to add the apig because it is not used in the text body
\printglossary[type=\acronymtype]
%%% \newpage just to demonstrate that links are correct
\newpage
\printglossary[type=main]

\end{document}


-
But how can I explain compact disk? I want to haw them in the glossary, too. –  youseeus Jan 14 '11 at 15:18
I added another example –  Martin H Jan 14 '11 at 15:47
@Martin: I think having almost all the code indented is not nice. I've tried to edit your answer accordingly; please make a rollback if you don't like it. –  Hendrik Vogt Jan 14 '11 at 16:37
+1 awesome solution. Can something like this be done somehow in Lyx? –  denilw Feb 5 '11 at 0:37
tex.stackexchange.com/q/12346/978 is a follow up question on how to do this in Lyx –  denilw Mar 1 '11 at 18:12

I have extended this very very nice example (thanks at this place ;) ) thourgh which it is not necessary any more to add the glossary entry manually:

\newglossaryentry{APIG}{
description={
Application Programming Interface Desc}
}

\newglossaryentry{API}{
type=\acronymtype,
name=API,
first=Application Programming Interface (API),
firstplural={Application Programming Interfaces (API's)},
see=[Glossary:]{\gls{APIG}},
}


The main key is \glslink{APIG}{Application Programming Interfaces}. Everytime the (API) acronym is added it "adds" the glossary entry.

-

My solution looks like that:

\newglossaryentry{api}
{
name={API},
description={An Application Programming Interface (API) is a particular set
of rules and specifications that a software program can follow to access and make use of the services and resources provided by another particular software program that implements that API},
first={Application Programming Interface (API)},
long={Application Programming Interface}
}


So I don't have to split it into two parts, one for the glossary and one for the acronym section. Imho a clean solution.

Cheers :-)

Edit: But if you really want to split into two sections, then OSHis solution is perfect.

-