1

The following BibTeX document is saved in ~/TestBib.bib.

@book{silberstein,
   author = {Shel Silverstein},
   title = {The Giving Tree},
   year = {1964},
   langid = {english}
}
@book{goldberg,
   author = {Lea Goldberg},
   title = {An Apartment for Rent},
   year = {1959},
   langid = {hebrew}
}

The following LaTeX document is saved in ~/Test.tex.

\documentclass{article}
%\usepackage[bidi=basic,hebrew,provide=*]{babel}
%\babelfont{rm}[Renderer=HarfBuzz]{FreeSans}    
\usepackage{biblatex}
\addbibresource{TestBib.bib}
\begin{document}
\cite{silberstein}\cite{goldberg}    
\printbibliography
\end{document}

When the following commands are executed in the Terminal:

> cd ~
> lualatex Test
> biber Test
> lualatex Test

the file ~/Test.pdf is generated. When opened in a PDF viewer, the file displays as follows.

An English document with a bibliography

If now the two commented lines are uncommented, and the .tex file is recompiled as above, the resulting .pdf file displays as follows.

A Hebrew document with a bibliography

(Note that Hebrew is a right-to-left language.)

Is it possible to set things up in such a way that bibliographic entries whose langid field is Hebrew would be right aligned with right-to-left text flow, whereas bibliographic entries whose langid field is English would be left aligned with left-to-right text flow?

For comparison, a similar effect to what I'm after can be accomplished easily using the bidi package (which requires the xelatex compiler) as follows.

\documentclass{article}
\usepackage[rldocument]{bidi}
\begin{document}
\begin{thebibliography}{99}
\bibitem LLea Goldberg. \emph{An Apartment for Rent}. 1959
\begin{LTRbibitems}
\bibitem SShel Silverstein. \emph{The Giving Tree}. 1964
\end{LTRbibitems}
\end{thebibliography}
\end{document}

A correctly formatted bidirectional bibliography using the bidi package

This is a similar question to mine, but the answer given there uses two separate bibliographies, whereas I'm interested in one continuous bibliography.

P.S.

It can be assumed that those bibliographic entries with langid equal to hebrew are in Hebrew, and not in English as in the example above. I'm not looking to recreate the right-to-left text flow effect on English text as in the bidi+xelatex example above.


I have added an enhancement request to the biblatex bug tracking so that the issue described in this post can be dealt with easily, flexibly, and naturally by biblatex.

2

2 Answers 2

2

While waiting for the enhancement, since LuaTex inherit's Omega's directionality commands, a potential workaround could be to use luabidi package's \setLTR command at every bibitem to reverse the item's paragraph direction for, say, non-hebrew langids (to relocate the bibitem label), and then insert a small amount of horizontal space.

example

I took the liberty of applying a negative fake slant for the titles in the Hebrew font.

Default Bibsorting for numeric style appears to be Unicode-based, by family name of first author.

MWE

\begin{filecontents*}[overwrite]{\jobname.bib}
@Book{מישהו1990,
  title     = {ספר},
  publisher = {הוצאה},
  date      = {1990},
  author    = {מישהו},
  langid    = {hebrew}
}
@Book{lg,
  title     = {דירה להשכיר},
%  publisher = {xxx},
  date      = {1959},
  author    = { לאה גולדבר},
  langid    = {hebrew}
}


@book{silberstein,
   author = {Shel Silverstein},
   title = {The Giving Tree},
   year = {1964},
   langid = {english}
}
@book{goldberg,
   author = {Lea Goldberg},
   title = {An Apartment for Rent},
   year = {1959},
   langid = {english}
}
\end{filecontents*}

\documentclass{article}
\usepackage{xcolor}
\usepackage{luabidi}

\usepackage[bidi=basic,english,hebrew,provide=*]{babel}
\babelfont{rm}[Renderer=HarfBuzz]{FreeSans}    
\babelfont[hebrew]{rm}[Renderer=HarfBuzz,Colour=blue,AutoFakeSlant=-0.2]{FreeSans}    

\usepackage[autolang=other*]{biblatex}
\addbibresource{\jobname.bib}

%\AtEveryBibitem{\currentlang :: \thefield{langid}}
\AtEveryBibitem{\iffieldequalstr{langid}{hebrew}{}{\setLTR\hspace{\leftmargin}\hspace{\itemsep}}}

\begin{document}
\cite{silberstein} \cite{lg} \cite{goldberg}    \cite{מישהו1990}
\printbibliography
\end{document}
2
  • Or wrap the LTR items with \begin{otherlanguage}{english}\end{otherlanguage}. Nov 26, 2022 at 8:38
  • @JavierBezos Maybe you can provide a separate answer. Your opinion is highly relevant. Nov 26, 2022 at 16:01
1

I've pruned down Cicada's code so that the essential parts are readily apparent.

\begin{filecontents*}[overwrite]{\jobname.bib}
@book{silverstein,
   author = {Shel Silverstein},
   title = {The Giving Tree},
   year = {1964},
   langid = {english}
}
@Book{goldberg,
   author = {לאה גולדברג},
   title = {דירה להשכיר},
   year = {1959},
   langid = {hebrew}
}
\end{filecontents*}

\documentclass{article}
\usepackage[bidi=basic,hebrew,provide=*]{babel}
\babelprovide[import]{english}
\babelfont{rm}[Renderer=HarfBuzz]{FreeSans}

\usepackage{biblatex}
\addbibresource{\jobname.bib}
\AtEveryBibitem{%
   \savefield{langid}{\langid}%
   \selectlanguage{\langid}%
   \iffieldequalstr{langid}{hebrew}%
   {}%
   {%
      \hspace{\leftmargin}%
      \hspace{\biblabelsep}%
   }%
}
\begin{document}
\cite{silverstein}\cite{goldberg}
\printbibliography
\end{document}

If the above code is saved in ~/Test.tex, and the following commands are then executed in the Terminal:

\> cd ~
\> lualatex Test
\> biber Test
\> lualatex Test

then the file ~/Test.pdf is generated. When opened in a PDF viewer, it displays as follows. (Only the relevant part of the display was captured in the screenshot.)

A bidirectional bibliography

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .