6

In 1 I had the answer on how to put the translation of an acronym and used both English and Spanish version.

The issue now is that I have acronyms that are only Spanish, others only English without translation and English with translation. The format for the document mandates that English is written emphasized while Spanish is in normal.

Is there any way of automating it? I was thinking on having 2 list, English acronyms and only Spanish, then load them, assigning a different style and then merging them so in the list of acronyms they appear in order.

The other solution I have found is on my acronym's list create two styles:

\newcommand{\engstyle}[1]{\emph{#1}}
\newcommand{\espstyle}[1]{#1}
\newacronym{ENG}{ENG}{\engstyle{English acronym}} %
\newacronym{ESP}{ESP}{\espstyle{Spanish acronym}} %

But then in the list of acronyms they appear with the assigned style. And I want them without any style.

Any suggestion?

Edit: What I want as exit.

Within the test English acronym (ENG) is displayed and the Spanish one this way, Spanish acronym (ESP).

List of Acronyms

ENG English acronym

ESP Spanish acronym

Edit 2: I didn't realize that Nicola updated the package. Now the question is: Is it possible to set multiple setacronymstyle within the same doc?

1 Answer 1

6

It's not possible to use multiple acronym styles (one will usually override another). However, here's a possible solution that uses the user1 key to store the font style to use when you define an acronym:

% arara: pdflatex
% arara: makeglossaries
% arara: pdflatex
% arara: pdflatex

\documentclass{article}

\usepackage[acronym]{glossaries}

\makeglossaries

\newcommand*{\engstyle}[1]{\emph{#1}}
\newcommand*{\espstyle}[1]{#1}

\newcommand*{\newengacronym}[4][]{%
  \newacronym[user1=\protect\engstyle,#1]{#2}{#3}{#4}%
}

\newcommand*{\newespacronym}[4][]{%
  \newacronym[user1=\protect\espstyle,#1]{#2}{#3}{#4}%
}

\newacronymstyle{lang}
{%
  \GlsUseAcrEntryDispStyle{long-short}%
}%
{%
  \GlsUseAcrStyleDefs{long-short}%
  \renewcommand*{\genacrfullformat}[2]{%
   \glsentryuseri{##1}{\glsentrylong{##1}}##2\space
   (\glsentryshort{##1})%
  }%
  \renewcommand*{\Genacrfullformat}[2]{%
   \glsentryuseri{##1}{\Glsentrylong{##1}}##2\space
   (\glsentryshort{##1})%
  }%
  \renewcommand*{\genplacrfullformat}[2]{%
   \glsentryuseri{##1}{\glsentrylongpl{##1}}##2\space
   (\glsentryshortpl{##1})%
  }%
  \renewcommand*{\Genplacrfullformat}[2]{%
   \glsentryuseri{##1}{\Glsentrylongpl{##1}}##2\space
   (\glsentryshortpl{##1})%
  }%
}

\setacronymstyle{lang}

\newengacronym{ENG}{ENG}{English Acronym}
\newespacronym{ESP}{ESP}{Spanish Acronym}

\begin{document}

First use : \gls{ENG}, \gls{ESP}.

Next user: \gls{ENG}, \gls{ESP}.

\printglossaries

\end{document}

This produces:

Image of resulting document

Edit:

If you want to redefine \glsentrylong, you'll also need to redefine \Glsentrylong otherwise you'll cause a problem for \makefirstuc:

% arara: pdflatex
% arara: makeglossaries
% arara: pdflatex
% arara: pdflatex

\documentclass{article}

\usepackage[acronym]{glossaries}

\makeglossaries

\newcommand*{\engstyle}[1]{\emph{#1}}
\newcommand*{\espstyle}[1]{#1}

\newcommand*{\newengacronym}[4][]{%
  \newacronym[user1=\protect\engstyle,#1]{#2}{#3}{#4}%
}

\newcommand*{\newespacronym}[4][]{%
  \newacronym[user1=\protect\espstyle,#1]{#2}{#3}{#4}%
}

\makeatletter
\newacronymstyle{lang}
{%
  \GlsUseAcrEntryDispStyle{long-short}%
}%
{%
  \GlsUseAcrStyleDefs{long-short}%
  \renewcommand*{\glsentrylong}[1]{%
    \glsentryuseri{##1}{\@gls@entry@field{##1}{long}}}%
  \renewcommand*{\glsentrylongpl}[1]{%
    \glsentryuseri{##1}{\@gls@entry@field{##1}{longpl}}}%
  \renewcommand*{\Glsentrylong}[1]{%
    \glsentryuseri{##1}{\@Gls@entry@field{##1}{long}}}%
  \renewcommand*{\Glsentrylongpl}[1]{%
    \glsentryuseri{##1}{\@Gls@entry@field{##1}{longpl}}}%
}
\makeatother

\setacronymstyle{lang}

\newengacronym{ENG}{ENG}{English Acronym}
\newespacronym{ESP}{ESP}{Spanish Acronym}

\begin{document}

First use : \gls{ENG}, \gls{ESP}.

Next user: \gls{ENG}, \gls{ESP}.

Long form: \acrlong{ENG}, \acrlong{ESP}.

Long form (first UC): \Acrlong{ENG}, \Acrlong{ESP}.

Plural long form: \acrlongpl{ENG}, \acrlongpl{ESP}.

Plural long form (first UC): \Acrlongpl{ENG}, \Acrlongpl{ESP}.

\printglossaries

\end{document}

However if you do the above, you'll no longer be able to use \glsentrylong in PDF bookmarks.

3
  • That was just what I was trying to do. Actually I tried something similar, but the problem is I don't know where to learn how to program things in latex. Could you please point me to a book or something?
    – jlanza
    Commented Jan 27, 2014 at 9:15
  • @jlanza This kind of thing isn't usually covered in most guides, since a lot of them are usually intended for beginners. There are far fewer advanced guides, but have a look at Style/Class Tutorials or Where can I find programming techniques material. Commented Jan 27, 2014 at 10:00
  • is it possible to redefine the \renewcommand*{\glsentrylong}[1]{\@gls@entry@field{#1}{long}} as to include \glsentryuseri{##1} value. I guess it is quicker and will also work when using \Acrlong. I've tried renewing the command inside the new style, but it crashes
    – jlanza
    Commented Feb 1, 2014 at 18:29

You must log in to answer this question.

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