LaTeX forum ⇒ GeneralCapitalize first letter of names in Glossaries list

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

Capitalize first letter of names in Glossaries list

Postby stinkinrich88 » Tue Aug 31, 2010 2:59 pm

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.

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

Postby stinkinrich88 » Wed Sep 01, 2010 11:59 am

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

  1. \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: 274
Joined: Thu Nov 06, 2008 11:15 am

Postby nlct » Wed Sep 01, 2010 12:07 pm

You need to redefine \glsnamefont:
  1. \documentclass{article}
  2. \usepackage[acronym]{glossaries}
  3.  
  4. \makeglossaries
  5.  
  6. \renewcommand{\glsnamefont}[1]{\makefirstuc{#1}}
  7.  
  8. \newglossaryentry{sample}{name=sample,description=a sample entry}
  9.  
  10. \newacronym{abc}{abc}{a sample acronym}
  11.  
  12. \begin{document}
  13.  
  14. \gls{sample}. \gls{abc}.
  15.  
  16. \printglossaries
  17. \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:
  1. \documentclass{article}
  2. \usepackage[acronym]{glossaries}
  3.  
  4. \makeglossaries
  5.  
  6. \newglossaryentry{sample}{name=sample,description=a sample entry}
  7.  
  8. \newacronym{abc}{abc}{a sample acronym}
  9.  
  10. \begin{document}
  11.  
  12. \gls{sample}. \gls{abc}.
  13.  
  14. \renewcommand{\glsnamefont}[1]{\makefirstuc{#1}}
  15. \printglossary
  16.  
  17. \renewcommand{\glsnamefont}[1]{\MakeUppercase{#1}}
  18. \printglossary[type=acronym]
  19. \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:

  1. \documentclass{article}
  2. \usepackage[acronym,smallcaps]{glossaries}
  3.  
  4. \makeglossaries
  5.  
  6. \newglossaryentry{sample}{name=sample,description=a sample entry}
  7.  
  8. \newacronym{abc}{abc}{a sample acronym}
  9.  
  10. \begin{document}
  11.  
  12. \gls{sample}. \gls{abc}.
  13.  
  14. \renewcommand{\glsnamefont}[1]{\makefirstuc{#1}}
  15. \printglossary
  16.  
  17. \renewcommand{\glsnamefont}[1]{\textmd{#1}}
  18. \printglossary[type=acronym]
  19. \end{document}


Regards
Nicola Talbot

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

Postby stinkinrich88 » Wed Sep 01, 2010 12:55 pm

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:

  1. \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: 274
Joined: Thu Nov 06, 2008 11:15 am

Postby nlct » Thu Sep 02, 2010 12:59 pm

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:

  1. \newacronym{velocity}{$\sigma$}{node velocity}


You could try
  1. \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:
  1. \documentclass{article}
  2. \usepackage[acronym,smallcaps]{glossaries}
  3.  
  4. \makeglossaries
  5.  
  6. \newglossaryentry{sample}{name=sample,description=a sample entry}
  7.  
  8. \newacronym{abc}{abc}{a sample acronym}
  9. \newacronym[sort=sigma]{velocity}{\null$\sigma$}{node velocity}
  10.  
  11. \begin{document}
  12.  
  13. \gls{sample}. \gls{abc}. \gls{velocity}.
  14.  
  15. \renewcommand{\glsnamefont}[1]{\makefirstuc{#1}}
  16. \printglossary
  17.  
  18. \renewcommand{\glsnamefont}[1]{\textmd{\makefirstuc{#1}}}
  19. \printglossary[type=acronym]
  20. \end{document}


Regards
Nicola Talbot

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

Postby stinkinrich88 » Thu Sep 02, 2010 2:41 pm

Ace! Thanks a lot. I really enjoy your Glossaries package :-)

User avatar
localghost
Site Moderator
Posts: 9206
Joined: Fri Feb 02, 2007 12:06 pm

Postby localghost » Thu Sep 02, 2010 7:01 pm

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
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1


Return to “General”

Who is online

Users browsing this forum: Baidu [Spider] and 5 guests