[Tex/LaTex] Glossaries package: smallcaps and uppercase in index does not work

glossariessmall-capstable of contents

I am using the glossaries package in pdfLaTeX. I am trying to

  1. use the acronyms written in small caps in the body text

    and

  2. for the index, make the first letter of each entry name in the glossary uppercase.

I have already tried to look around but I could not find a solution.

To obtain the glossary I run the command makeindex defined as following:

"/usr/texbin/makeglossaries" %

Normally, I load my entries from 2 external files but I do not think that this is the problem since I get the same issue also after running my MWE. Anyway, to show the commands I'm using I inserted them as comments in the MWE.

Also, I'm not sure if this is important, but I use MinionPro as my main font and KOMA-Script.

My MWE is based on this thread:
http://www.latex-community.org/forum/viewtopic.php?f=5&t=9966

\documentclass{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[toc=true,smallcaps,section,nonumberlist,acronym,nomain]{glossaries}
\newglossary{slg}{sym}{syb}{Nomenclature}
% \input{./text/glossary}
% \loadglsentries{./text/symbols}
\makeglossaries
\newacronym{pcm} {PCM} {phase change material}
\newglossaryentry{sym:hfus}{type=slg,sort={pl:h},
                  name = {\null$\Delta H_{fus}$},
                  description={latent heat of fusion}}

\begin{document}
Sample: \gls{sym:hfus}. \gls{sym:hfus}. \gls{pcm}. \gls{pcm}.

    \textsc{This is small caps. PCM pcm }

\renewcommand{\glsnamefont}[1]{\makefirstuc{#1}}
\printglossary[type=slg, style=long, nonumberlist=true]

\renewcommand{\glsnamefont}[1]{\MakeUppercase{#1}}
\printglossary[type=acronym, style=long]
\end{document}

Here's the result:
Result of MWE

The only thing that gets capitalized is Fus from the math environment and I really do not understand how this happens. Everything else (smallcaps option and uppercases of description) is just not working.

Someone can please explain me what I'm doing wrong?

Best Answer

As mentioned in the comments, your acronyms aren't appearing in small caps because you've defined them using upper case. You said that the upper casing of the description hasn't worked. That's because you haven't made any changes relating to the description. \glsnamefont is applied to the name not the description. You need to define a new style that makes the description start with an upper case letter:

\documentclass{scrreprt}

\usepackage[T1]{fontenc}
\usepackage[toc=true,smallcaps,section,nonumberlist,acronym,nomain]{glossaries}
\newglossary{slg}{sym}{syb}{Nomenclature}

\makeglossaries

\newacronym{pcm}{pcm}{phase change material}
\newglossaryentry{sym:hfus}{type=slg,sort={pl:h},
                  name = {\null$\Delta H_{fus}$},
                  description={latent heat of fusion}}

\newglossarystyle{long-ucdesc}{%
  \setglossarystyle{long}%
    \renewcommand{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
    \Glossentrydesc{##1}\glspostdescription\space ##2\tabularnewline
  }%
}

\begin{document}
Sample: \gls{sym:hfus}. \gls{sym:hfus}. \gls{pcm}. \gls{pcm}.

    \textsc{This is small caps. PCM pcm }

\printglossary[type=slg, style=long-ucdesc, nonumberlist=true]

\renewcommand{\glsnamefont}[1]{\MakeUppercase{#1}}
\printglossary[type=acronym, style=long]

\end{document}

This produces:

Image of resulting document

The following defines a style that makes the initial letters of the description upper case:

\documentclass{scrreprt}

\usepackage[T1]{fontenc}
\usepackage[toc=true,smallcaps,section,nonumberlist,acronym,nomain]{glossaries}
\newglossary{slg}{sym}{syb}{Nomenclature}

\makeglossaries

\newacronym{pcm}{pcm}{phase change material}
\newglossaryentry{sym:hfus}{type=slg,sort={pl:h},
                  name = {\null$\Delta H_{fus}$},
                  description={latent heat of fusion}}

\newglossarystyle{long-ucdesc}{%
  \setglossarystyle{long}%
    \renewcommand{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
    \Glossentrydesc{##1}\glspostdescription\space ##2\tabularnewline
  }%
}

\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

\begin{document}
Sample: \gls{sym:hfus}. \gls{sym:hfus}. \gls{pcm}. \gls{pcm}.

    \textsc{This is small caps. PCM pcm }

\printglossary[type=slg, style=long-ucdesc, nonumberlist=true]

\printglossary[type=acronym, style=long-initcapsdesc]

\end{document}

Result:

Image of result

If you have at least version 4.22 of glossaries, you can use \glsentrytitlecase instead:

\documentclass{scrreprt}

\usepackage[T1]{fontenc}
\usepackage[toc=true,smallcaps,section,nonumberlist,acronym,nomain]{glossaries}
\newglossary{slg}{sym}{syb}{Nomenclature}

\makeglossaries

\newacronym{pcm}{pcm}{phase change material}
\newglossaryentry{sym:hfus}{type=slg,sort={pl:h},
                  name = {\null$\Delta H_{fus}$},
                  description={latent heat of fusion}}

\newglossarystyle{long-ucdesc}{%
  \setglossarystyle{long}%
    \renewcommand{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
    \Glossentrydesc{##1}\glspostdescription\space ##2\tabularnewline
  }%
}

\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
  }%
}

\begin{document}
Sample: \gls{sym:hfus}. \gls{sym:hfus}. \gls{pcm}. \gls{pcm}.

    \textsc{This is small caps. PCM pcm }

\printglossary[type=slg, style=long-ucdesc, nonumberlist=true]

\printglossary[type=acronym, style=long-initcapsdesc]

\end{document}

With glossaries-extra you can make use of the glossdesc attribute:

\documentclass{scrreprt}

\usepackage[T1]{fontenc}
\usepackage[section,nonumberlist,acronym,nomain]{glossaries-extra}
\newglossary{slg}{sym}{syb}{Nomenclature}

\makeglossaries

\setabbreviationstyle[acronym]{long-short-sc}

\newacronym{pcm}{pcm}{phase change material}
\newglossaryentry{sym:hfus}{type=slg,sort={pl:h},
                  name = {\null$\Delta H_{fus}$},
                  description={latent heat of fusion}}

\glssetcategoryattribute{acronym}{glossdesc}{title}
\glssetcategoryattribute{general}{glossdesc}{firstuc}

\begin{document}
Sample: \gls{sym:hfus}. \gls{sym:hfus}. \gls{pcm}. \gls{pcm}.

    \textsc{This is small caps. PCM pcm }

\printglossary[type=slg, style=long, nonumberlist=true]

\printglossary[type=acronym, style=long]

\end{document}
Related Question