I am using the glossaries package only for its acronym capabilities, and I have one or two that are only used once in the document. For those acronyms, is there a way to only display the full text?

Specifically, the default is for \gls{dft} to display

density functional theory (DFT),

but I'd like it to only display

density functional theory

if the acronym is only used once.

  • Just for the case that you haven't noticed it: I've added to my answer a patch that extends the glossaries package by the special feature you are interested in. – mhp Aug 26 '11 at 14:10

If you want to get the long form of an acronym—independently of the selected acronym style and the context where the acronym is used—I think it's best to simply use \acrlong or \acl. Note that the latter command is only defined if the shortcuts option of the glossaries package is set.

Edit: Werner has pointed out in a comment to his answer that it is probably possible to extend the glossaries package such that acronyms are printed in a distinct way if they are used only once in the document. The following patch shows that this can indeed be done:




  \newbool{glo@\the\glslabeltok @usedonlyonce}% define an additional switch per acronym

}{% write appropriate information to the main auxiliary file

}{% print the long form of the acronym if the acronym is used only once


\newacronym{ANO}{ANO}{Acronym Number One}
\newacronym{ANT}{ANT}{Acronym Number Two}




\gls{ANO}, \gls{ANO}\\


Obviously, you need two LaTeX runs to get everything right. Moreover, if you use not only \gls (\ac), but also \Gls (\Ac), \GLS, \glspl (\acp), \Glspl (\Acp) and \GLSpl you have to patch \@Gls@, \@GLS@, \@glspl@, \@Glspl@ and \@GLSpl@ in the same way as \@gls@.

The resulting output is:

  • Do you know if the need for a double run of LaTeX would be picked up by latexmk? – rcollyer Aug 26 '11 at 14:16
  • I don't know. It depends on how latexmk deals with changes in the main auxiliary file (the mydoc.aux file). – mhp Aug 26 '11 at 14:36
  • I think it monitors if anything changes, and based upon what changes it reruns something appropriate (one hopes). – rcollyer Aug 26 '11 at 14:41
  • I've browsed the documentation of latexmk. I think there is a good chance that everything will work out of the box, especially if you are using a current version of latexmk. – mhp Aug 26 '11 at 14:55
  • 1
    OK, I've tested the example in my answer: It works. latexmk notices that the main auxiliary file has changed and consequently invokes latex a second time. – mhp Aug 26 '11 at 15:02

You need to set the first key for these entries when you declare them via

\newacronym[<key-val list>]{<label>}{<abbrv>}{<long>}

Even though the first key is described under the definition of \newglossaryentry, \newacronym uses \newglossaryentry to define acronyms. Consequently, the following is taken from the glossaries package documentation:


How the entry will appear in the document text on first use with \gls (or one of its uppercase variants). If this field is omitted, the value of the text key is used. Note that if you use \glspl, \Glspl, \GLSpl, \glsdisp before using \gls, the firstplural value won’t be used with \gls.

So, specifically for your case, you would probably define it this way:

  [first={density functional theory},...]% <key-val list>
  {dft}% <label>
  {DFT}% <abbrv>
  {density functional theory}% <long>

The following minimal example illustrates this:

\usepackage{glossaries}% http://ctan.org/pkg/glossaries
  [first={density functional theory}]% <key-val list>
  {dft}% <label>
  {DFT}% <abbrv>
  {density functional theory}% <long>

Blah blah blah \gls{dft}. Blah blah blah blah

First use of an acronym using the glossaries package

  • 1
    Definitely useful. But, I'm more looking for something where LaTeX will programmatically determine that I've only used it once, so the acronym need not be included. I'd like to create a glossary file that I can import and not have to manually reset this if I only use something once. – rcollyer Aug 22 '11 at 12:25
  • 2
    Such an implementation would require a usage counter (to keep track oh how many times an acronym is called for), require 3 compilations (first to establish all counts; second to rewrite those acronyms only used once; third to possibly adjust references due to the rewrite during the second parse) and be optional to the user via a package choice - since the behaviour may be specific. I would contact the package author and see whether this is possible to include in a future version. – Werner Aug 22 '11 at 14:10
  • That's what I thought. – rcollyer Aug 22 '11 at 14:18
  • @Werner I don't think it requires counters. I guess that a line in .aux file for every but the first occurence of the acronym would be enough, and a glossary package anyways has to determine whether it is first or other occurence. The next time you go thru the .aux file and you don't print the abbr. at the first occurence if the abbr. was not used in the previous run. I think that three runs of latex would be sufficient then. Disclaimer: I have never used any glossary package so I'm not able to code this myself. – yo' Apr 26 '12 at 7:47
  • @tohecz: Sure, if "every but the first" is properly defined. Counters just make it easy, since it can be used with "all occurrences" and still yield valuable information. – Werner Apr 26 '12 at 14:18

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.