1

I am trying to use the glossaries package to print a list of acronyms. Could someone please point me in the right direction to bold the first letter of each word in the printed glossary? Image below for clarification. enter image description here

In terms of a MWE (I know this is completely wrong but I thought I should try and include some attempt. I'm guessing the way in which \printglossaries presents the argument in \newacronym[key-val list]{label}{abbrv}{long} needs to be redefined but I haven't a clue how)....

\documentclass{article}
% Load the package with the acronym option
\usepackage[acronym,nomain]{glossaries}
% Generate the glossary
\makeglossaries
\begin{document}
\section*{Section with acronyms}
% Acronym definitions
\newacronym{utc}{UTC}{\textbf{C}oordinated Universal Time}
\newacronym{adt}{ADT}{Atlantic Daylight Time}
\newacronym{est}{EST}{Eastern Standard Time}
% Use the acronyms
\gls{utc} is 3 hours behind \gls{adt} and 10 hours ahead of \gls{est}.
\gls{utc} \gls{utc} 
%Print the glossary
\printglossaries
\small\hfill Created by http://texblog.org
\end{document}
2

The glossaries bundle also provides the mfirstuc package, which provides the command \capitalisewords, which converts the first letter of each word to uppercase. This can be adapted so that instead of converting the letter to uppercase, it turns it bold instead. A new command can be created to do this:

\newrobustcmd{\bffirst}[1]{{\let\mfirstucMakeUppercase\textbf\capitalisewords{#1}}}

The extra pair of braces ensures that the change to \mfirstucMakeUppercase only has a local effect. (This is internally used by commands such as \Gls, so it's important to restore it.)

A new acronym style can then be defined that puts the description inside the argument of this new custom \bffirst command:

\newacronymstyle{bf-long-short}%
{%
  \GlsUseAcrEntryDispStyle{long-short}%
}%
{%
  \GlsUseAcrStyleDefs{long-short}%
  \renewcommand*{\GenericAcronymFields}{description={\bffirst{\the\glslongtok}}}%
}

This new style should be set before defining the acronyms:

\setacronymstyle{bf-long-short}

(If you get an "undefined control sequence" error for \newacronymstyle, then your version of glossaries is too old and needs to be updated.) Note that the glossaries user manual advises against defining entries inside the document environment so I've moved \newacronym into the preamble in the modified example below:

\documentclass{article}

% Load the package with the acronym option
\usepackage[acronym,nomain]{glossaries}
% Generate the glossary
\makeglossaries

\newrobustcmd{\bffirst}[1]{{\let\mfirstucMakeUppercase\textbf\capitalisewords{#1}}}

\newacronymstyle{bf-long-short}%
{%
  \GlsUseAcrEntryDispStyle{long-short}%
}%
{%
  \GlsUseAcrStyleDefs{long-short}%
  \renewcommand*{\GenericAcronymFields}{description={\bffirst{\the\glslongtok}}}%
}

\setacronymstyle{bf-long-short}

% Acronym definitions
\newacronym{utc}{UTC}{Coordinated Universal Time}
\newacronym{adt}{ADT}{Atlantic Daylight Time}
\newacronym{est}{EST}{Eastern Standard Time}


\begin{document}
\section*{Section with acronyms}

% Use the acronyms
\gls{utc} is 3 hours behind \gls{adt} and 10 hours ahead of
\gls{est}.
\gls{utc} \gls{utc} 

%Print the glossary
\printglossaries
\small\hfill Created by http://texblog.org
\end{document}

This makes the first letter bold for each word of the description when displayed in the list of acronyms but doesn't change the normal behaviour in the main text.

Edit:

If you additionally load the mfirstuc-english package then \capitalisewords will ignore words like "a", "an", "of", "in". (If you open mfirstuc-english.sty in a text editor, you'll see which words have been defined using \MFUnocap.¹) Additional words can be added, for example,

\MFUnocap{as}

In the case where you have a letter taken from the middle of the word (rather than the initial letter) you will have to manually override the description for that case:

\newacronym[description={E\textbf{x}tensible \textbf{M}arkup \textbf{L}anguage}]{XML}{XML}{Extensible Markup Language}

Further information about \capitalisewords, \MFUnocap and related commands is available in the mfirstuc user manual which should be located in the same directory as the glossaries user manual.


¹ Disputed or context-dependent words (such as "up") aren't included by mfirstuc-english and need to be explicitly added using \MFUnocap if required.

  • Exactly what I was looking for. Thanks for being so descriptive. – 1QuickQuestion Jul 24 '15 at 10:23
  • Although is there away to avoid boding the first letter of a words which might not be part of the acronym (of, as, in, etc.)? Similarly might it be possible to bold the first couple letters in a word? – 1QuickQuestion Jul 24 '15 at 11:01
  • If I could give you more points I would. Thank you. – 1QuickQuestion Jul 24 '15 at 13:47

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.