前面带有箭头的首字母缩略词

前面带有箭头的首字母缩略词

我正在使用该acronyms包,我想知道是否有一种简单的方法可以通过在首字母缩略词前面放置箭头来标记它们?

答案1

这是一个有点不寻常的请求。我假设使用该命令时,箭头应该出现在全名和缩写形式之间\ac。在下面的示例代码中,我展示了如何进行。这个想法是重新定义内部命令\@ac;这意味着定义一系列类似于\acf\acf*和的命令\acfa来实际排版箭头:

\documentclass{article}
\usepackage[colorlinks]{hyperref}
\usepackage[printonlyused,withpage]{acronym}

\makeatletter
% similar to \acf and relatives but adding an arrow between the full name and the short form
\newcommand*{\Arracf}{\AC@starredfalse\protect\Arracfa}%
\WithSuffix\newcommand\Arracf*{\AC@starredtrue\protect\Arracfa}%
\newcommand*{\Arracfa}[1]{%
  \texorpdfstring{\protect\@Arracf{#1}}{\AC@acl{#1} (#1)}}
\newcommand*{\@Arracf}[1]{%
  \ifAC@footnote
    \acsfont{\AC@acs{#1}}%
      \footnote{\AC@placelabel{#1}\AC@acl{#1}{}}%
  \else
  \acffont{%
    \AC@placelabel{#1}\AC@acl{#1}%
      $\rightarrow$\nolinebreak[3]\acfsfont{(\acsfont{\AC@acs{#1}})}%
  }%
  \fi
  \ifAC@starred\else\AC@logged{#1}\fi}

%modification of \@ac to use \Arracf (which includes the arrow)
\renewcommand{\@ac}[1]{%
  \ifAC@dua
    \ifAC@starred\acl*{#1}\else\acl{#1}\fi%
  \else
    \expandafter\ifx\csname ac@#1\endcsname\AC@used%
      \ifAC@starred\acs*{#1}\else\acs{#1}\fi%
    \else
      \ifAC@starred\Arracf*{#1}\else\Arracf{#1}\fi%
    \fi
  \fi
}
\makeatother

\begin{document}

\section{Intro}
In the early nineties, \ac{GSM} was deployed in many European
 countries. \ac{GSM} offered for the first time international
roaming for mobile subscribers. The \ac{GSM}'s use of \ac{TDMA} as
 its communication standard was debated at length. And every now
 and then there are big discussion whether \ac{CDMA} should have
been chosen over \ac{TDMA}.

\begin{acronym}[TDMA]
\acro{CDMA}{Code Division Multiple Access}
\acro{GSM}{Global System for Mobile communication}
\acro{TDMA}{Time Division Multiple Access}
\end{acronym}

\end{document}

免责声明:我不确定上述代码是否会按照acronym包提供的所有命令变体的预期运行。

编辑:下面的代码重新定义\ac为除了第一个之外的所有首字母缩略词的用法自动在前面添加一个箭头(如评论中所要求的):

\documentclass{article}
\usepackage[colorlinks]{hyperref}
\usepackage[printonlyused,withpage]{acronym}

\makeatletter
%modification of \@ac to include an arrow for every use except the first
\renewcommand{\@ac}[1]{%
  \ifAC@dua
    \ifAC@starred\acl*{#1}\else\acl{#1}\fi%
  \else
    \expandafter\ifx\csname ac@#1\endcsname\AC@used%
      \ifAC@starred\acs*{#1}\else\mbox{$\rightarrow$\acs{#1}}\fi%
    \else
      \ifAC@starred\Arracf*{#1}\else\acf{#1}\fi%
    \fi
  \fi
}
\makeatother

\begin{document}

\section{Intro}
In the early nineties, \ac{GSM} was deployed in many European
 countries. \ac{GSM} offered for the first time international
roaming for mobile subscribers. The \ac{GSM}'s use of \ac{TDMA} as
 its communication standard was debated at length. And every now
 and then there are big discussion whether \ac{CDMA} should have
been chosen over \ac{TDMA}.

\begin{acronym}[TDMA]
\acro{CDMA}{Code Division Multiple Access}
\acro{GSM}{Global System for Mobile communication}
\acro{TDMA}{Time Division Multiple Access}
\end{acronym}

\end{document}

相关内容