3

For writing linguistics papers, I use leipzig.sty for making lists of abbreviations used in glosses. In its documentation, there is the section "4.3 Redefine existing abbreviations"; however, it's left blank. That is exactly what I'd like to do, to redefine existing abbreviations with something else (especially for papers written in a language other than English).

Instructions on how to do this would be greatly appreciated! Thank you.

Added below is a mwe:

\documentclass{article}

\usepackage[nomain,nostyles]{glossaries}
\usepackage{glossary-inline}
\usepackage{leipzig}

\makeglossaries

\newleipzig{erg}{erg}{nokaku}

\begin{document}

test\footnote{\printglossary[style=inline]}

{\Erg}

\end{document}
cgnieder
  • 66,645
renoh
  • 159
  • Welcome to TeX.SX! Can you be more specific? What precisely is “left blank”? – egreg Nov 08 '15 at 14:54
  • @egreg hi egreg, nothing is written in the document in that section. What I'd like to do is, e.g. redefine 'erg' as something other than 'ergative', more precisely, as 'nokaku', which means ergative in Japanese. I'd like to be able to do that just for papers written in Japanese, and still be able to use the predefined standard Leipzig abbreviations. – renoh Nov 08 '15 at 15:05
  • Looking at leipzig.sty, \newleipzig{erg}{nok}{nokaku} (or whatever) should do. – egreg Nov 08 '15 at 16:14
  • @egreg Thank you. That works for abbreviations not yet defined, but it does not work for those that are predefined. The predefined ones are listed in leipzig.tex, I think, but I don't want to make changes to that file. So, I'm hoping that there is a way to redefine (or override the predefined ones) in the preamble. – renoh Nov 09 '15 at 00:42
  • Please, add a minimal example of code. It will make things easier. See http://meta.tex.stackexchange.com/q/228 – egreg Nov 09 '15 at 00:43
  • @egreg Sorry, I should have done that. I added a mwe. I use xelatex, but platex gives me the same error. – renoh Nov 09 '15 at 01:07
  • Maybe I'm wrong, but it seems that one has to delve into glossaries internals, because \newleipzig executes \newacronym and so trying to redefine an abbreviations conflicts with the already existing entry. – egreg Nov 09 '15 at 07:54
  • That's too bad... but thank you for your help. I'll wait and see if someone else comes up with a solution. – renoh Nov 09 '15 at 08:39

1 Answers1

2

I can offer you an \undefleipzig so you are able to reset an abbreviation with \newleipzig:

\documentclass{article}

\usepackage[nomain,nostyles]{glossaries}
\usepackage{glossary-inline}
\usepackage{leipzig}

\newcommand{\undefleipzig}[1]{\csundef{glo@\glsdetoklabel{#1}@name}}

\undefleipzig{erg}
\newleipzig{erg}{erg}{nokaku}

\makeglossaries

\begin{document}

test

{\Erg}

\printglossary[style=inline]

\end{document}

The problem is that \newleipzig does \newacronym, when glossaries is loaded. So when one tries to redefine an existing abbreviation, the protection mechanism of glossaries enters into action. With the \undefleipzig trick, this mechanism is disabled for the particular entry we want to kill.

A possible definition of \renewleipzig to supplement the existing \newleipzig could be

\documentclass{article}

\usepackage[nomain,nostyles]{glossaries}
%\usepackage{glossary-inline}
\usepackage{leipzig}

\makeatletter
\newcommand{\renewleipzig}[2][]{%
  \if@leipzig@defined{#2}
    {%
     \renew@leipzig{#1}{#2}%
    }%
    {%
     \PackageError{leipzig}
       {Abbreviation `#2' undefined}
       {No `#2` abbreviation is defined, use \string\newleipzig}%
     \@gobbletwo
    }%
}
\def\if@leipzig@defined#1{%
  \uppercase\expandafter{\expandafter\ifcsname\@car#1\@nil}\@cdr#1\@nil\endcsname
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi
}
\def\renew@leipzig#1#2{%
  \ifcsname glo@\glsdetoklabel{#2}@name\endcsname
    \csundef{glo@\glsdetoklabel{#2}@name}
  \fi
  \if\relax\detokenize{#2}\relax
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi
  {\newleipzig{#2}}{\newleipzig[#1]{#2}}%
}
\makeatother

\renewleipzig{erg}{erg}{nokaku}
\newleipzig{aaa}{bbb}{ccc}
\renewleipzig[first=UUU]{aaa}{bbb}{ccc}

\makeglossaries

\begin{document}

test

\Erg{}

\Aaa

\Aaa

\printglossary

\end{document}

I'm not sufficiently expert in leipzig to understand if the result is as expected.

egreg
  • 1,121,712
  • Thank you @egreg! This works perfectly! I'm really thankful. – renoh Nov 09 '15 at 09:01
  • The second solution didn't work. It gave me: "bbb bbb ccc. 1 erg erg nokaku. 1". – renoh Nov 09 '15 at 11:02
  • Hi @renoh, I know this is an old thread, but this is a behaviour of leipzig that I haven't been able to pin down. It only happens on some systems, so it probably has to do with the particular version of glossaries which you have.

    Try putting \glsunsetall after \makeglossaries and before \begin{document}

    – Natalie Weber Jun 02 '16 at 19:07
  • @egreg's answer was so nice that I included it in a package update (leipzig 2.0, added to CTAN 2017-06-16). The update also fixes some other bugs, including the "bbb bbb ccc." problem. (For that issue, see this and this question. – Natalie Weber Jun 17 '17 at 17:16
  • @NatalieWeber You're welcome! – egreg Jun 17 '17 at 17:40