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?

  • 3
    See manual chapter 12.2 - Synonyms
    – Marco
    May 9 '12 at 12:18

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{%
    \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}.


enter image description here

  • That's not a ConTeXt solution and the question was explicitly about ConTeXt. Use of def in ConTeXt is discouraged.
    – helcim
    Jan 5 '19 at 14:50
  • 1
    @helcim So what? I explained the theory around defining acronyms; adapting it to ConTeXt should be easy. I'm quite surprised the other answer, which uses \def has not even a comment of the same kind.
    – egreg
    Jan 5 '19 at 17:33
  • Yes, the other answer should have such comment as well. Maybe I'm too pedantic about it, but when you look for ConTeXt solutions to ConTeXt questions here and find so many answers giving LaTeX (which is specifically counterproductive) or Plain TeX solutions it's getting much less helpful than it could be.
    – helcim
    Jan 7 '19 at 8:56
  • @helcim Perhaps, if the documentation for ConTeXt was more easily accessible, it could be easier to provide conforming answers. For instance, I found \definesynonyms in the ConTeXtgarden wiki: it is described as a command with four arguments, but there is no mention at all about what the second and fourth arguments do. And the commands don't do what the OP is looking for, that is, distinguishing between first and subsequent usages.
    – egreg
    Jan 7 '19 at 9:58
  • 1
    @helcim I'm looking at the manual: on page 79 you can see two pieces of code using \def. Is it discouraged or not? One has to decide about this; if it is really discouraged, then it should not appear in the manual. Look for \def in the LaTeX manual, for instance.
    – egreg
    Jan 7 '19 at 11:42

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:


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

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


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
  \ifcsname AcroUsed#1\endcsname
    % If the acro was already used, return the acronym
    \csname #1\endcsname
    % Otherwise, set as used, print full and acro
    \fullacro{#1} (\csname #1\endcsname)
    \expandafter\def\csname AcroUsed#1\endcsname{1}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.