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.
Following a suggestion of Javier Bezos, patching \bbl@fixname
seems better, because it also works with all language changing commands.
\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{natbib}
\usepackage{doi}
\usepackage{hyperref}
\bibliographystyle{apsrev4-1}
\makeatletter
\let\ORIbbl@fixname\bbl@fixname
\def\bbl@fixname#1{%
\@ifundefined{languagealias@\expandafter\string#1}
{\ORIbbl@fixname#1}
{\edef\languagename{\@nameuse{languagealias@#1}}}%
}
\newcommand{\definelanguagealias}[2]{%
\@namedef{languagealias@#1}{#2}%
}
\makeatother
\definelanguagealias{en}{english}
\begin{document}
\cite{Renyi1961}
\bibliography{\jobname}
\end{document}
Here's something you can play with:
\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[paperwidth=9cm, paperheight=10cm, showframe]{geometry}
\parindent 0pt%
%\usepackage[american, british]{babel}
%\usepackage{datetime}
\def\germtoday{% Example format: Date Month Year
\number\day\space
\ifcase\month\or
Januar%
\or Februar%
\or März%
\or April%
\or Mai%
\or Juni%
\or Juli%
\or August%
\or September%
\or Oktober%
\or November%
\or Dezember%
\fi
\space\number\year}
\newcommand\germanaffidavit{
\begingroup
\language=31%
The language is \the\language. {\germtoday}
% \showhyphens{% Useful to test how words are being hyphenated
This text will be in Language stating the same information as the
Language one above. Of course this should automatically use
correct hyphenation for Language texts.
% }
\endgroup}
\newcommand\englishaffidavit{%
\begingroup
\language=0
The language is \the\language. \today
% \showhyphens{%
This text will be in Language stating the same information as the
Language one above. Of course this should automatically use
correct hyphenation for Language texts.
% }
\endgroup}
\newcommand\affidavit{\germanaffidavit\newpage\englishaffidavit}
\begin{document}
The language is \the\language
This text will be in Language stating the same information as the
Language one above. Of course this should automatically use
correct hyphenation for Language texts.
\newpage
\affidavit
\newpage
The language is \the\language
This text will be in Language stating the same information as the
Language one above. Of course this should automatically use
correct hyphenation for Language texts.
\end{document}
Remarks
When switching babel
off, compile twice to get rid of the error message.
I'd be inclined to use a custom date command to avoid dependency on other packages for getting it 'right'; what I suggested here is meant to be illustrative of the possibilities, not definitive or even standards-compliant.
Uncomment the \showhyphens
command to verify that TeX is hyphenating things correctly (note that the output gets printed in the .log
)
Best Answer
I just ran into the same problem with a German document. Here is what fixed the problem without any workarounds in Ubuntu; You need to adjust this to your TeX/OS combination.
Also note that the described PDF Properties workaround did not work in my case. In general, I would always first look for ways to fix the actual problem, rather than using workarounds that strip my software of its features.
Edit: On Fedora this helped:
sudo dnf install texlive-babel-german