2

I'm using glossaries-extra for spanish and english acronims, and works well for my. I followed this posts:

Using the glossaries package for English acronyms in German documents

But I want to change the order in that the acronyms is showed in the list in the case that user1 is defined.

Im using this

\documentclass{article}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}         

\usepackage[acronym, nomain, nonumberlist, toc]{glossaries-extra}
\setabbreviationstyle[acronym]{long-short-user}

\renewcommand{\glsxtrpostdescacronym}{%
 \ifglshasfield{\glsxtruserfield}{\glscurrententrylabel}%
 { (\textit{\glscurrentfieldvalue})}%
 {}%
}
\makeglossaries

\newacronym[user1=Signal to Noise Ratio]{snr}{SNR}{relación señal a ruido}
\newacronym{utn}{UTN}{Universidad Tecnológica Nacional}

\begin{document}    

Primer uso de \gls{snr}. Segundo uso de \gls{snr}.

Primer uso de \gls{utn}. Segundo uso de \gls{utn}.

\printglossaries

\end{document}

and I get:

enter image description here

But I want:

enter image description here

In summary I want to show

short user1 (long)

if user1 is defined, else I want to show only

short long

Can somebody help me?

Best Regards,

Matias

1

There are two approaches that I can think of. The first is to define a custom style that's modified to check for the user1 field. For example:

\documentclass{article}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}         

\usepackage[acronym, nomain, nonumberlist, toc]{glossaries-extra}
\setabbreviationstyle[acronym]{long-short-user}

\makeglossaries

\newacronym[user1=Signal to Noise Ratio]{snr}{SNR}{relación señal a ruido}
\newacronym{utn}{UTN}{Universidad Tecnológica Nacional}

\newglossarystyle{bilinguallist}{%
  \setglossarystyle{list}% base it on the list style
  \renewcommand*{\glossentry}[2]{%
    \item[\glsentryitem{##1}%
          \glstarget{##1}{\glossentryname{##1}}]
      \ifglshasfield{\glsxtruserfield}{##1}%
      {\textit{\glscurrentfieldvalue} (\glossentrydesc{##1})}%
      {\glossentrydesc{##1}}%
      \glspostdescription\space ##2}%
}
\setglossarystyle{bilinguallist}% set this new style

\begin{document}

Primer uso de \gls{snr}. Segundo uso de \gls{snr}.

Primer uso de \gls{utn}. Segundo uso de \gls{utn}.

\printglossaries

\end{document}

image of document

The second method modifies \glossentrydesc which is used in all the predefined glossary styles when displaying the description.

With the base glossaries package, this command just checks if the entry has been defined and displays the description. The glossaries-extra package redefines this command to set the current abbreviation style and check for the attributes glossdescfont and glossdesc before displaying the description.

If you're not interested in using the glossdescfont and glossdesc attributes, you could just redefine \glossentrydesc like this:

\documentclass{article}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}         

\usepackage[acronym, nomain, nonumberlist, toc]{glossaries-extra}
\setabbreviationstyle[acronym]{long-short-user}

\makeglossaries

\newacronym[user1=Signal to Noise Ratio]{snr}{SNR}{relación señal a ruido}
\newacronym{utn}{UTN}{Universidad Tecnológica Nacional}

\renewcommand{\glossentrydesc}[1]{%
 \glsdoifexistsorwarn{#1}%
 {%
   \glssetabbrvfmt{\glscategory{#1}}%
   \ifglshasfield{\glsxtruserfield}{#1}%
   {\textit{\glscurrentfieldvalue} (\glsentrydesc{#1})}%
   {\glsentrydesc{#1}}%
 }%
}

\begin{document}

Primer uso de \gls{snr}. Segundo uso de \gls{snr}.

Primer uso de \gls{utn}. Segundo uso de \gls{utn}.

\printglossaries

\end{document}

The result is the same as before.

| improve this answer | |
  • Hello Nicola, both solutions works well. I took the second one because in the real document i'm using \setglossarystyle{long}. Thank you. – Matías Leonel Martini Aug 17 '17 at 14:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.