Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This is a repost of the original message I posted to comp.text.tex in August, which is still unanswered there. I'm sorry for reposting, but I want to spread this to a wider readership.

I found couple of similar questions (along with helpful answers) on StackExchange, however, they are more focused on how to deal with the variety of cases the German language has. This is not my actual problem, since the suggested workarounds for this issue are sufficient. They mostly incorporate the use of \glslink and \glsdisp.

Below is the text of my original post.

I would like to use the glossaries package for German documents including many English based acronyms. For better understanding, let's have a look at a simple example:

  • Acronym: PSK
  • English long: Phase Shift Keying
  • German long: Phasenumtastung

Im most cases, there is not corresponding acronym in German, therefore I would like to use the English acronym in my document. Upon first use, the inserted text shall look like

Phasenumtastung (PSK, Phase Shift Keying)

Upon further use, only

PSK

shall be used.

Finally, in the list of acronyms, it shall look like:

PSK - Phasenumtastung (Phase shift Keying)

I tried to to setup something customized by renewing \CustomAcronymFields, \SetCustomDisplayStyle and \glossaryentryfield following the user documentation. I'm using the current version 3.01 of glossaries.

My approach is basically to put the string ", Phase Shift Keying" into the description field while defining with \newacronym and then use it with customized \defglsdisplayfirst and \glossaryentryfield.

This is to demonstrate how it should look like:

% compile this with
%    pdflatex example.tex
%    makeindex  -s "example.ist" -t "example.alg" -o "example.acr" "example.acn"
%    pdflatex example.tex

\documentclass{scrartcl}

\usepackage[ngerman]{babel}

\usepackage[acronym,nomain,sanitize={description=false,symbol=false}]{glossaries}
\makeglossaries

%% Desired style:
% first: "German long (acronym[, English long])"
% following: "acronym"
\renewcommand*{\CustomAcronymFields}{%
    name={\the\glsshorttok},%
    symbol={\the\glslongtok},%
    text={\the\glsshorttok},%
    plural={\the\glsshorttok\noexpand\acrpluralsuffix}%
}

\renewcommand*{\SetCustomDisplayStyle}[1]{%
  % ##1 corresponds to the 'first' key
  % ##2 corresponds to the 'description' key
  % ##3 corresponds to the 'symbol' key
  % ##4 is the inserted text given by the final optional argument to
  % commands like \gls
  % The short form can be obtained via \glsentryshort{\glslabel}
  % The plural short form can be obtained via
  %\glsentryshortpl{\glslabel}
  % The long form can be obtained via \glsentrylong{\glslabel}
  % The plural long form can be obtained via
  %\glsentrylongpl{\glslabel}
  \defglsdisplayfirst[#1]{##3 (##1##4##2##4)}%
  % ##1 corresponds to the 'text' key
  % the rest as above
  \defglsdisplay[#1]{##1##4}%
}
\SetCustomStyle

% start the glossary entries with capitals
\newglossarystyle{superuc}{%
  \glossarystyle{super}%
  \renewcommand*\glossaryentryfield[5]{%
    \glstarget{##1}{##2} & \makefirstuc{##4}##3\glspostdescription\space##5\\
  }
}



%% acronym definitions
% italic typeset foreign language terms
\newcommand{\foreignlang}[1]{\emph{#1}}
% define acronym with both German and English long
\newcommand{\newacropair}[4]{\newacronym[description={, \foreignlang{#4}}]{#1}{#2}{#3}}
% define acronym with only German long
\newcommand{\newacrogerman}[3]{\newacronym[description={}]{#1}{#2}{#3}}
% define acronym with only English long
\newcommand{\newacroenglish}[3]{\newacronym[description={}]{#1}{#2}{\foreignlang{#3}}}

% sample acronyms
% English acronym along with its common German counterpart
\newacropair{acr:adc}{ADC}{Analog-Digital-Umsetzer}{Analog to Digital Converter}
% English acronym without a common German counterpart
\newacroenglish{acr:dect}{DECT}{Digital Enhanced Cordless Telecommunications}
% German acronym
\newacrogerman{acr:din}{DIN}{Deutsches Institut fuer Normung}


% Alternative first - to be used if the first use is not nominative singular.
% Problem: I do not find a way to use glossaries' integrated 'first use' flag.
% This macro is my current dirty implementation. It always displays the full form
% and unsets the 'first use' flag afterwards. Bad things happen if at a later point
% it time, I decide to mention the same acronym earlier. I'll be using \glsalt again
% and end up in a double definition of the acronym, which I would like to avoid.
\newcommand{\glsalt}[2]{\glslink{#1}{#2 (\acrshort*{#1}\glsdesc*{#1})}\glsunset{#1}}


\begin{document}

\section{Problems}

% For the first mention, I'll be using \glsalt, since I need to display the 
% German text in genitive.
Die Aufloesung des \glsalt{acr:adc}{Analog-Digital-Umsetzers} beeinflusst\dots

% In the example below, I would need a plural form. That means an 's' would
% have to be attached to both the English acronym as well as the English long form.
% I have no clue how to implement that cleanly, due to my changes in
% \SetCustomDisplayStyle in the preamble.
Die Aufloesung der \glsalt{acr:adc}{Analog-Digital-Umsetzer} beeinflusst\dots


\section{Normal Cases}

\glsreset{acr:adc}

% These are only to show how it should look like for the 'normal' cases.
\gls{acr:adc} -- \gls{acr:adc}

\gls{acr:dect} -- \gls{acr:dect}

\gls{acr:din} -- \gls{acr:din}

\printglossary[type=\acronymtype,style=superuc,nonumberlist=false]

\end{document}

This works for me unless I don't have to use the plural form upon the first occurence. From then on, the concept behind glossaries, so far I can understand, does not really allow my tweak.

The main reason, to my understanding, is the fact that when defining a new acronym by \newacronym, besides the label, only one short form and one long form can be passed and accessed in \CustomAcronymFields. These two can be accessed by \glsshorttok and \glslongtok for storing them under the user-defined keys, such as name, symbol, text, etc. Especially the description key itself cannot be accessed at this stage.

From the conceptual point of view, it would be helpful if all three forms (short, English long, German long) could be passed to \newacronym separately and then concatenated in a customized fashion to be finally stored with their corresponding keys, including firstplural and longplural. Note that for my example, I would e.g. have to append an "s" for the plural forms of the short form as well as to the English long form and provide a used-defined plural form for the German long form in most cases.

For now, my only question is whether you think that my problem can still be solved with what glossaries offers so far. If not, would it make sense to try to redefine a couple of commands? I've had the impression that e.g. \glsentryfull has to be redefined. However, one major problem I fear is that most of these commands only take a subset of keys, such as only short and long (not description) in case of \glsentryfull.

Or is there even another package which would do my task without modifications?

share|improve this question
    
Your question is lacking (like the orginal question on c.t.t) a complete minimal example that could be used for testing. –  Ulrike Fischer Oct 12 '11 at 10:27
    
@UlrikeFischer, you are right. My question is more a conceptual one, therefore I did not create one yet. I will add one asap. –  Christoph Oct 12 '11 at 11:02
    
Well your example actually don't show your problem with the plural. Apart from this: You are writing a german text so I think you should try to translate also "Enhanced Data Rate". At second I think you are putting to much emphasis on the "foreign language" aspect. The main attribute of the text behind the acronym is not that it is in english but that it explains its origin. There could also stand a text like "first used in the novel ...". Also I doubt that you actually need language dependant \newacronym commands. –  Ulrike Fischer Oct 12 '11 at 12:28
    
Well, this stuff is used in the context of communication technologies. 99% of the acronyms are English, and some of them do not have a common German counterpart. So it is for EDR -- sure I could translate it to erweiterte Datenrate, however, in the context of the document, this is uncommon. Maybe EDR is not the best example, I will replace it by another one. –  Christoph Oct 12 '11 at 13:57
    
You should put @Ulrike in comments so that I get notified of your answers. I do understand your problem with the multitudity of english technical terms, nevertheless I do think you should make an effort to keep them at bay. But the main point of my comment was that imho you should change your point of view: don't divide your acronyms in "german" and "english" acronyms. Actually you seem to have currently at least 3 types: normal (DIN), commented (ADC), name with additional formating (EDR). –  Ulrike Fischer Oct 12 '11 at 15:11
show 1 more comment

1 Answer

up vote 9 down vote accepted

I missed the question when it was posted to comp.text.tex, but here's a solution. It uses the user1 key to store the translation:

\documentclass{article}

\usepackage{glossaries}
\usepackage{etoolbox}

\newtoks\customtok

\renewcommand*{\newacronymhook}{%
 \edef\dosetkeys{\noexpand\setkeys{glossentry}{user1={},\the\glskeylisttok}}%
 \dosetkeys
 \ifcsempty{@glo@useri}%
 {%
   \expandafter\customtok\expandafter{\the\glsshorttok}%
 }%
 {%
   \edef\custom{\the\glsshorttok, \csexpandonce{@glo@useri}}%
   \expandafter\customtok\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\glslongtok\space(\the\customtok)},%
  firstplural={\the\glslongtok\noexpand\acrpluralsuffix
    \space (\the\customtok)}%
  text={\the\glsshorttok},%
  plural={\the\glsshorttok\noexpand\acrpluralsuffix}%
}

\SetCustomStyle

\makeglossaries

\newacronym[user1=Phase Shift Keying]{psk}{PSK}{Phasenumtastung}
\newacronym{aa}{AA}{Another Acronym}

\begin{document}

First use: \gls{psk}. Subsequent use: \gls{psk}.

First use: \gls{aa}. Subsequent use: \gls{aa}.

\printglossaries
\end{document}
share|improve this answer
    
@egreg could you please help me on modifying the code above so it is: OtherLanguage_long (PSK, EnglishLong). I want to store in user1 the OtherLanguage_long. And if possible to use user2 to set the plural for the OtherLanguage_long. –  jlanza Nov 18 '13 at 12:00
    
@jlanza I suggest you post a new question with a link back to this one. –  Nicola Talbot Nov 18 '13 at 12:15
    
I have posted the preliminary solution to my problem at tex.stackexchange.com/questions/136634/… I used 2 custom tokens, on for singular and another for plural. I guess I can tune it a bit more automating the plural from the singular, but Spanish is quite strange on plurals ;) –  jlanza Nov 18 '13 at 15:31
    
Based on the solution I proposed or yours, do you know how to make the custompostdesc to be capitalized on the Glossaries list? I've tried plenty of things mainly from tex.stackexchange.com/questions/103838/… but I get errors :( Could you please help me on that? –  jlanza Nov 18 '13 at 16:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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