我正在使用该acronym
包来管理我的缩写。TeX.SE 的旧贡献\Ac
提供了一个可行的解决方案,在使用而不是时将缩写的第一个字符大写\ac
。在我的例子中,有些句子以化学物质的名称开头,或者后者列在表格中。在这些情况下,当然,物质名称也应该大写。不幸的是,前一个答案的提议补丁在这里失败了,因为 IUPAC 命名法通常以数字开头,例如3-丙基-1-胺. 即使是用引号括起来的单词,例如“点击”化学( \enquote{click} chemistry
) 不能正确大写。
我怎样才能扩展补丁程序以将首字母大写而不是将首字符大写?
麦当劳
\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}
此代码存在三个问题
- 该命令会
\Acl{APA}
产生以下错误:! Argument of \iupac has an extra }.
\acl{APA}
- 使用时
\Acl{APA}
,我希望输出是3-Azido-1-propylamine
而不是3-azido-1-propylamine
。 - 使用时
\Acs{CuAAC}
,我希望输出是"Click" chemistry
而不是"click" chemistry
。
答案1
这不是使用软件包的解决方案acronym
,而是一种替代方案:使用最新版本的acro
软件包可以“开箱即用”(感谢模块l3text
):
\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 ,
long = copper(I)-catalyzed azide-alkyne cycloaddition
}
\begin{document}
1: \Acl{APA}
2: \Acs{CuAAC}
3: \Acl{CuAAC}
\end{document}