I'm using glossaries package to make my list of acronyms. I'm writing in Spanish but some of my acronyms are in English. I want them to be displayed like:
Spanish description – English long (Short) –
I was thinking on using the description label in glossaries to include the Spanish description. However I don't know how to modify the \acX macros in order to display the acronym correctly (first time all, next just the short, etc.)
Any help or hint is more than welcome.
CU
Edit: After having Using the glossaries package for English acronyms in German documents I need it to be modified to a format like:
OtherLanguage_long (Short, Long)
Long (Short)
ie. –> Calidad de Servicio (QoS, Quality of Service)
Internet Protocol (IP)
Edit 2: Problem solved… At least I think so.
I've created to tokens, one for plural and another for singular.
\documentclass{article}
\usepackage[acronym, toc, shortcuts]{glossaries}
\usepackage{etoolbox}
\newtoks\customtoksingular
\newtoks\customtokplural
\renewcommand*{\newacronymhook}{%
\edef\dosetkeys{\noexpand\setkeys{glossentry}{user1={},\the\glskeylisttok}}%
\dosetkeys
\ifcsempty{@glo@useri}%
{%
%\expandafter\customtoksingular\expandafter{\the\glsshorttok\space(\the\glslongtok)}%
\expandafter\customtoksingular\expandafter{\noexpand\acrfullformat{\the\glslongtok}{\the\glsshorttok}}%
}%
{%
\edef\custom{\csexpandonce{@glo@useri}\space(\the\glsshorttok, \the\glslongtok)}%
\expandafter\customtoksingular\expandafter{\custom}%
}%
\ifcsempty{@glo@userii}%
{%
%\expandafter\customtoksingular\expandafter{\the\glsshorttok\space(\the\glslongtok)}%
\expandafter\customtokplural\expandafter{\noexpand\acrfullformat
{\noexpand\glsentrylongpl{\the\glslabeltok}}%
{\noexpand\glsentryshortpl{\the\glslabeltok}}}
}%
{%
\edef\custom{\csexpandonce{@glo@userii}\space(\the\glsshorttok, \the\glslongtok\noexpand\acrpluralsuffix)}%
\expandafter\customtokplural\expandafter{\custom}%
}%
}
\newcommand*{\custompostdesc}[1]{%
\ifcsempty{glo@#1@useri}{}{ (\glsentryuseri{#1})}%
}
\renewcommand*{\CustomAcronymFields}{%
user1={},%
name={\the\glsshorttok},%
description={\the\glslongtok\noexpand\custompostdesc{\the\glslabeltok}},%
first={\the\customtoksingular},%
firstplural={\the\customtokplural},%
% first={\the\glslongtok\space(\the\customtoksingular)},%
%firstplural={\the\glslongtok\noexpand\acrpluralsuffix\space (the\customtoksingular},%
text={\the\glsshorttok},%
plural={\the\glsshorttok\noexpand\acrpluralsuffix}%
}
\SetCustomStyle
\makeglossaries
\newacronym[user1=interfaz de programaci\'{o}n de la aplicaci\'{o}n, user2=interfaces de programaci\'{o}n de la aplicaci\'{o}n]{api}{API}{Application Programming Interface}
\newacronym{aa}{AA}{Another Acronym}
\begin{document}
First use: Las \acp{api} .... Subsequent use: \acp{api}
\glsresetall{}
First use: Las \ac{api} .... Subsequent use: \ac{api}
First use: \gls{aa}. Subsequent use: \gls{aa}.
\printglossary[type=\acronymtype]
\end{document}
Best Answer
I recommend you upgrade to the latest version of
glossaries
(v4.01 at time of writing) as it's more flexible. Here's an example that uses v4.01:This produces:
Edit:
If you upgrade to the latest version (v4.02, 2013/12/05) it's easier to define a new acronym style and have
\acf
match the style. (Although it's also possible to define acronym styles where they don't match, as is the case with the predefinedfootnote
style where\acr
doesn't use a footnote.) Here's the above example rewritten using v4.02 code:This produces:
Edit 2:
In answer to @cacamailg's comment regarding only using the non-English version, the simplest method is just to define a set of commands that check the first use flag like this:
Then you can do something like:
This has some limitations, for example, you can't use the final insert optional argument used by commands like
\gls
.