如果我向环境添加一个参数acronym
来设置首字母缩写词列的宽度,则首字母缩写词列中文本的字体会自动更改。我该如何防止(或至少控制)这种情况?下面是一个加载了参数的 MWE [PdL]
:
\documentclass[12pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[american]{babel}
\usepackage[babel]{csquotes}
\usepackage{acronym}
\begin{document}
\begin{acronym}[PdL]
\acro{PD}{Democratic Party (\textit{Partito Democratico})}
\acro{PdL}{The People of Freedom (\textit{Il Popolo della Libertà})}
\end{acronym}
\end{document}
下面是同一个示例的输出,但没有[PdL]
加载参数:
答案1
这似乎是软件包作者的明智选择。如果没有acronym
指定可选参数,则列表将排版为普通description
环境。否则,可选参数将设置标签宽度并\bflabel
用于排版首字母缩略词。
当然\bflabel
可以在序言中重新定义;默认定义是
\def\bflabel#1{{\textbf{\textsf{#1}}\hfill}}
然而,实现并不好,因为宽度是使用
\settowidth{\labelwidth}{\textbf{\textsf{#1}}}
无论如何,而不是正确的
\settowidth{\labelwidth}{\bflabel{#1}}
这里有一个“更正确”的实现,它使用\bflabel
不带可选参数的实现:
\documentclass[12pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[american]{babel}
\usepackage[babel]{csquotes}
\usepackage{acronym}
\makeatletter
\renewenvironment{AC@deflist}[1]%
{\ifAC@nolist
\else
\raggedright
\begin{list}{}{\settowidth{\labelwidth}{\bflabel{#1}}%
\setlength{\leftmargin}{\labelwidth}%
\addtolength{\leftmargin}{\labelsep}%
\let\makelabel\bflabel}%
\fi}
{\ifAC@nolist
\else
\end{list}%
\fi}
\renewenvironment{acronym}[1][1]
{%
\providecommand*{\acro}{\AC@acro}%
\providecommand*{\acroplural}{\AC@acroplural}%
\long\def\acroextra##1{##1}%
\def\@tempa{1}\def\@tempb{#1}%
\ifx\@tempa\@tempb
\global\expandafter\let\csname ac@des@mark\endcsname\AC@used
\ifAC@nolist
\else
\begin{description}\let\makelabel\bflabel
\fi
\else
\begin{AC@deflist}{#1}%
\fi
}
{%
\ifx\AC@populated\AC@used
\else
\ifAC@nolist
\else
\item[]\relax%
\fi
\fi
\expandafter\ifx\csname ac@des@mark\endcsname\AC@used
\ifAC@nolist
\else
\end{description}%
\fi
\else
\end{AC@deflist}%
\fi}
\makeatother
% Provide here a new definition for \bflabel if desired
%\def\bflabel#1{{\textbf{\textsf{#1}}\hfill}}
\begin{document}
\begin{acronym}[PdL]
\acro{PD}{Democratic Party (\textit{Partito Democratico})}
\acro{PdL}{The People of Freedom (\textit{Il Popolo della Libertà})}
\end{acronym}
\end{document}