Latest news 2020-05-02: new blog post "Book Samples."

glossaries package FAQ

FAQ Search Tips

How do I define my own custom acronym style? 🔗

As from version 4.02, you can define your own acronym style using \newacronymstyle. For example, suppose you want the long form to appear in the margin on first use. You could define the style from scratch, but you might find it easier to base the new style on an existing style. For example, let's define a new style called "margin" that's based on the "short-long" style:

\newacronymstyle{margin}
{%
  \GlsUseAcrEntryDispStyle{short-long}%
}%
{%
  \GlsUseAcrStyleDefs{short-long}%  
  \renewcommand*{\genacrfullformat}[2]{%
   \protect\firstacronymfont{\glsentryshort{##1}}##2%
   \protect\marginpar{\glsentrylong{##1}}%
  }%
  \renewcommand*{\Genacrfullformat}[2]{%
   \firstacronymfont{\Glsentryshort{##1}}##2%
   \protect\marginpar{\glsentrylong{##1}}%
  }%
  \renewcommand*{\genplacrfullformat}[2]{%
   \protect\firstacronymfont{\glsentryshortpl{##1}}##2%
   \protect\marginpar{\glsentrylongpl{##1}}%
  }%
  \renewcommand*{\Genplacrfullformat}[2]{%
   \protect\firstacronymfont{\Glsentryshortpl{##1}}##2%
   \protect\marginpar{\glsentrylongpl{##1}}%
  }%
}
Now you can set the style:
\setacronymstyle{margin}
Pre version 4.02: A new style can be set by redefining \CustomAcronymFields and using \SetCustomStyle.
\DeclareRobustCommand{\MARGINPAR}[1]{\marginpar{#1}}

\renewcommand*{\CustomAcronymFields}{%
  name={\the\glsshorttok},% name is abbreviated form
  description={\the\glslongtok},% description is long form
  first={\the\glsshorttok\MARGINPAR{\the\glslongtok}},%
  firstplural={\the\glsshorttok\noexpand\acrpluralsuffix\MARGINPAR{\the\glslongtok}},%
  text={\the\glsshorttok},%
  plural={\the\glsshorttok\noexpand\acrpluralsuffix}%
}

\SetCustomStyle % Switch to custom style
Note that this method gets more complicated if the plural forms can't be derived by appending the singular form with the plural suffix ("s" by default). If you find this a problem, then upgrade to the latest version and use \newacronymstyle as described above.

Last modified: 2013-12-08 16:39:19.


Category: glossaries package
Topic: Referencing Terms