# Capitalize first letter of an acronym (acronym package)

I am using the acronym package to manage my abbreviations. An older contribution from TeX.SE offered a working solution to capitalize the first character of the abbreviation when using \Ac instead of \ac. In my case, some sentences start with the name of a chemical substance or the latter are listed in a table. In these cases, of course, the substance names should also be capitalized. Unfortunately, the proposed patch of the former answer fails here because the IUPAC nomenclature often starts with a number, such as 3-acidopropyl-1-amin. Even words enclosed in quotation marks such as "click" chemistry (\enquote{click} chemistry) cannot be capitalized correctly.

How could I extend the patch to capitalize the first letter instead of the first character?

## M(N)WE

\documentclass{article}
\usepackage{csquotes}
\usepackage{chemmacros}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Acronyms Patch
%
% Extend acronym package with first letter caps
% https://tex.stackexchange.com/a/150798/117727
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\makeatletter
\newif\ifAC@uppercase@first%
\def\Aclp#1{\AC@uppercase@firsttrue\aclp{#1}\AC@uppercase@firstfalse}%
\def\AC@aclp#1{%
\ifcsname fn@#1@PL\endcsname%
\ifAC@uppercase@first%
\expandafter\expandafter\expandafter\MakeUppercase\csname fn@#1@PL\endcsname%
\else%
\csname fn@#1@PL\endcsname%
\fi%
\else%
\AC@acl{#1}s%
\fi%
}%
\def\Acp#1{\AC@uppercase@firsttrue\acp{#1}\AC@uppercase@firstfalse}%
\def\AC@acp#1{%
\ifcsname fn@#1@PL\endcsname%
\ifAC@uppercase@first%
\expandafter\expandafter\expandafter\MakeUppercase\csname fn@#1@PL\endcsname%
\else%
\csname fn@#1@PL\endcsname%
\fi%
\else%
\AC@ac{#1}s%
\fi%
}%
\def\Acfp#1{\AC@uppercase@firsttrue\acfp{#1}\AC@uppercase@firstfalse}%
\def\AC@acfp#1{%
\ifcsname fn@#1@PL\endcsname%
\ifAC@uppercase@first%
\expandafter\expandafter\expandafter\MakeUppercase\csname fn@#1@PL\endcsname%
\else%
\csname fn@#1@PL\endcsname%
\fi%
\else%
\AC@acf{#1}s%
\fi%
}%
\def\Acsp#1{\AC@uppercase@firsttrue\acsp{#1}\AC@uppercase@firstfalse}%
\def\AC@acsp#1{%
\ifcsname fn@#1@PL\endcsname%
\ifAC@uppercase@first%
\expandafter\expandafter\expandafter\MakeUppercase\csname fn@#1@PL\endcsname%
\else%
\csname fn@#1@PL\endcsname%
\fi%
\else%
\AC@acs{#1}s%
\fi%
}%
\edef\AC@uppercase@write{\string\ifAC@uppercase@first\string\expandafter\string\MakeUppercase\string\fi\space}%
\def\AC@acrodef#1[#2]#3{%
\@bsphack%
\protected@write\@auxout{}{%
\string\newacro{#1}[#2]{\AC@uppercase@write #3}%
}\@esphack%
}%
\def\Acl#1{\AC@uppercase@firsttrue\acl{#1}\AC@uppercase@firstfalse}%
\def\Acf#1{\AC@uppercase@firsttrue\acf{#1}\AC@uppercase@firstfalse}%
\def\Ac#1{\AC@uppercase@firsttrue\ac{#1}\AC@uppercase@firstfalse}%
\def\Acs#1{\AC@uppercase@firsttrue\acs{#1}\AC@uppercase@firstfalse}%
\robustify\Aclp%
\robustify\Acfp%
\robustify\Acp%
\robustify\Acsp%
\robustify\Acl%
\robustify\Acf%
\robustify\Ac%
\robustify\Acs%

\def\AC@@acro#1[#2]#3{%
\ifAC@nolist%
\else%
\ifAC@printonlyused%
\expandafter\ifx\csname acused@#1\endcsname\AC@used%
\item[\protect\AC@hypertarget{#1}{\acsfont{#2}}] #3%
\ifAC@withpage%
\expandafter\ifx\csname r@acro:#1\endcsname\relax%
\PackageInfo{acronym}{Acronym #1 used in text but not spelled out in full in text}%
\else%
\dotfill\pageref{acro:#1}%
\fi\\%
\fi%
\fi%
\else%
\item[\protect\AC@hypertarget{#1}{\acsfont{#2}}] #3%
\fi%
\fi%
\begingroup%
\def\acroextra##1{}%
\@bsphack%
\protected@write\@auxout{}%
\@esphack%
\endgroup%
}
\makeatother

% %%%%%%%%%%%%%%%%%%
% Start the document
% %%%%%%%%%%%%%%%%%%

\begin{document}

\section*{List of Abbreviations}
\begin{acronym}[\enquote{click} chemistry]
\acro{APA}[3-APA]{\iupac{3-azido-1-propyl|amine}}
\end{acronym}

\section{Use of the abbreviations}
\subsection{Use of \texttt{\textbackslash ac\{\}} /  \texttt{\textbackslash acs\{\}} and \texttt{\textbackslash acl\{\}}}
\acl{APA} (\acs{APA})\\
\acl{CuAAC} (\acs{CuAAC})

\subsection{Use of \texttt{\textbackslash Ac\{\}} /  \texttt{\textbackslash Acs\{\}} and \texttt{\textbackslash Acl\{\}}}
\Acl{APA} (\Acs{APA})\\
\Acl{CuAAC} (\Acs{CuAAC})

\end{document}


### Three problems with this code

1. The \Acl{APA} command produces the following error: ! Argument of \iupac has an extra }. which does not occur with \acl{APA}
2. When using \Acl{APA}, I want the output to be 3-Azido-1-propylamine instead of 3-azido-1-propylamine.
3. When using \Acs{CuAAC}, I want the output to be "Click" chemistry instead of "click" chemistry.
• Completely unrelated to the issue itself, but you might want to check your current definition of "click reaction". As far as I can see, the current text is more an example for a click reaction than an actual definition. Actually, the current description text would better fit to the abbreviation CuAAC (that you seem to use as a key to refer to "click reaction"). You might want to change that. Also, "click reaction" itself is not really an abbreaviation, such as "3-APA" is, so why is it listed in the "list of abbreviations" then? Nov 7 '19 at 7:57
• @leandriis You are right that the term "click" chemistry also describes reactions other than CuAAC. However, it is not uncommon to use the term for CuAAC, as the most important representative of this reaction class. Of course, you have to pay attention to the context of the research and the readership. In my case, however, this is perfectly okay. As far as the type of abbreviation is concerned, you are of course also right. But since I want to consistently talk about "click" chemistry, if CuAAC is meant, it was useful to regard this as an "abbreviation".
– Sam
Nov 7 '19 at 9:59

Not a solution with the acronym package but an alternative: with an up to date version of acro this works “out of the box” (thanks to the l3text module):

\documentclass{article}

\usepackage{acro}
\usepackage{csquotes}
\usepackage{chemmacros}

\DeclareAcronym{APA}{
short = 3-APA ,
long = \iupac{3-azido-1-propyl|amine}
}
\DeclareAcronym{CuAAC}{
short = \enquote{click} chemistry ,