glossaries package FAQ

How do I set the font for just the long form when using \newacronym? 🔗

As from version 4.02 you can define your own custom acronym style (see How do I define my own custom acronym style?). For example, suppose you want the long form in italic followed by the short form in parentheses on first use, then you can define a new style called, say, em-long-short that’s based on the long-short style:

\newacronymstyle{em-long-short}
{%
  \GlsUseAcrEntryDispStyle{long-short}%
}%
{%
  \GlsUseAcrStyleDefs{long-short}%  
  \renewcommand*{\genacrfullformat}[2]{%
   \emph{\glsentrylong{##1}}##2\space
   (\firstacronymfont{\glsentryshort{##1}})%
  }%
  \renewcommand*{\Genacrfullformat}[2]{%
   \emph{\Glsentrylong{##1}}##2\space
   (\firstacronymfont{\glsentryshort{##1}})%
  }%
  \renewcommand*{\genplacrfullformat}[2]{%
   \emph{\glsentrylongpl{##1}}##2\space
   (\firstacronymfont{\glsentryshortpl{##1}})%
  }%
  \renewcommand*{\Genplacrfullformat}[2]{%
   \emph{\Glsentrylongpl{##1}}##2\space
   (\firstacronymfont{\Glsentryshortpl{##1}})%
  }%
}
Now you can set the style:
\setacronymstyle{em-long-short}
You may prefer to move the insert part (##2) into the \emph argument:
\newacronymstyle{em-long-short}
{%
  \GlsUseAcrEntryDispStyle{long-short}%
}%
{%
  \GlsUseAcrStyleDefs{long-short}%  
  \renewcommand*{\genacrfullformat}[2]{%
   \emph{\glsentrylong{##1}##2}\space
   (\firstacronymfont{\glsentryshort{##1}})%
  }%
  \renewcommand*{\Genacrfullformat}[2]{%
   \emph{\Glsentrylong{##1}##2}\space
   (\firstacronymfont{\glsentryshort{##1}})%
  }%
  \renewcommand*{\genplacrfullformat}[2]{%
   \emph{\glsentrylongpl{##1}##2}\space
   (\firstacronymfont{\glsentryshortpl{##1}})%
  }%
  \renewcommand*{\Genplacrfullformat}[2]{%
   \emph{\Glsentrylongpl{##1}##2}\space
   (\firstacronymfont{\Glsentryshortpl{##1}})%
  }%
}

Note that if you are using glossaries-extra, it uses a completely different abbreviation mechanism so the above won’t work.

Pre version 4.02:

You can use the custom acronym format, as described in How do I define my own custom acronym style?. For example, suppose you want the long form to be emphasized using \emph, you can do the following:

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

\SetCustomStyle
This displays long (short). You can swap, add or remove \glslongtok and \glsshorttok, as required. Remember to use \SetCustomStyle to switch to this acronym style. (If you get an error saying that \CustomAcronymFields can’t be redefined as it doesn’t exist or an “Undefined control sequence” error for \SetCustomStyle, then you need to update your version of glossaries.)

Note, however, that this solution doesn’t work for plurals that aren’t formed by simply prefixing the singular term with \acrpluralsuffix. If this causes a problem, upgrade to the latest version and use \newacronymstyle as described above.

2020-07-01 14:16:00


Permalink: https://www.dickimaw-books.com/faq.php?id=56
Alternative link: https://www.dickimaw-books.com/faq.php?itemlabel=longformat

Category: glossaries package
Topic: Referencing Terms