Generalglossaries | Capitalize first Character in final List

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
noid
Posts: 3
Joined: Fri Jan 20, 2012 8:59 am

glossaries | Capitalize first Character in final List

Post by noid »

Hi,

I have been having some trouble in trying to capitalize just the first character of the acronym in the final listing alone.

i.e. I want the acronym to be small in the normal text but for the List of Acronym, the listing should have the first character of each word in the text to be capitalized.

e.g. a sample acronym (ABC)

Whereas, in the listing (\printglossaries) it should be:

ABC A Sample Acronym

Any help or lead in the right direction would be great

Thanks

Recommended reading 2024:

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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

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

glossaries | Capitalize first Character in final List

Post by nlct »

I think the easiest way is to use the custom acronym style:

Code: Select all

\documentclass{article}

\usepackage{glossaries}

\renewcommand*{\CustomAcronymFields}{%
  name={\the\glsshorttok},%
  description={\noexpand\makefirstuc{\the\glslongtok}},%
  first={\noexpand\acrfullformat{\the\glslongtok}{\the\glsshorttok}},%
  firstplural={\noexpand\acrfullformat
    {\the\glslongtok\noexpand\acrpluralsuffix}{\the\glsshorttok}}%
  text={\the\glsshorttok},%
  plural={\the\glsshorttok\noexpand\acrpluralsuffix}%
}

\SetCustomStyle

\makeglossaries

\newacronym{ABC}{ABC}{a sample acronym}

\begin{document}

Test: \gls{ABC}. \gls{ABC}.

\printglossaries

\end{document}
Regards
Nicola Talbot
noid
Posts: 3
Joined: Fri Jan 20, 2012 8:59 am

Re: glossaries | Capitalize first Character in final List

Post by noid »

HI,

Thanks a lot for your response.

I tried playing around with \makefirstuc and \glsmakefirstuc or \xmakefirstuc.

Though the description field only seems to apply it to the first word in the acronym.
Is there any way to make each word in the list of acronym start with an upper case.

e.g. ABC A Sample Acronym, should be in the listing, whereas the text will have a sample acronym.

Thanks for your help,
User avatar
nlct
Posts: 276
Joined: Thu Nov 06, 2008 11:15 am

glossaries | Capitalize first Character in final List

Post by nlct »

Try this:

Code: Select all

\documentclass{article}

\usepackage{glossaries}
\usepackage{etoolbox}

\DeclareListParser{\wordlist}{ }%

\DeclareRobustCommand{\capitalise}[1]{%
  \def\addspace{}%
  \renewcommand*{\do}[1]{\addspace\makefirstuc{##1}\def\addspace{ }}%
  \wordlist{#1}%
}

\renewcommand*{\CustomAcronymFields}{%
  name={\the\glsshorttok},%
  description={\capitalise{\the\glslongtok}},%
  first={\noexpand\acrfullformat{\the\glslongtok}{\the\glsshorttok}},%
  firstplural={\noexpand\acrfullformat
    {\the\glslongtok\noexpand\acrpluralsuffix}{\the\glsshorttok}}%
  text={\the\glsshorttok},%
  plural={\the\glsshorttok\noexpand\acrpluralsuffix}%
}

\SetCustomStyle

\makeglossaries

\newacronym{ABC}{ABC}{a sample acronym}

\begin{document}

Test: \gls{ABC}. \gls{ABC}.

\printglossaries

\end{document}
Regards
Nicola Talbot
noid
Posts: 3
Joined: Fri Jan 20, 2012 8:59 am

Re: glossaries | Capitalize first Character in final List

Post by noid »

Hi,

Thanks a lot, that works just fine for my picky requirements!
Never thought about trying with a capitalize and creating custom command, as was done in the above code.

Great package!
Post Reply