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'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

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

3 Answers 3

up vote 42 down vote accepted

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}

alt text

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}

alt text

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 }

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

%%% define the acronym and use the see= option
\newglossaryentry{api}{type=\acronymtype, name={API}, description={Application
Programming Interface}, first={Application
Programming Interface (API)\glsadd{apig}}, see=[Glossary:]{apig}}
\begin{document}
\noindent
First use \gls{api}\    subsequent \gls{api}
\newpage

\printglossary[type=\acronymtype]
%%% \newpage just to demonstrate that links are correct
\newpage
\printglossary[type=main]

\end{document}

alt text

share|improve this answer
    
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
1  
+1 awesome solution. Can something like this be done somehow in Lyx? –  denilw Feb 5 '11 at 0:37
1  
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
1  
This solution is really fantastic and even now, nearly three years after, I'm still glad that I can profit of it. I know it is very ambitious, but I've got a question concerning this solution: would it somehow be possible to "transfer" page-references (which now appear only with the acronym-entry and the glossary-entry is always said to be referenced on page one) to the entry in the glossary? This might be a very tricky task, but it'd make this solution even better than it is already. –  user43961 Jan 18 at 22:41
show 4 more comments

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}{
name=\glslink{API}{Application Programming Interface (\gls{API})},
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}}, 
description=\glslink{APIG}{Application Programming Interfaces}
}

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

share|improve this answer
add comment

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.

share|improve this answer
    
Nice solution, but I'd use first={\glsentrylong{api}} (\glsentryname{api}). –  sergej Jun 19 at 18:27
add comment

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.