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}
\usepackage[nohyperlinks, printonlyused, withpage]{acronym}
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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{}%
{\string\newacro{#1}[\string\AC@hyperlink{#1}{#2}]{\AC@uppercase@write #3}}%
\@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}}
\acro{CuAAC}[\enquote{click} chemistry]{copper(I)-catalyzed azide-alkyne cycloaddition}
\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
- The
\Acl{APA}command produces the following error:! Argument of \iupac has an extra }.which does not occur with\acl{APA} - When using
\Acl{APA}, I want the output to be3-Azido-1-propylamineinstead of3-azido-1-propylamine. - When using
\Acs{CuAAC}, I want the output to be"Click" chemistryinstead of"click" chemistry.

