过去,我广泛使用了词汇表包。现在,我尝试使用首字母缩略词,其中构成首字母缩略词的字母在首字母缩略词列表中带有下划线。在文本中,我希望\gls
首先使用缩写来显示其描述的脚注文本,其中描述链接到首字母缩略词列表中的相应条目:
\acronymfont{<abbrv>}\footnote{<description>}
在首字母缩略词列表中,我希望正常显示缩写和完整格式以及数字列表。因此,主要区别在于,在脚注中不显示完整格式,而是显示描述,描述是 的可选参数\newacronym
。
\CustomAcronymFields
是否可以通过、\SetCustomDisplayStyle
和/或 的帮助来实现\SetCustomStyle
?
答案1
如果您想定义自定义缩写样式,强烈建议您至少升级到 v4.02。如果您这样做,您可以尝试以下操作:
\documentclass{article}
\usepackage[colorlinks]{hyperref}
\usepackage[acronym]{glossaries}
\makeglossaries
\newacronymstyle{custom-fn}% new style name
{% Check for long form in case of a mixed glossary
\ifglshaslong{\glslabel}{\glsgenacfmt}{\glsgenentryfmt}%
}%
{% Style definitions:
% User needs to supply the description:
\renewcommand*{\GenericAcronymFields}{}%
% Need to ensure hyperlinks are switched off on first use:
\glshyperfirstfalse
% Redefine the commands used by \glsgenacfmt on first use:
\renewcommand*{\genacrfullformat}[2]{%
\firstacronymfont{\glsentryshort{##1}}##2%
\footnote{\glshyperlink[\glsentrydesc{##1}]{##1}}%
}%
\renewcommand*{\Genacrfullformat}[2]{%
\firstacronymfont{\Glsentryshort{##1}}##2%
\footnote{\glshyperlink[\glsentrydesc{##1}]{##1}}%
}%
\renewcommand*{\genplacrfullformat}[2]{%
\firstacronymfont{\glsentryshortpl{##1}}##2%
\footnote{\glshyperlink[\glsentrydesc{##1}]{##1}}%
}%
\renewcommand*{\Genplacrfullformat}[2]{%
\firstacronymfont{\Glsentryshortpl{##1}}##2%
\footnote{\glshyperlink[\glsentrydesc{##1}]{##1}}%
}%
% Redefine the no-link full forms:
\renewcommand*{\glsentryfull}[1]{%
\glsentrylong{##1}\space(\acronymfont{\glsentryshort{##1}})%
}%
\renewcommand*{\Glsentryfull}[1]{%
\Glsentrylong{##1}\space(\acronymfont{\glsentryshort{##1}})%
}%
\renewcommand*{\glsentryfullpl}[1]{%
\glsentrylongpl{##1}\space(\acronymfont{\glsentryshortpl{##1}})%
}%
\renewcommand*{\Glsentryfullpl}[1]{%
\Glsentrylongpl{##1}\space(\acronymfont{\glsentryshortpl{##1}})%
}%
% Redefine the link full forms:
\renewcommand*{\acrfullfmt}[3]{%
\glslink[##1]{##2}{%
\glsentrylong{##2}##3\space(\acronymfont{\glsentryshort{##2}})%
}%
}%
\renewcommand*{\Acrfullfmt}[3]{%
\glslink[##1]{##2}{%
\Glsentrylong{##2}##3\space(\acronymfont{\glsentryshort{##2}})%
}%
}%
\renewcommand*{\ACRfullfmt}[3]{%
\glslink[##1]{##2}{%
\MakeTextUppercase{%
\glsentrylong{##2}##3\space
(\acronymfont{\glsentryshort{##2}})%
}%
}%
}%
\renewcommand*{\acrfullplfmt}[3]{%
\glslink[##1]{##2}{%
\glsentrylongpl{##2}##3\space
(\acronymfont{\glsentryshortpl{##2}})%
}%
}%
\renewcommand*{\Acrfullplfmt}[3]{%
\glslink[##1]{##2}{%
\Glsentrylongpl{##2}##3\space
(\acronymfont{\glsentryshortpl{##2}})%
}%
}%
\renewcommand*{\ACRfullplfmt}[3]{%
\glslink[##1]{##2}{%
\MakeTextUppercase{%
\glsentrylongpl{##2}##3\space
(\acronymfont{\glsentryshortpl{##2}})%
}%
}%
}%
% Don't apply any font change for the acronym in the document text:
\renewcommand*{\acronymfont}[1]{##1}%
\renewcommand*{\acrpluralsuffix}{\glspluralsuffix}%
% Sort acronyms according to the short form:
\renewcommand*{\acronymsort}[2]{##1}%
}
% Now set the new acronym style (to override the default style)
\setacronymstyle{custom-fn}
% Define a glossary style that will display the short form followed
% by the long form.
\newglossarystyle{custom-fn}%
{%
% base it on the long style
\setglossarystyle{long}%
\renewcommand{\glossentry}[2]{%
\glsentryitem{##1}\glstarget{##1}{\glsentryshort{##1}} &
\glsentrylong{##1}\glspostdescription\space ##2\tabularnewline
}%
}
% Now define the acronyms (must be done after setting the custom
% style)
\newacronym[description={set of tags for use in developing hypertext
documents}]{html}{html}{\underline{h}yper \underline{t}ext
\underline{m}arkup \underline{l}anguage}
\begin{document}
\gls{html}.
\printglossary[type=acronym,style=custom-fn]
\end{document}
产品: