GeneralCapitalize first letter of names in Glossaries list

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
stinkinrich88
Posts: 52
Joined: Sat Jun 07, 2008 11:56 am

Capitalize first letter of names in Glossaries list

Post by stinkinrich88 »

Hello,

I'm using the glossaries package. It prints my glossary at the end of the document, but all the entry names are in lowercase. I'd like to know how I can make the first letter of each entry name in the glossary uppercase. The same for the list of acronyms would also be appreciated.

Note: I don't want to know how to make the first letter uppercase in the text (I know about \Gls instead of \gls), only in the glossary list at the end.

Thanks,

Rich
Last edited by stinkinrich88 on Thu Sep 02, 2010 7:47 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

stinkinrich88
Posts: 52
Joined: Sat Jun 07, 2008 11:56 am

Capitalize first letter of names in Glossaries list

Post by stinkinrich88 »

Of course, I've tried the following code in my preamble:

Code: Select all

\renewcommand{\glsnamefont}[1]{\makefirstuc{#1}}
But I get several errors in my .acr file, saying I've got an extra } or forgotten a $....

Any ideas?
User avatar
nlct
Posts: 276
Joined: Thu Nov 06, 2008 11:15 am

Capitalize first letter of names in Glossaries list

Post by nlct »

You need to redefine \glsnamefont:

Code: Select all

\documentclass{article}
\usepackage[acronym]{glossaries}

\makeglossaries

\renewcommand{\glsnamefont}[1]{\makefirstuc{#1}}

\newglossaryentry{sample}{name=sample,description=a sample entry}

\newacronym{abc}{abc}{a sample acronym}

\begin{document}

\gls{sample}. \gls{abc}.

\printglossaries
\end{document}
However it looks a bit odd for an acronym to start with a capital and have the rest in lower case as it makes it look like an ordinary word. The following will make the acronym all upper case in the list of acronyms:

Code: Select all

\documentclass{article}
\usepackage[acronym]{glossaries}

\makeglossaries

\newglossaryentry{sample}{name=sample,description=a sample entry}

\newacronym{abc}{abc}{a sample acronym}

\begin{document}

\gls{sample}. \gls{abc}.

\renewcommand{\glsnamefont}[1]{\makefirstuc{#1}}
\printglossary

\renewcommand{\glsnamefont}[1]{\MakeUppercase{#1}}
\printglossary[type=acronym]
\end{document}
You haven't mentioned if you are using the 'smallcaps' option. If you have and you are using a font that doesn't support bold small caps, then try:

Code: Select all

\documentclass{article}
\usepackage[acronym,smallcaps]{glossaries}

\makeglossaries

\newglossaryentry{sample}{name=sample,description=a sample entry}

\newacronym{abc}{abc}{a sample acronym}

\begin{document}

\gls{sample}. \gls{abc}.

\renewcommand{\glsnamefont}[1]{\makefirstuc{#1}}
\printglossary

\renewcommand{\glsnamefont}[1]{\textmd{#1}}
\printglossary[type=acronym]
\end{document}
Regards
Nicola Talbot
stinkinrich88
Posts: 52
Joined: Sat Jun 07, 2008 11:56 am

Capitalize first letter of names in Glossaries list

Post by stinkinrich88 »

Oh wow, thanks a lot! You covered just about everything, there!

I found out why I was getting an error with \makefirstuc: there are math symbols in my list of acronyms. E.g. I have an entry like this:

Code: Select all

\newacronym{velocity}{$\sigma$}{node velocity}
However, I would still like to use \makefirstuc in my list of acronyms as some of my acronyms are displayed in smallcaps and I'd like the first letter to be bigcaps. All other acronyms are defined in capital letters anyway, so it shouldn't look strange.

E.g. I have like DTN, RWP, opnet (this is displayed in small caps, but I want the o to be big).

Just a small annoyance, though. If you know the answer I'd love to hear it!

Thanks again,

Rich
User avatar
nlct
Posts: 276
Joined: Thu Nov 06, 2008 11:15 am

Capitalize first letter of names in Glossaries list

Post by nlct »

stinkinrich88 wrote: I found out why I was getting an error with \makefirstuc: there are math symbols in my list of acronyms. E.g. I have an entry like this:

Code: Select all

\newacronym{velocity}{$\sigma$}{node velocity}
You could try

Code: Select all

\newacronym{velocity}{\null$\sigma$}{node velocity}
(The upper casing is then applied to \null so it has no effect.) It might be an idea to set the sort key in this instance. Example:

Code: Select all

\documentclass{article}
\usepackage[acronym,smallcaps]{glossaries}

\makeglossaries

\newglossaryentry{sample}{name=sample,description=a sample entry}

\newacronym{abc}{abc}{a sample acronym}
\newacronym[sort=sigma]{velocity}{\null$\sigma$}{node velocity}

\begin{document}

\gls{sample}. \gls{abc}. \gls{velocity}.

\renewcommand{\glsnamefont}[1]{\makefirstuc{#1}}
\printglossary

\renewcommand{\glsnamefont}[1]{\textmd{\makefirstuc{#1}}}
\printglossary[type=acronym]
\end{document}
Regards
Nicola Talbot
stinkinrich88
Posts: 52
Joined: Sat Jun 07, 2008 11:56 am

Re: Capitalize first letter of names in Glossaries list

Post by stinkinrich88 »

Ace! Thanks a lot. I really enjoy your Glossaries package :-)
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Capitalize first letter of names in Glossaries list

Post by localghost »

Now that the problem is solved, please be so kind and mark the topic accordingly as described in Section 3 of the Board Rules. You are not new to the forum so by now you should know that.


Best regards
Thorsten
omrik
Posts: 1
Joined: Mon May 13, 2019 11:12 am

Capitalize first letter of names in Glossaries list

Post by omrik »

I'm trying to do something slightly different.

I would like to define the acronym in the text using lowercase letters as follows:
sample acronym (SA)
degrees of freedom (DOF)
While recurrences will be displayed as:
SA
DOF

but, at the acronyms list, I would like it to appear with uppercase letters as:
SA - Sample Acronym
DOF - Degrees of Freedom

Using your code with the following slight changes, I can't get it right:

Code: Select all

\documentclass{article}
\usepackage[acronym]{glossaries}
 
\makeglossaries
 
\newglossaryentry{sample}{name=sample,description=a sample entry}
 
\newacronym{sa}{SA}{Sample Acronym}

\newacronym{dof}{DOF}{Degrees of Freedom}
 
\begin{document}
 
This is a \gls{sample}. And this is a \gls{sa} while another one will be \gls{dof}.
Recurrences are \gls{sa} and \gls{dof}.
 
\renewcommand{\glsnamefont}[1]{\makefirstuc{#1}}
\printglossary
 
\printglossary[type=acronym,style = super]
\end{document}
Help will be appreciated.
Post Reply