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.

The acronym packages allows one to easily create and display acronyms, with a simple syntax, like \ac{usb}. The first time this is called, is will say “Universal Serial Bus (USB)”, but after that, just “USB”. I found nothing about this in the documentation, but this article on PDF-strings seems to offer similar functionality, but the example seems incomplete. How can I define and display acronyms in ConTeXt?

share|improve this question
2  
See manual chapter 12.2 - Synonyms –  Marco May 9 '12 at 12:18

3 Answers 3

up vote 8 down vote accepted

The context version of this functionality is called 'synonyms', types of which are defined using \definesynonyms. The wiki page for definesynonyms contains some examples, but in short:

\definesynonyms[acronym][acronyms][\infull]

\acronym[VVV]{vvv}{Bureau of Tourist Information}
\starttext
The Dutch \VVV\ (\infull{VVV}) can provide you with the tourist information on Hasselt.
\stoptext

There now also a \setupsynonyms[acronyms] and \placelistofacronyms. That are used to produce a list of (used or all) acronyms.

As far as I know, ConTeXt does not have a built-in feature for 'first use'.

share|improve this answer

The theory behind this is easy, if you don't need to index the acronyms.

\def\newacronym#1#2#3{% #1 = key, #2 = abbreviated form, #3 = expanded form
  \expandafter\def\csname ac@#1\endcsname{%
    #3~(#2)%
    \expandafter\gdef\csname ac@#1\endcsname{#2}%
   }%
}
\def\ac#1{\csname ac@#1\endcsname}

\newacronym{usb}{USB}{Universal Serial Bus}
\newacronym{ml}{ML}{Murphy's Law}

Here's \ac{usb} and \ac{ml}; let's see that \ac{usb} works 
not according to \ac{ml}.

\bye

enter image description here

share|improve this answer

I had the same question but needed indexing. Also, my project contains many loose files, so I don't want to search for first occurances myself.

\definesynonyms[acron][acronyms][\fullac] % Define acronyms as context synonyms

% Define a new macro
\def\ac#1{
  \ifcsname AcroUsed#1\endcsname
    % If the acro was already used, return the acronym
    \csname #1\endcsname
  \else
    % Otherwise, set as used, print full and acro
    \fullacro{#1} (\csname #1\endcsname)
    \expandafter\def\csname AcroUsed#1\endcsname{1}
  \fi
}
share|improve this answer

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.