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.

I use \usepackage[english]{babel}, but I am keeping getting error:

Package babel Error: You haven't defined the language EN yet.

while parsing bibliography with \bibliographystyle{apsrev4-1} (curiously enough, for some other bibliography styles I don't get this problem).

I've discovered that in some bib entries there are lines

language = {en},

Changing en to english does solve the problem. However, as I get the bib file generated from other tool (Mendeley) it would be annoying.

Is there a way to define language en as a synonym of english?

Note:

There is a similar question Unable to get rid of error babel: You haven't defined the language en yet?, but it is closed as unclear.

Example:

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}

\usepackage{hyperref}

\usepackage{natbib}
\bibliographystyle{apsrev4-1}
\usepackage{doi}

\begin{document}

    \cite{Renyi1961}

    \bibliography{notwrk}

\end{document}

And notwrk.bib

@inproceedings{Renyi1961,
author = {R\'{e}nyi, Alfr\'{e}d},
booktitle = {Proceedings of the Fourth Berkeley Symposium on Mathematical Statistics and Probability, Volume 1: Contributions to the Theory of Statistics},
issn = {0097-0433},
language = {en},
publisher = {The Regents of the University of California},
title = {{On Measures of Entropy and Information}},
url = {http://projecteuclid.org/euclid.bsmsp/1200512181},
year = {1961}
}
share|improve this question
1  
Also this question is unclear, mainly because an example is missing. –  egreg Sep 3 at 10:42
1  
@egreg What is unclear in "[In babel], [i]s there a way to define language en as a synonym of english?"? In any case, as of now I am working on a phd thesis, so it would take me time to create a "minimal (not) working example". –  Piotr Migdal Sep 3 at 10:46
2  
How are we supposed to reproduce the issue? Just a minimal preamble, the bibliography style, a citation and an entry that creates the problem. I tried to make a M(n)WE, but got no error. –  egreg Sep 3 at 10:47
    
I added example. –  Piotr Migdal Sep 3 at 11:12

1 Answer 1

up vote 5 down vote accepted

This is not a full aliasing system, because it acts just on \selectlanguage, but it should be sufficient for your purpose. A full system would need deep surgery in babel.

\begin{filecontents*}{\jobname.bib}
@inproceedings{Renyi1961,
author = {R\'{e}nyi, Alfr\'{e}d},
booktitle = {Proceedings of the Fourth Berkeley Symposium on Mathematical Statistics 
  and Probability, Volume 1: Contributions to the Theory of Statistics},
issn = {0097-0433},
language = {en},
publisher = {The Regents of the University of California},
title = {{On Measures of Entropy and Information}},
url = {http://projecteuclid.org/euclid.bsmsp/1200512181},
year = {1961}
}
\end{filecontents*}

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}

\usepackage{hyperref}

\usepackage{natbib}
\bibliographystyle{apsrev4-1}
\usepackage{doi}

\usepackage{letltxmacro}

\LetLtxMacro{\ORIGselectlanguage}{\selectlanguage}
\makeatletter
\DeclareRobustCommand{\selectlanguage}[1]{%
  \@ifundefined{alias@\string#1}
    {\ORIGselectlanguage{#1}}
    {\begingroup\edef\x{\endgroup
       \noexpand\ORIGselectlanguage{\@nameuse{alias@#1}}}\x}%
}
\newcommand{\definelanguagealias}[2]{%
  \@namedef{alias@#1}{#2}%
}
\makeatother

\definelanguagealias{en}{english}


\begin{document}

    \cite{Renyi1961}

    \bibliography{\jobname}

\end{document}

The filecontents* trick is just to make the example self-contained, you don't need it and you can use the normal .bib file you have.

share|improve this answer
    
Thanks, works! For the full file I had to add also \definelanguagealias{EN}{english}, as it seems to be case-sensitive. –  Piotr Migdal Sep 3 at 13:05
    
@PiotrMigdal Yes, it is. But it's just a matter of adding the necessary aliases once the need arises. –  egreg Sep 3 at 13:47

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.