1

My document has two types of abbreviations:

  • Translated, for which I want to print the long form in French and English (with highlighted initials). For example:
\newabbreviation[
    longplural={interfaces de programmation d'application},
    user1={de l'anglais~:~application programming interface}
]{abb.api}{API}{interface de programmation d'application}
  • Non translated, for which I want to print the long form in English only (again with highlighted initials). For example:
\newabbreviation{gpt}{GPT}{generative pre-trained transformer}
  • French abbreviations, for which I want to print the long form in French only (again with highlighted initials). For example:
\newabbreviation[
    longplural={accidents vasculaires cérébraux}
]
{avc}{AVC}{accident vasculaire cérébral}

I managed to do this with the long-short-user abbreviation style. I even got the desired behavior for initials by using \GlsXtrEnableInitialTagging{abbreviation}{\itag} and redefining \glsxtrtagfont.

All that remains is to configure the list of abbreviations such that:

  • For abbreviations for which the user1 field is defined, I want to print it.
  • For others, I want the long form to be printed.

I am currently using the long,nonumberlist style for the \printglossary command, which is not producing the correct output for English and translated abbreviations. Is there a way to define a custom style that changes what is printed in the list of abbreviations?

Edit: Here's a minimal example:

\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}

The output: enter image description here

2
  • Welcome to TeX.SE! Please show us a short compilable code you have so far, then we do not have to guess what you are doing ...
    – Mensch
    Commented Jun 4, 2023 at 18:21
  • @Mensch for notifying me. It is done.
    – 0sharp
    Commented Jun 4, 2023 at 18:41

1 Answer 1

0

Like this? (I made you example a bit more minimal added a new glossary style that outputs the user1 field instead of the description if it is present.)

\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}

MWE output

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .