我的文档有两种类型的缩写:
- 翻译,我想用法语和英语打印长格式(带有突出显示的首字母)。例如:
\newabbreviation[
longplural={interfaces de programmation d'application},
user1={de l'anglais~:~application programming interface}
]{abb.api}{API}{interface de programmation d'application}
- 未翻译,我只想打印英文长表(再次突出显示首字母)。例如:
\newabbreviation{gpt}{GPT}{generative pre-trained transformer}
- 法语缩写,我只想打印法语的长格式(再次突出显示首字母)。例如:
\newabbreviation[
longplural={accidents vasculaires cérébraux}
]
{avc}{AVC}{accident vasculaire cérébral}
我设法用缩写风格做到了这一点。我甚至通过使用 和重新定义long-short-user
获得了所需的首字母行为。\GlsXtrEnableInitialTagging{abbreviation}{\itag}
\glsxtrtagfont
剩下的就是配置缩写列表,使得:
- 对于定义了 user1 字段的缩写,我想要打印它。
- 对于其他人,我希望打印长格式。
我目前正在使用long,nonumberlist
该命令的样式\printglossary
,但无法生成正确的英语和翻译缩写输出。有没有办法定义自定义样式来更改缩写列表中打印的内容?
编辑:这是一个最小的例子:
\documentclass[12pt, a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[english, arabic, greek, main=french]{babel}
\usepackage[LAE, T1]{fontenc}
\usepackage[abbreviations, automake]{glossaries-extra}
\setabbreviationstyle{long-short-user}
\glssetcategoryattribute{abbreviation}{noshortplural}{true}
\GlsXtrEnableInitialTagging{abbreviation}{\itag}
\newcommand{\highlight}[1]{\uppercase{\textbf{#1}}}
\renewcommand{\glsxtrtagfont}{\highlight}
% French
\newabbreviation[
longplural={\itag{a}ccidents \itag{v}asculaires \itag{c}érébraux}
]
{avc}{AVC}{accident vasculaire cérébral}
% Translated
\newabbreviation[
longplural={interfaces de programmation d'application},
user1={de l'anglais~:~\itag{a}pplication \itag{p}rogramming \itag{i}nterface}
]{api}{API}{interface de programmation d'application}
% English
\newabbreviation[
user1={\itag{g}enerative \itag{p}re-trained \itag{t}ransformer}
]{gpt}{GPT}{}
\makeglossaries
\begin{document}
\printabbreviations[title={Liste des abréviations}, style=long,nonumberlist]
\begin{itemize}
\item \gls{avc}
\item \gls{api}
\item \gls{gpt}
\end{itemize}
\end{document}
答案1
像这样?(我让你的例子更简洁一些,添加了一个新的词汇表样式,它输出字段user1
而不是description
是否存在字段。)
\documentclass{article}
\usepackage[english, main=french]{babel}
\usepackage[abbreviations, automake]{glossaries-extra}
\setabbreviationstyle{long-short-user}
\glssetcategoryattribute{abbreviation}{noshortplural}{true}
\GlsXtrEnableInitialTagging{abbreviation}{\itag}
\newcommand{\highlight}[1]{\uppercase{\textbf{#1}}}
\renewcommand{\glsxtrtagfont}{\highlight}
\newglossarystyle{custom-long}{%
\setglossarystyle{long}%
\renewcommand{\glossentry}[2]{%
\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
\setbox0=\hbox{\glsentryuseri{##1}\unskip}%
\ifdim\wd0=0pt%
\glossentrydesc{##1}%
\else
\glsentryuseri{##1}%
\fi
\glspostdescription\space ##2\tabularnewline
}%
}
% French
\newabbreviation[
longplural={\itag{a}ccidents \itag{v}asculaires \itag{c}érébraux}
]{avc}{AVC}{accident vasculaire cérébral}
% Translated
\newabbreviation[
longplural={interfaces de programmation d'application},
user1={de l'anglais~:~\itag{a}pplication \itag{p}rogramming \itag{i}nterface}
]{api}{API}{interface de programmation d'application}
% English
\newabbreviation[
user1={\itag{g}enerative \itag{p}re-trained \itag{t}ransformer}
]{gpt}{GPT}{}
\makeglossaries
\begin{document}
\printabbreviations[title={Liste des abréviations}, style=custom-long, nonumberlist]
\begin{itemize}
\item \gls{avc}
\item \gls{api}
\item \gls{gpt}
\end{itemize}
\end{document}