4

I use the glossaries package and when I print the acronyms using \printglossary[type=\acronymtype,title={List of Abbreviations}], part of the output I get is as shown below.

enter image description here

I have specified acronyms in a separate file as follows:

\newacronym{brdf}{BRDF}{bidirectional reflectance distribution function}
\newacronym{cnn}{CNN}{convolutional neural network}
\newacronym{awgn}{AWGN}{additive white Gaussian noise}

Is there a way to capitalize first letter of all words in the list of acronyms ONLY, when printing? (And have them in lower-case in the text)

Edit:

example

\documentclass[a4paper,oneside,12pt]{report}
% Abbreviations
\usepackage[acronym,style=super,nogroupskip,nonumberlist,toc]{glossaries}

\loadglsentries{def_abr} % file with acronyms
\makeglossaries

\begin{document} 
% abstract, toc, list of figures here
\renewcommand{\glsnamefont}[1]{\textbf{#1}}
\printglossary[type=\acronymtype,title={List of Abbreviations}]


\chapter*{Example Usage}
 \gls{brdf}, \gls{awgn}, \gls{psnr}, \gls{cnn}
% chapters
\end{document}

def_abr.tex file:

\newacronym{brdf}{BRDF}{bidirectional reflectance distribution function}
\newacronym{cnn}{CNN}{convolutional neural network}
\newacronym{psnr}{PSNR}{peak-signal-to-noise ratio}
\newacronym{snr}{SNR}{signal to noise ratio}
\newacronym{awgn}{AWGN}{additive white Gaussian noise}
  • Show a complete example that can be used for tests. That makes it much easier to help you. – Ulrike Fischer Mar 25 at 9:24
  • @UlrikeFischer added. – Sndn Mar 25 at 9:44
  • That's not a complete example. It has no \documentclass command, I can't compile it due to the reference to an external file and as it doesn't use the acronyms the list will be empty. – Ulrike Fischer Mar 25 at 9:46
  • @UlrikeFischer Apologies. Is update ok? – Sndn Mar 25 at 11:06
  • Acronym psnr not defined. – Steven B. Segletes Mar 25 at 11:07
2

Here's an alternative approach that uses glossaries-extra (an extension to the glossaries package):

\documentclass[a4paper,oneside,12pt]{report}
% Abbreviations
\usepackage[acronym,style=super,nogroupskip,nonumberlist]{glossaries-extra}

\makeglossaries
\setabbreviationstyle[acronym]{long-short}
\loadglsentries{def_abr} % file with acronyms

\glssetcategoryattribute{acronym}{glossdesc}{title}

\begin{document} 
% abstract, toc, list of figures here
\renewcommand{\glsnamefont}[1]{\textbf{#1}}
\printglossary[type=\acronymtype,title={List of Abbreviations}]


\chapter*{Example Usage}
 \gls{brdf}, \gls{awgn}, \gls{psnr}, \gls{cnn}
% chapters
\end{document}

(I've omitted the toc option as it's the default for glossaries-extra).

This produces on page 1:

List of Abbreviations AWGN Additive White Gaussian Noise BRDF Bidirectional Reflectance Distribution Function CNN Convolutional Neural Network PSNR Peak-Signal-To-Noise Ratio

and page 2:

Example Usage bidirectional reflectance distribution function (BRDF), additive white Gaussian noise (AWGN), peak-signal-to-noise ratio (PSNR), convolutional neural network (CNN)

The glossaries package automatically loads mfirstuc (which was originally developed as part of the glossaries package). The title attribute uses \capitalisewords to convert the case. You can control whether or not to capitalise the hyphenated parts of words using \MFUhyphentrue and \MFUhyphenfalse. The default is the false setting, which is why the above has "Peak-signal-to-noise".

The following switches it on:

\documentclass[a4paper,oneside,12pt]{report}
% Abbreviations
\usepackage[acronym,style=super,nogroupskip,nonumberlist]{glossaries-extra}

\makeglossaries
\setabbreviationstyle[acronym]{long-short}
\loadglsentries{def_abr} % file with acronyms

\glssetcategoryattribute{acronym}{glossdesc}{title}
\MFUhyphentrue

\begin{document} 
% abstract, toc, list of figures here
\renewcommand{\glsnamefont}[1]{\textbf{#1}}
\printglossary[type=\acronymtype,title={List of Abbreviations}]


\chapter*{Example Usage}
 \gls{brdf}, \gls{awgn}, \gls{psnr}, \gls{cnn}
% chapters
\end{document}

This produces:

image of list of abbreviations

To prevent words like "to" from being changed use the mfirstuc-english package or set up exceptions with \MFUnocap (for example, \MFUnocap{to}).

  • Elegant solution! However with \MFUnocap{to} and \MFUhyphentrue exception didn't work for me. – Sndn Mar 27 at 20:30
  • @Sndn Sorry I should've checked that. I'll look into it. – Nicola Talbot Mar 30 at 10:03
1

You can use \titlecap to capitalize the 1st letter of each word in the List of Abbreviations. You can even exclude words like to from being capitalized. The key is to turn on the meaning of \titlecap for the glossary print, and turn it off elsewhere.

I am not a glossaries user, but I am sure there is a way to automate the process so that the \titlecap macro need not be added to each entry.

\documentclass[a4paper,oneside,12pt]{report}
\usepackage{titlecaps}
\Addlcwords{to}
\usepackage{filecontents}
\begin{filecontents*}{glsfile}
\newacronym{brdf}{BRDF}{\titlecap{bidirectional reflectance distribution function}}
\newacronym{cnn}{CNN}{\titlecap{convolutional neural network}}
\newacronym{psnr}{PSNR}{\titlecap{peak-signal-\relax to-noise ratio}}
\newacronym{snr}{SNR}{\titlecap{signal to noise ratio}}
\newacronym{awgn}{AWGN}{\titlecap{additive white Gaussian noise}}
\end{filecontents*}
% Abbreviations
\usepackage[acronym,style=super,nogroupskip,nonumberlist,toc]{glossaries}

\loadglsentries{glsfile} % file with acronyms
\makenoidxglossaries
\begin{document} 
% abstract, toc, list of figures here
\renewcommand{\glsnamefont}[1]{\textbf{#1}}
\printnoidxglossary[type=\acronymtype,title={List of Abbreviations}]
\renewcommand\titlecap[1]{#1}

\chapter*{Example Usage}
 \gls{brdf}, \gls{awgn}, \gls{psnr}, \gls{cnn}, \gls{snr}
% chapters
\end{document}

enter image description here

enter image description here

1

A possible solution is to redefine the \glossentry command that is used to print the entries in the glossary table. In the MWE below I have used the \makefirstuc command from the mfirstuc package to make the first letter of the entry upper case. The definitions in the text remain lower case.

The code is not very clean but I could not figure out how to apply the \makefirstuc command directly on the \glossentrydesc command or on the argument of this command so I opted for a similar construct as in the mfirstuc package manual.

Edit: on closer reading the OP asked to capitalize all words. mfirstuc has a command for that (\capitalisewords), and also has a shortcut for expansion (\ecapitalisewords).

MWE:

\documentclass[a4paper,oneside,12pt]{report}
% Abbreviations
\usepackage[acronym,style=super,nogroupskip,nonumberlist,toc]{glossaries}
\usepackage{mfirstuc}

\loadglsentries{def_abr} % file with acronyms
\makeglossaries

\begin{document} 
\gls{brdf}, \gls{awgn}, \gls{psnr}, \gls{cnn}

\renewcommand*{\glossentry}[2]{%  Change the displayed items
\glstarget{#1}{\glossentryname{#1}} %
& \ecapitalisewords{\glossentrydesc{#1}}% Description
\tabularnewline
}

\printglossary[type=\acronymtype,title={List of Abbreviations}]
\end{document}

Result:

enter image description here Sources:

glossaries: How to customize list of symbols with additional column for units?

Is there a command to make first letter upper case?

Note that the first question redefines \glossentry in the context of a glossarystyle, that is probably better if you use multiple types of glossaries (or in general if you prefer cleaner code).

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.