# Change Long Form of Acronym to Lower Case in Text (Glossaries)

There are a lot of examples of how to change first letters to upper case using glossaries (Capitalize first letter of each word when printing list of acronyms, capitalisation and list of acronyms, Glossaries Capitalize Every First Letter)

In my case, have to use some acronyms with both a lower case and an upper case version in the text, while at the same time having an upper case first letter in the list of acronyms in the long form. On the other hand, I have some entries that do not have an upper case version, so I can't simply use \Glsentrylong, when redefining the style.

So far, changing the appearance in the text is no problem, if the long form is given in lower case. Changing the appearance in the list, however, proved to be too difficult for me. I tried checking for a user entry, using \ifglshasfield, without success (not even with long-short-user and and long-short-user-desc styles). My attempts to increase the number of categories and checks (that are already done for the description) utterly failed.

In the original version (commented part) I was not able to change the appearance of the long form in the list of acronyms when the long form was lower case. If the long form was upper case, I was not able to use a lower case long form in text. Using text={lowcaseupcase} with {Lowcaseupcase} as the long form also gave the long form in the text.

In the current version I get the following outputs in the list:

• long form given: long form printed (ok, see WOD, xyz) user entry and
• long form given: user entry printed (ok, see HAHA)
• description and long form given: just the description is printed (long form missing, see ANY, MAKRO, tbd)
• desription, long form and user entry given: the long form and the description are given (user entry missing, see HOHO, LCUC)

Is there a way to use lower case long forms in text while having the upper case form in the list without capitalizing every entry?

A possible solution might be to explicitly convert the first letter in text to lower case (as opposed to \acl{label} vs \Acl{label}) but I fear that would mean to define a lot of new commands. Maybe I missed a simple solution to this...

\documentclass{scrartcl}

\usepackage[ngerman]{babel}
\usepackage{calc}
\usepackage[xindy,shortcuts=ac,nomain,acronym,nogroupskip,toc,shortcuts,numberedsection=nameref]{glossaries-extra}

\setlength{\glslistdottedwidth}{.5\hsize}

% discriminate between entries with and without descriptions: based on https://tex.stackexchange.com/questions/355455/style-acronyms-long-forms-and-avoid-description-fields-for-those-that-dont-have
\makeatletter
\define@key{mynewabbrv}{description}{\def\mydesc{#1}}
\makeatother
\renewcommand*{\newacronym}[4][]{%
\def\mydesc{}%
\setkeys*{mynewabbrv}{#1}%
\ifdefempty{\mydesc}%
{\newabbreviation[category=withoutdesc,#1]{#2}{#3}{#4}}%
{\newabbreviation[category=withdesc,#1]{#2}{#3}{#4}}%
}

\newglossarystyle{finallistdotted}%
{%
\setglossarystyle{list}%
\renewenvironment{theglossary}%
{%
\begin{description}%
\labelsep=0pt%
}%
{\end{description}}%
}%
\renewcommand*{\glsgroupskip}{\indexspace}%
\renewcommand{\glossentry}[2]{%
\item[]\makebox[\glslistdottedwidth][l]{%
\glsentryitem{##1}%
\glstarget{##1}{\glsentryshort{##1}%
}%
% previous output that worked except for capitalizing the first letters of defined  entries
%       \glsifcategory{##1}{withoutdesc}%
%       {\glsentrylong{##1}}%   \Glsentrylong{##1} gives the entry with the first letter capitalized
%       {%
%           \parbox[t]{\textwidth-\glslistdottedwidth}{\glsentrylong{##1}\space (\glossentrydesc{##1})}%    \Glsentrylong{##1} gives the entry with the first letter capitalized
%       }%
% my check for user1 -- prints user1 does not print \glsentrylong when user1 is not given and the entry has a description
\glsifcategory{##1}{withoutdesc}%
{\ifglshasfield{useri}{##1}%
{\glsentryuseri{##1}}%
{\glsentrylong{##1}}%   \Glsentrylong{##1} gives the entry with the first letter capitalized
}%
{%
\ifglshasfield{useri}{##1}%
{\parbox[t]{\textwidth-\glslistdottedwidth}{\glsentrylong{##1}\space (\glossentrydesc{##1})}}%  \Glsentrylong{##1} gives the entry with the first letter capitalized
{\parbox[t]{\textwidth-\glslistdottedwidth}{\glsentryuseri{##1}\space (\glossentrydesc{##1})}}%
}%
}%
}
\makeglossaries

\setabbreviationstyle[withoutdesc]{long-short}
\setabbreviationstyle[withdesc]{long-short-desc}
\renewcommand*{\glsxtrlongshortdescsort}{\the\glsshorttok}  % sort by short form

\newcommand{\mymacro}{\textit{my~macro}}

% some stupid examples
\newacronym[]{WOD}{WOD}{Without Description}
\newacronym[]{xyz}{xyz}{xyz}

\newacronym[user1={Haha}]{HAHA}{HAHA}{haha}

\newacronym[description={long form missing}]{ANY}{ANY}{Anything}
\newacronym[description={long form missing}]{macro}{MAKRO}{\mymacro}
\newacronym[description={long form missing -- here I need the lower case in the list of acronyms even for the first letter of the long form, so I can't seem to use \emph{Glsentrylong} in the definition of \emph{finallistdotted} -- that would be too easy!}]{tbd}{tbd}{to be done}

\newacronym[user1={Hoho},description={long form instead of user entry given -- similar to HAHA but with description}]{HOHO}{HOHO}{hoho}
\newacronym[user1={Lowcaseupcase},description={long form instead of user entry given -- \textbf{this should allow lower case (lowcaseupcase) and upper case (Lowcaseupcase) versions in text but print "Lowcaseupcase" in the list of acronyms}}]{LCUC}{LCUC}{lowcaseupcase}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\glssetcategoryattribute{acronym}{glossname}{title}

\begin{document}

\ac{ANY} -- \ac{ANY}

\ac{WOD} -- \ac{WOD}

Pre\acl{LCUC} -- \Acl{LCUC} -- \Ac{LCUC} -- \Acf{LCUC} -- Pre\acl{LCUC} -- Pre-\acs{LCUC}

Pre\acl{HAHA} -- \Acl{HAHA} -- \Ac{HAHA} -- \Acf{HAHA} -- Pre\acl{HAHA} -- Pre-\acs{HAHA}

\Acl{HOHO}

\ac{tbd} -- \acs{tbd} -- \Acl{tbd}. -- \ACS{tbd}! -- \ACL{tbd}!!!

\ac{macro}

\ac{xyz}

\printglossary[type=\acronymtype,style=finallistdotted,title=Abkürzungsverzeichnis,toctitle=Abkürzungsverzeichnis]

\end{document}

• If i understand you right, you are looking for an easy(?) way to print only/exactly what YOU want in the glossary and also have the different options within the main text ... correct? If so, did you try to declare an extra key (or e.g. use user1) for every entry, which you will use for the glossarystyle? – Venez Apr 24 '20 at 13:00
• In short, I want to print the long form as given in \newacronym. An entry "lower case" should be printed "lower case", an entry "Upper case" should be printed "Upper case" in the list of acronyms. In the text I also have to use "upper case" in some context, where I have some kind of prefix, like "noupper case". Trying to use the user1 key is exactly what I was trying in my example. However, it did not work with the styles in the example or if I used styles with "user". – Echo Apr 24 '20 at 13:25

I will concentrate my answer on the essential part of your question (at least i think so ^^#). The code below should help you to specify the text you want to show for every entry in the glossary - without consideration if there is a UpperCase form or whatever. Is that any help to you?

PS: You could also use user1, but then you must switch \glsglostext{##1} with \glsuseri{##1} in the style definition.

\documentclass{scrartcl}
\usepackage[nomain,acronym]{glossaries-extra}

{glostext}              % new key
{\glsentrytext{TODO}}   % default value
{\glsentryglostext}     % analogous to \glsentrytext
{\Glsentryglostext}     % analogous to \Glsentrytext
{\glsglostext}          % analogous to \glstext
{\Glsglostext}          % analogous to \Glstext
{\GLSglostext}          % analogous to \GLStext

% Define the glossary entries
\newacronym[
glostext={HoHo},
user1={HoHO},
description={long form instead of user entry},
]{HOHO}{HOHO}{hoho}

% Set the new glossary style
\newglossarystyle{yourAcronyms}{%
\setglossarystyle{list}%
\renewcommand*{\glossentry}[2]{%
\item[\glsentryitem{##1}%
\glstarget{##1}{\glossentryname{##1}}]
\glsglostext{##1}\glspostdescription\space ##2}%
}

\makeglossaries
\begin{document}

• Thank you, this is very helpful but I still can't figure out what to do, when I have a " normal" entry where I don't need glostext (e.g. \newacronym[description={just Haha}]{HAHA}{HAHA}{Haha}). Is there a way to fall back to use \glsentrylong for this entry? – Echo Apr 24 '20 at 15:05
• Replacing \glsentrytext{TODO} by \glsentrylong{##1} does not produce an error but does not print a long form for HAHA, either. – Echo Apr 24 '20 at 15:13
• Even if you have a "normal" entry there is nothing wrong with a definition of a glostext field nonetheless. You are right, it is a double entry but its easy to maintain. Or do you want the algorithm to check for it by all means? – Venez Apr 24 '20 at 15:27
• For a few entries it might be ok to add a definition of glostext but consider a case with many "normal" entries and just a few where glostext is needed. In this case, a check is definetly needed. – Echo Apr 24 '20 at 15:45
• A small man's solution that works for me is to keep the upper case entry in the long field and put the lower case version in glostext. In this case there is no need for a redefinition of the glossary style and redundancy is kept to a minimum. One can use Pre\glslink{HOHO}{\glsglostext{HOHO}} or Pre-\glslink{HOHO}{\glsentryshort{HOHO}} and even Pre-\glslink{HOHO}{\glsentryshort{HOHO}} (Pre\glslink{HOHO}{\glsglostext{HOHO}}). These can be called by a user-defined macro, as needed. I would not have found this solution without Venez' answer, though. – Echo Apr 27 '20 at 7:57