I am creating a bilingual (main: greek, secondary: english) document with xelatex
and polyglossia
and I'm using biblatex
with biber for the bibliography management. As biblatex is currently setup the bibliography is output in greek which is fine. However, since most of the bibliography is english, the bibliography fields are not hyphenated properly.
If I add autolang=hyphen
to the biblatex options, the hyphenation is correct, but the whole entry converts to english which is something I do not want. Is there any way to change language on a per field basis only? For now I have created a simple macro \newcommand{\en}{\selectlanguage{english}}
and add \en
to the fields I want in english, but this is tiresome and error-prone on a document with way too many references. Is there any way to change the language of the specified fields (title, author, journal, booktitle) but not alter the language of the whole entry?
MWE
\documentclass{book}
% Change these if you want
\newcommand{\MainFont}{Times New Roman}
\newcommand{\SansFont}{Arial}
\newcommand{\MonoFont}{Courier New}
\usepackage{filecontents}
\begin{filecontents}{bibliography.bib}
@article{anarticle,
author={Lathrop, J.W.},
journal={Electron Devices, IRE Transactions on},
title={Photolithographic fabrication techniques for transistors},
year={1958},
month={April},
volume={5},
number={2},
pages={117},
doi={10.1109/T-ED.1958.14395},
ISSN={0096-2430},
langid={english},
hyphenation={english}
}
\end{filecontents}
\usepackage{fontspec}
\usepackage{polyglossia}
\setmainlanguage{greek}
\setotherlanguage{english}
\usepackage[backend=biber,style=alphabetic,maxcitenames=2]{biblatex}
\setmainfont[Mapping=tex-text,Ligatures={TeX,Common}]{\MainFont}
\setsansfont[Mapping=tex-text,Ligatures={TeX,Common}]{\SansFont}
\setmonofont[Mapping=tex-text,Ligatures={TeX,Common}]{\MonoFont}
\newfontfamily\greekfont[Script=Greek,Mapping=tex-text,Ligatures={Common,TeX}]{\MainFont}
\newfontfamily\greekfontsf[Script=Greek,Mapping=tex-text,Ligatures={Common,TeX}]{\SansFont}
\newfontfamily\greekfonttt[Script=Greek,Mapping=tex-text,Ligatures={Common,TeX}]{\MonoFont}
\addbibresource{bibliography.bib}
\begin{document}
\cite{anarticle}
\printbibliography
\end{document}
autolang=hyphen
option does exactly this: the bibliography will be in the main language, but hyphenation will respectlangid
language=autobib,autolang=other
orlanguage=autocite,autolang=other
you will see a difference. this is also ho to set manually fields. You will not need to set maunually in bbl or bib file:\DeclareFieldFormat{title}{% \iffieldundef{langid} {#1} {\foreignlanguage{\thefield{langid}}{#1}}% } \DeclareListFormat{location}{% \iffieldundef{langid} {#1} {\foreignlanguage{\thefield{langid}}{#1}}% } \DeclareFieldFormat{institution}{% \iffieldundef{langid} {#1} {\foreignlanguage{\thefield{langid}}{#1}}% }
\renewcommand*{\mkbibnamefirst}[1]{\foreignlanguage{\thefield{langid}}{\scshape #1}} \renewcommand*{\mkbibnamelast}[1]{\foreignlanguage{\thefield{langid}}{\scshape #1}}
but you need to have langid fields in bib file