2

I'm using the Glossaries package, and I would like the acronyms to be printed as follows:

  • list of acronyms: first letter of each word of an acronym to be uppercase
  • running text: first letter of each word of an acronym to be lowercase

The solution presented here works very well, but I have an acronym with a hyphen, which is recognized as one word ("Air-conditioning"). How can I revise the code so the output is "Air-Conditioning" in the list of acronyms instead of "Air-conditioning"?

My code so far is:

\documentclass[a4paper,oneside,11pt]{report}
\usepackage[nopostdot,nogroupskip,nonumberlist,acronym]{glossaries}

\newacronym{hvac}{HVAC}{heating, ventilation and air-conditioning}

\makeatletter
\newglossarystyle{long-initcapsdesc}{%
  \setglossarystyle{long}%
    \renewcommand{\glsnamefont}[1]{\MakeUppercase{##1}}%
    \renewcommand{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
    \protected@edef\thisdesc{\glsentrydesc{##1}}%
    \xcapitalisewords{\thisdesc}\glspostdescription\space ##2\tabularnewline
  }%
}
\makeatother

\makeglossaries

\begin{document}

\printglossary[type=acronym,style=long-initcapsdesc,title={List Of Acronyms}]

\vspace{100pt}
\noindent 
text text text \gls{hvac} text text text

\end{document}

And the current output looks like this: enter image description here

2

If you have at least version 2.03 of mfirstuc you can enable splitting on hyphens with \MFUhyphentrue.

\documentclass[a4paper,oneside,11pt]{report}
\usepackage[nopostdot,nogroupskip,nonumberlist,acronym]{glossaries}

\MFUhyphentrue

\newacronym{hvac}{HVAC}{heating, ventilation and air-conditioning}

\makeatletter
\newglossarystyle{long-initcapsdesc}{%
  \setglossarystyle{long}%
    \renewcommand{\glsnamefont}[1]{\MakeUppercase{##1}}%
    \renewcommand{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
    \protected@edef\thisdesc{\glsentrydesc{##1}}%
    \xcapitalisewords{\thisdesc}\glspostdescription\space ##2\tabularnewline
  }%
}
\makeatother

\makeglossaries

\begin{document}

\printglossary[type=acronym,style=long-initcapsdesc,title={List Of Acronyms}]

\vspace{100pt}
\noindent 
text text text \gls{hvac} text text text

\end{document}

There's now a simpler way of applying \capitalisewords to a field:

\newglossarystyle{long-initcapsdesc}{%
  \setglossarystyle{long}%
    \renewcommand{\glsnamefont}[1]{\MakeUppercase{##1}}%
    \renewcommand{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
    \glsentrytitlecase{##1}{desc}\glspostdescription\space ##2\tabularnewline
  }%
}

image of result

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.