# Long form of acronyms capitalized in section headings

I use the glossaries package and defined headers often in section titles.

In general I keep the first letter of each word in the headings in capital case, but if an acronym occurs the first time, it is printed in full length, but I can only capitalize the first letter by command.

\documentclass{scrartcl}

\usepackage[acronym]{glossaries}
\newacronym{test}{TTSbCiH}{this text should be capitalized in headings}
\makeglossaries

\begin{document}
\section{\Gls{test}}
\Glsfirst{test}

\glsfirst{test}
\end{document}


which looks like

But, it should rather be "1 This Text Should Be Capitalized In Headings" (even better was "1 This Text Should be Capitalized in Headings")

How can I achieve that?

• To be honest, as it stands now, i would just not use the mechanism of glossaries and set the description by hand. If you want to do that multiple times (not just two or three), you can probably automate this, but the question that arises for me would be: Is a sectin heading really the right thing to use here? Dec 20, 2014 at 13:16

I would patch this setup by adding a macro \Glsheading that retrieves a capitalized version of the long acronym description. So, you could say something like

\section{\Glsheading{test}}


In the glossaries package those things are accomplished with token registers. For your purpose it will be sufficent to store the relevant information into a macro. Hence a definition of \Glsheading could look like

\newcommand{\Glsheading}[1]{\@nameuse{gls@cap@head@#1}}


Now, you need to include a little module to \newacronym that stores the control sequence gls@cap@head@#1, or in your example case \gls@cap@head@test (=> "This Text Should Be Capitalized In Headings (TTSbCiH)"):

\LetLtxMacro{\gls@newacronym}{\newacronym}
\renewcommand{\newacronym}[4][]{%
\gls@newacronym[#1]{#2}{#3}{#4}


Note: This definition uses the letltxmacro package and a helper macro \capitalize (given in the complete code)

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

%<begin_patch>
\usepackage{letltxmacro}
\makeatletter
\LetLtxMacro{\gls@newacronym}{\newacronym}
\renewcommand{\newacronym}[4][]{%
\gls@newacronym[#1]{#2}{#3}{#4}
\makeatother

\newcommand{\capitalize}[1]{%
\ignorespaces
\expandafter\expandafter\expandafter
\xcapitalize\expandafter\space #1 \relax}
\def\xcapitalize#1 #2{%
#1%
\ifx\relax#2\else
\space\MakeUppercase{#2}%
\expandafter\xcapitalize
\fi}
%<end_patch>

\newacronym{test}{TTSbCiH}{this text should be capitalized in headings}
\makeglossaries

\begin{document}